AI Game Controller


An Evolutionary AI Controller for Autonomous Platform Gameplay

AI Game Controller is a C++ artificial intelligence project that combines a custom SFML platformer with NeuroEvolution of Augmenting Topologies. The application recreates a level inspired by Yoshi’s Island 1 from Super Mario World and trains an artificial neural network to control Mario and attempt to complete the level without scripted gameplay behaviour.

Developed before my reusable engine architecture, the project formed the practical component of my undergraduate dissertation and explores how neural networks, genetic algorithms and real-time simulation can be combined within an interactive application.


The Engineering Problem

Traditional game AI commonly relies on scripted rules, decision trees or finite-state machines. These approaches require developers to define how an agent should respond to known situations.

The challenge was to create a controller capable of learning platforming behaviour through evolutionary optimisation. The system needed to observe the level, convert environmental information into neural-network inputs, produce movement decisions and evaluate each controller according to its progress through the level.

My Role

I designed and implemented the complete platforming application, including player movement, physics, collision handling, level behaviour, enemies, camera movement, application states and debugging systems.

I also integrated the NEAT algorithm, designed the environmental inputs, connected neural-network outputs to player controls and implemented the training, fitness and visualisation systems used to evolve autonomous controllers.

Experiment Demonstration

Platforming Simulation

Demonstrates the custom SFML platforming environment used to evaluate both human and AI-controlled gameplay being played by a human.

Evolution in Progress

Demonstrates generations of controllers being evaluated while the neural network evolves through fitness-based selection, mutation and speciation.

Learned Autonomous Gameplay

Demonstrates the evolved neural controller successfully navigating the complete level without scripted behaviour or human input.

Architecture Overview

AI Game Controller combines a real-time SFML platforming simulation with a neuroevolution system responsible for creating, evaluating and evolving artificial neural networks.

The gameplay layer manages the level, player, physics and collisions. The controller layer converts the surrounding environment into network inputs, while the NEAT system evaluates performance and evolves improved controllers across successive generations.

Core Systems

The application is organised into three focused areas that connect gameplay simulation with evolutionary artificial intelligence.

Platforming Simulation

Implements player movement, jumping, gravity, tile-based levels, enemies, collectables, camera tracking and collision handling. These systems provide the environment in which both human and artificial controllers operate.

Neural Controller

Converts nearby level information into numerical neural-network inputs and interprets network outputs as player movement decisions. Different environmental input configurations were tested to determine how the amount of visible information affected learning.

NEAT & Training

Creates and evolves populations of artificial neural networks using fitness evaluation, mutation, crossover and speciation. Controllers are rewarded according to their progress through the level, allowing effective behaviours to develop over successive generations.

Together, these systems allow Mario to be controlled through learned neural-network behaviour rather than predefined gameplay rules.

Engineering Principles

PrincipleApplication
Separation of ConcernsGameplay, AI control, neural-network processing and evolutionary training are divided into focused systems.
Modular DesignPlayer behaviour, collisions, level objects, application states and NEAT processing are implemented as separate components.
Controller AbstractionHuman input and AI-generated decisions interact with the same underlying player systems.
Data TransformationLevel information is converted into numerical inputs before being processed by the neural network.
Objective EvaluationControllers are compared using measurable fitness based primarily on level progress.
Incremental ComplexityNEAT evolves network topology by introducing new neurons and connections over time.
Experimental ComparisonAlternative input structures were trained and compared to evaluate their effect on performance.
ObservabilityNeural-network structures and controller behaviour can be visualised during training.

Key Design Decisions

Learning Instead of Scripted Behaviour

The controller is not explicitly told when to move or jump. Successful behaviour emerges through repeated evaluation and evolutionary selection.

Shared Gameplay Systems

Human and artificial controllers use the same player, physics and collision systems, ensuring the AI operates under the same gameplay conditions as a human player.

Grid-Based Environment Inputs

The level is converted into a simplified grid of numerical values rather than supplying rendered images directly to the neural network.

Comparative Input Design

Both a small local input area and a wider environmental grid were evaluated. The wider representation provided the controller with more useful information about upcoming obstacles and level geometry.

Technologies

Development

C++

Visual Studio

Git

Engineering Approach

NeuroEvolution of Augmenting Topologies (NEAT)

Artificial Neural Networks

Genetic Algorithms

Evolutionary Computation

Fitness-Based Selection

Speciation

Structural Mutation

State-Driven Design

Separation of Concerns

Collision Management

Engineering Outcome

AI Game Controller demonstrates how evolutionary computation can be integrated into a real-time C++ platforming application.

By separating the gameplay simulation from the neural controller and evolutionary systems, the project provides a consistent environment in which artificial neural networks can be evaluated and improved. The wider environmental input configuration successfully evolved controllers capable of completing the level, demonstrating the importance of input representation when applying machine learning to interactive systems.

Application Gallery

Repository

Explore the source code to see how the architectural principles are implemented throughout the framework.