This is a proof-of-concept Invaders-style game where the invaders are controlled by neural networks and each new wave is evolved by genetic algorithms. This is made possible by DelphiNEAT library. I’m also using the GR32 library for semi-fast 2D graphics and PNGDelphi for PNG loading.
Update : Unfortunately, the Delphi NEAT site has been offline for a long time (I still have the library available locally if anoyone’s interested). To learn more about the NEAT method check out this page instead.
Actually those “neat” invaders are initially quite dumb and the game is certainly on the easy side I believe they might become smarter if you let them evolve for a while (i.e. survive 10 waves or so). Some fiddling with various constants defined in the source code could also yield interesting results. Anyway, I see this program as complete and won’t be updating it in the near future.
Here’s the basic model of an aliens’ mind :
Each invader is controlled by an artificial neural network.
- Distance to the player on X axis
- Distance to the player on Y axis
- “Can fire” flag (zero or one)
- Current speed on X axis
- Current speed on Y axis
- Distance to closest rocket on X axis
- Distance to closest rocket on Y axis
- Acceleration on X axis
- Acceleration on Y axis
- “Fire” value (if above a certain treshold, invader fires)
To enable evolution, we need a way to rate an invaders’ performance. In this game invaders are awarded points for various actions and these points are used to calculate their fitness. Currently points are awarded for staying alive (0.1 points per second), hitting the player with their bombs (200 points) and generally being trigger-happy (0.1 for every bomb dropped). You can play around with these values (and add new ones) to evolve different behaviours.
Executable (479 KB)
Required : Windows (Any), a decent CPU (45 FPS on my Duron 1,2 GHz)
Source code (107 KB)
Required : Delphi 7 + the abovementioned libraries