I Like Trains
A multiplayer Python programming game developed for EPFL students.
Project
I created I Like Trains in 2025 for students at EPFL. Participants write autonomous train agents that compete to transport passengers on a shared grid, balancing route choices, collision avoidance and the cost of carrying a longer train.
View code ↗i-like-trains__video_01Educational context and contribution
The project provides a shared game environment in which students implement and test decision-making strategies in Python. My contribution was creating the game for this educational setting at EPFL.
The student-facing task is to build an agent: observe the current state, choose an action and inspect its consequences during play. The supplied environment handles the simulation, network communication and graphical display.
Game mechanics
Agents collect passengers that appear on the map and transport them to a delivery zone to score points. Picking up passengers increases the number of wagons, making the train longer and slower. An agent must therefore balance collecting more passengers against the time and risk involved in delivering them.
Trains move on a two-dimensional grid and can turn left or right, continue straight, or drop wagons. Collisions with walls or other trains cause a temporary elimination before respawning. These rules create competing demands for navigation, capacity management and collision avoidance.
i-like-trains__image_02Agent interface
A student agent inherits from BaseAgent and implements get_move(), which is called to request the next action. The agent receives information about the grid, trains, passengers and delivery zone and can retain additional state for its strategy.
This interface supports incremental development: start with avoiding walls, add passenger selection, then account for other trains and blocked routes. Students can maintain several versions of an agent and compare their behaviour.
Client–server architecture
The Python server maintains game rooms, client connections and the authoritative simulation state. It updates trains, passengers and delivery zones and broadcasts state information to connected clients.
The client manages network communication, input and Pygame rendering. Received state updates are passed to the agent, which returns an action to the server. Keeping the agent separate from simulation and display lets students focus on their control logic.
Testing and comparison
The game provides agent, manual and observer modes. Students can run a local server for development, control a train with the keyboard, or observe several agents competing. A remote server supports networked matches.
The documented assessment compares submitted agents against bots at different levels. The project output is the game, agent interface and teaching documentation; agent competition scores measure performance within the game.