Very late to the issue but nonetheless here it is

I finally realized why my algo doesn’t choose best path. What I had was check a bunch of locations and do the find_path_to_edge and check how many locations it has until it gets to an edge, however the reason this does not work is because my units many destroy some other firewalls along the way and change its path. So I was wondering how would I take into account some firewalls may be destroyed. I know it is a turn simulator but I am unclear how to go about creating one.

There are several threads on these turn simulators to help get you started, but here’s the basic idea:

You can add and remove desired units to simulate with the and_unit() and remove_units() game map helper functions. Copy the game state you want to simulate so you can mess up the simulated copy and preserve the original game state. From there, replicate how the “action frames” are handled until all attack units have died/scored, i.e. moving and attacking and taking damage.

1 Like

can you explain a bit more? I do not understand how this works…

Sure. You’ll get more information from those threads I mentioned, but here’s a little more detail:

The “action phase” of the game (when the units are placed and the game engine “runs the turn”) is what you want to simulate. You can get a sense of how this plays out just by watching the game, but the exact details of it are either in those threads or the docs of the game.

I recommend making a separate module (class in a .py file if you’re like me and don’t understand modules) for the simulator so that way the strategy file can “have” a simulator object that it can just pass a game_state into and get an entire simulation back, such as calling self.simulator.simulate(game_state) from the strategy file.

From there, in the main logic of your simulator, you just need to grab the important information of the game state, more specifically the game_state’s game_map, then break the “action phase” down into individual frames (the frame-by-frame you can examine in a replay). Off the top of my head I believe moving the units is the first step each frame, so every frame begins by moving each information unit to its next location if they’ve stayed there long enough (2 frame for pings, 4 for emps/scramblers, per the docs). To start, use the pathfinder in the gamelib to help get this path. Then run the logic on the rest of the action frame (following the docs and using the gamelib function to help you), keeping track of what information you’d like to know about the turn. Once the simulation is done (all information units have died or scored on the other side), return the information you’ve collected.