AI for Supertuxkart

Python  //  Machine Learning  //  Reinforcement Learning

01. Overview

A comparative analysis of machine learning approaches for developing artificial intelligence in the Supertuxkart soccer mode. The objective was to build a competitive bot capable of real-time decision-making, strategic maneuvering, and scoring against opponents.

Three distinct architectures were evaluated: a basic scoring model, a Reinforcement Learning (RL) model, and an enhanced scoring model utilizing higher-level functions.

02. Data & Feature Engineering

The models were trained using a 101.1 MB dataset recorded during automated 1-vs-1 matches. Game state inputs were logged every 250 milliseconds. Data imbalance was mitigated by equalizing the ratio of desirable actions (10 seconds prior to a goal) to randomized undesirable actions.

03. Evaluated Models & Performance

A. Basic Scoring Model

A binary classification model evaluating raw control inputs (e.g., forward, reverse, left). Despite reaching a training accuracy of 0.912, it failed to translate parameters to dynamic gameplay, consistently losing 0:100 against the hard-coded baseline AI.

B. Reinforcement Learning (RL) Model

An adaptive model utilizing a reward system (+10 for scoring, -10 for conceding, +3 for hitting the ball towards the goal, etc.). Following an initial supervised pre-training phase, the model interacted directly with the environment. Over 72 hours of training, the model improved its decision-making, elevating its match performance from 0:100 to 3:100 against the baseline AI. Although hardware constraints limited the total training duration, the consistent upward trend in performance demonstrates clear improvement and indicates promising potential given extended computational resources.

C. Enhanced Scoring Model

This model bypasses raw input controls by using the scoring network to dynamically prioritize strategic targets (the ball, opponents, or power-ups). Delegating execution to higher-level functions resolved the strategic limitations of earlier models and proved highly effective. This framework delivered a statistically significant performance advantage. In a 100-game evaluation against the baseline AI, the enhanced model secured a decisive 72% win rate.

View Source on GitHub