Wednesday, July 13, 2011

Cannons and the Swarm

An attempt to create fast algorithm for swarm movement in dynamic terrain, I've adapted the A* to work on a grid, that guides the agents. The grid cells contain danger level and flow direction. The "danger" is increased when a projectile hits the swarm agent. Once in a while, I run A* on the resulting grid, pathing from agent spawn points to the center. Flow directions are then aligned along the resulting path. Agents are using the flow vectors as movement direction (+ some primitive danger avoidance behavior).

The cannons use backpropagation neural network with 8 inputs, 12 tanh hidden nodes and 2 outputs. Inputs are projectile velocity vector, cannon location, target location and target velocity. I record projectile location when it passes closest to the target, and use the offset from the real target location as error for network learning. It gets better over time :)