Space AI

Since I’ve always been interested in artificial intelligence, I attended the course Artificial Intelligence for Games for which the project Space AI has been developed. It is a simulation of a simplified 2D space environment in which spaceships controlled by artificial intelligence interact with each other. I did both graphics and programming (gameplay, AI) myself.

Miners are unarmed spaceships that search the area for asteroids. When they discover an asteroid, they approach and dismantle it for resources. Afterwards, they search for more asteroids. As soon as the storage space of the ship is completely filled, it flies to a miner station to empty it. If a pirate ship comes near, the miner will try to flee until it either gets destroyed or no pirate ship is around anymore. If the miner has been damaged it will approach the nearest heal station to repair and then continue its mining routine.
Pirates are aggressive, armed spaceships that hunt for miners. They wander around until a miner comes in their sight. Then they approach the miner respectively pursue it and fire their weapons as soon as the miner is within combat range. The miner will be destroyed if a sufficient amount of damage is inflicted. Afterwards, the pirates look for new victims. If a pirate is attacked by one or more policemen, it will try to destroy them first before continuing the hunt.
Policemen are special ships that start from a police station as soon as a miner is attacked or pursued by a pirate. In that case the miner makes an emergency call which is stored at the miners current position. The next available policeman will then fly to this emergency call and as soon as it has reached it, combat all nearby pirate ships for a given period of time. In doing so, it either gets destroyed or subsequently returns to the police station.

The AI which controls the space ships was implemented using hierarchical state machines. The movements are controlled by steering behaviors. In detail, a seek/arrival behavior, a wander and a flee behavior with multiple escape targets were implemented. For angular adjustment the ships use a LookWhereYouAreGoing behavior, i.e. they always look in their current moving direction.

You can find the project on my GitHub page.