Hero Must Die is a game created in 72 hours for the Ludum Dare 25 game jam. It is a puzzle game where you have to figure out how to make the levels impossible for an AI to beat them given limited resources. The game is essentially a role reversal: You are the level designer, and you must stop the player (the AI) from winning! The AI uses NeuroEvolution of Augmenting Topologies (NEAT) to evolve a neural network capable of beating the levels.
- Neural network AI evolved with NEAT
- 7 levels
- Many item types for various puzzles including spikes, jump pads, ice, and tile solidity modification
- Source code available
The AI in Hero Must Die uses a custom distribution of NEAT (NeuroEvolution of Augmenting Topologies) to evolve a neural network capable of controlling the character to beat the levels. The neural network uses the map grid around the player’s position as inputs (simply the tile’s unique ID), as well as its current position, velocity, and a vector pointing it towards the goal. When the AI is being trained, many phenotypes are generated and try to beat the level. They are then evaluated based on their performance, allowing evolution to progress.
The selection method for the genetic algorithm is a simple roulette wheel algorithm. After either the AI has found a solution (beat the level) or run out of generations (around 60), the learning is terminated and it plays back the most fit phenotype. This game would be impossible without this special kind of AI because it revolves around the player preventing the AI from beating the level. The AI allows a role reversal that could not easily happen with standard game AI algorithms such as decision trees or path finding.