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.

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.

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

Related posts :

4 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. 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.

  3. home typist says:

    No es lo mismo degustar un coctel en un vaso común y sin ningún tipo de decoración, que beberlo en un recipiente el cual ha sido preparado con ciertos elementos que lo hacen más apetitoso.

  4. […] Yet Another Breakout Clone I’m not a game developer, but, as most programmers do, I’ve always had some interest in the field. The first game that I wrote back in gymnasium was a two-player version of Snake. Written from scratch in Turbo Pascal 7, it featured such innovative design decisions as a completely text- and number-less HUD (I couldn’t figure out how to properly output text in graphics mode) and diagonally moving snakes (it made the keyboard controls easier to implement). Later, while studying AI in the university, I fiddled with neural networks and genetic algorithms and eventually used both to control the enemy ships in my version of Space Invaders. […]

Leave a Reply