Skip to content

ColbyStarr/tetris_ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tetris AI

This is a Tetris-playing AI with support for automated optimization using a weight-based utility function.

Features

  • Play Tetris with a custom agent (Dellacherie-Thiery)
  • Run multiple episodes for benchmarking
  • Optimize the agent's weights using simulated annealing
  • Headless mode for faster, non-visual simulation
  • Automatically initializes a weights.json file to store learned weights

Requirements

  • Python 3.9+
  • pygame
  • numpy

Install dependencies with:

pip install -r requirements.txt

Usage

Run the Tetris AI using the command-line interface.

Run episodes (evaluate agent performance)

python main.py run

Options:

  • --episodes N: Number of episodes to run (default: 200)
  • --headless: Disable rendering for faster evaluation

Example:

python main.py run --episodes 100 --headless

Optimize weights using simulated annealing

python main.py optimize

Options:

  • --headless: Disable rendering during optimization

Example:

python main.py optimize --headless

weights.json

When the program is first run, it checks for the existence of a file called weights.json. If it doesn't exist, it creates one and initializes it with an empty object ({}). This file is used by the optimizer to store and update the weights that define the agent's decision-making.

About

This is a Tetris-playing AI with support for automated optimization using a weight-based utility function.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages