Logo Lanfrica

Meiring47817909/Tsoro_Yematatu

Record type:

softwareproject
Creator:
Mei
Host:
This project implements the traditional African board game Tsoro Yematatu and explores reinforcement learning approaches (tabular Q‑learning and Deep Q‑Networks) to train agents that can play the game. It also includes a Tkinter GUI for interactive play. # Tsoro Yematatu Reinforcement Learning Project This project implements the traditional African board game **Tsoro Yematatu** and trains a Tabular Q-Learning agent to master it. The game features a completely mathematically symmetric zero-sum reward function (Option C) and a hard 50-turn cap to enforce hyper-efficient, realistic gameplay. It also includes a Tkinter GUI for interactive human-vs-AI play. --- ## πŸ“‚ Project Structure ```text tsoro_yematatu/ β”‚ β”œβ”€β”€ game/ β”‚ β”œβ”€β”€ game_interface.py # Abstract interface for games β”‚ β”œβ”€β”€ tsoro_yematatu.py # Tsoro Yematatu game rules & logic β”‚ β”œβ”€β”€ board_gui.py # Tkinter GUI for human play β”‚ β”œβ”€β”€ agents/ β”‚ β”œβ”€β”€ gui_agent.py # GUI wrapper for human vs computer β”‚ β”œβ”€β”€ qlearning_agent.py # Core Q-learning agent with Option C reward β”‚ β”œβ”€β”€ training/ β”‚ β”œβ”€β”€ train_qlearning.py # Train the Q-learning agent β”‚ β”œβ”€β”€ evaluate_master.py # Tournament: 1000-episode agent vs historical checkpoints β”‚ β”œβ”€β”€ profile_training_intervals.py # Track average game lengths in 100-episode buckets β”‚ β”œβ”€β”€ main.py # Entry point for GUI play ``` ## πŸš€ How to Use ### 1. Train the Agent Train a fresh Q-learning agent. We recommend 1,000 to 5,000 episodes for optimal intelligence. This will generate a file called `qlearning_table.pkl` in the root directory. ```bash python training/train_qlearning.py --episodes 5000 ``` ### 2. Play the Game (GUI) Play interactively against the computer using the Tkinter GUI. By default, you play as 'X' (going first). ```bash python main.py --mode qlearning --player O ``` **Options:** - `--mode random` β†’ computer plays completely random moves - `--mode qlearning` β†’ computer uses trained Q‑learning agent - `--player X|O` β†’ choose which side the computer plays (O goes second) - `--model filename.pkl` β†’ load a specific Q-table file (defaults to `qlearning_table.pkl`) *Example:* To play as 'O' (meaning the A …