Space shooter
Project 1
An endless space shooter built with Pygame. You steer a ship along the bottom of the screen with the arrow keys and blast the asteroids raining down. Every 10 kills, a boss arrives that sweeps across the screen and fires back. Shields give you three seconds of invulnerability, and you earn a new one each time a boss appears.
It was my first project, which I made in 11th grade, and I designed it around simple controls so a machine learning agent could learn to play it. I built a headless copy of the game as a reinforcement-learning environment and trained a Deep Q-Network in TensorFlow. The agent sees the five closest asteroids, chooses whether to move, wait or shoot, and learns from rewards for staying alive and destroying asteroids. Experience replay and a separate target network keep its training stable.
You can play it right here in your browser. I compiled it to WebAssembly with pygbag, which meant replacing Pygame's timers with frame-based timing and making the game loop asynchronous.
Python
- Pygame
TensorFlow
NumPy
WebAssembly