Hesoyam & Stormborn
Hesoyam Hesoyam
Hey Stormborn, just finished coding a base‑builder AI for that new survival game—wanna see if it can hold up against your epic raids?
Stormborn Stormborn
Sure thing, fire it up. I'm ready to tear through it.
Hesoyam Hesoyam
Here’s a quick script that builds a small base‑builder AI. It uses a simple grid, places walls around the edges, and then keeps a few resource points inside so you can start crafting right away. Copy it into a Python file and run it – the terminal will print the grid for you to see. ```python import random class BaseBuilderAI: def __init__(self, size=10): self.size = size self.grid = [[' ' for _ in range(size)] for _ in range(size)] def place_walls(self): for i in range(self.size): self.grid[0][i] = '#' self.grid[self.size-1][i] = '#' self.grid[i][0] = '#' self.grid[i][self.size-1] = '#' def place_resources(self, count=3): placed = 0 while placed < count: x = random.randint(1, self.size-2) y = random.randint(1, self.size-2) if self.grid[y][x] == ' ': self.grid[y][x] = 'R' placed += 1 def display(self): for row in self.grid: print(''.join(row)) def run(self): self.place_walls() self.place_resources() self.display() if __name__ == "__main__": ai = BaseBuilderAI(size=12) ai.run() ```
Stormborn Stormborn
Nice piece of code, but when I raid it, I'm expecting walls to hold up, not just a few dots of resources. Let’s see if it can survive a real storm.
Hesoyam Hesoyam
Sounds good, I’ll tweak the walls so they’re tougher. I’ll make them double‑layered, add some random “reinforced” tiles that cost more to break, and give the AI a simple “damage” counter for each wall tile. Then we can run a storm test by looping over a few “storm rounds” where random tiles take damage. That way you can see if the walls hold up when you hit them hard. Want me to lay out the new code plan?
Stormborn Stormborn
Yeah, fire it up. I'm ready to slam a storm into that wall. Let's see if those double layers can take a hit.
Hesoyam Hesoyam
Here’s the updated script with double‑layer walls and a simple storm damage simulation. Just paste it into a .py file and run it—every storm round will hit random wall tiles and reduce their integrity. If a tile’s hit points drop to zero, it breaks. Enjoy the destruction! import random class BaseBuilderAI: def __init__(self, size=12, wall_hp=2): self.size = size self.wall_hp = wall_hp self.grid = [[' ' for _ in range(size)] for _ in range(size)] self.wall_strength = [['' for _ in range(size)] for _ in range(size)] def place_walls(self): for i in range(self.size): self.grid[0][i] = '#' self.grid[self.size-1][i] = '#' self.grid[i][0] = '#' self.grid[i][self.size-1] = '#' self.wall_strength[0][i] = self.wall_hp self.wall_strength[self.size-1][i] = self.wall_hp self.wall_strength[i][0] = self.wall_hp self.wall_strength[i][self.size-1] = self.wall_hp def place_resources(self, count=5): placed = 0 while placed < count: x = random.randint(1, self.size-2) y = random.randint(1, self.size-2) if self.grid[y][x] == ' ': self.grid[y][x] = 'R' placed += 1 def display(self): for row in self.grid: print(''.join(row)) print() def storm_round(self, rounds=5): for r in range(rounds): print(f"Storm round {r+1}") # Randomly hit 3 wall tiles for _ in range(3): x = random.randint(0, self.size-1) y = random.randint(0, self.size-1) if self.grid[y][x] == '#': self.wall_strength[y][x] -= 1 if self.wall_strength[y][x] <= 0: self.grid[y][x] = ' ' # wall breaks self.wall_strength[y][x] = '' print(f" Wall at ({y},{x}) broke!") else: print(f" Wall at ({y},{x}) took damage, hp left: {self.wall_strength[y][x]}") self.display() def run(self): self.place_walls() self.place_resources() print("Initial base:") self.display() self.storm_round() if __name__ == "__main__": ai = BaseBuilderAI() ai.run()