NEAT Invaders Game

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.

Actually those “neat” invaders are initially quite dumb and the game is certainly on the easy side :P 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.

Inputs

  1. Distance to the player on X axis
  2. Distance to the player on Y axis
  3. “Can fire” flag (zero or one)
  4. Current speed on X axis
  5. Current speed on Y axis
  6. Distance to closest rocket on X axis
  7. Distance to closest rocket on Y axis

Outputs

  1. Acceleration on X axis
  2. Acceleration on Y axis
  3. “Fire” value (if above a certain treshold, invader fires)

Fitness function
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.

Download

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

Share :
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Slashdot
  • Sphinn
  • TwitThis
Related posts :

2 Responses to “NEAT Invaders Game”

  1. That’s so funny! Nice work. Are you still unable to reach my website, http://www.hypeskeptic.com/mattias/ , because from what I can tell it should be up.

  2. 2
    White Shadow says:

    I can reach it now; I found out it was offline a long while ago and hadn’t checked it since then. Thanks for letting me know it’s back, I’ll update the post.

Leave a Reply