Dataset Viewer

The dataset viewer is not available because its heuristics could not detect any supported data files. You can try uploading some data files, or configuring the data files location manually.

YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/datasets-cards)

Go Game AI Training Environment & Dataset Generator

Welcome to the Go AI Training Environment, a tool designed for the "Martial Terran" project on Hugging Face Datasets. This application serves two primary purposes:

  1. A Visual Tool: To play the game of Go against an AI opponent or watch two AIs play against each other.
  2. A Dataset Generator: To automatically record every game played into the standard Smart Game Format (.sgf), creating a valuable dataset for training and fine-tuning Go-playing machine learning models.

The system is architected with a clean separation between the user interface and the AI, allowing developers to easily plug in their own models for testing and training.

Core Components

The project consists of two main Python scripts that work together:

  • Go_Game_Frontend_V3.2.py: The graphical user interface (GUI) built with Pygame. It is responsible for drawing the board, handling human player input (mouse clicks), managing the game flow, and communicating with the AI.
  • Go_AI_Backend.py: The AI "brain." This is a simple command-line script with no graphics. Its only job is to receive the current state of the board, decide on a move, and send it back to the frontend. This script is designed to be the place where you integrate your pretrained transformer or other ML model.

How to Use

Prerequisites

  • Python 3
  • Pygame library (pip install pygame)

Running the Application

  1. Ensure both Go_Game_Frontend_V3.2.py and Go_AI_Backend.py are in the same directory.
  2. Run the frontend from your terminal:
    python Go_Game_Frontend_V3.2.py
    

The game window will appear, and you can start playing or watching immediately.

Controls and Modes

  • Human vs. AI (Default): The human plays as Black. Click on an intersection to place a stone. The frontend will then send the board state to the AI, which will play as White.
  • AI vs. AI: Press the M key to switch to this mode. The application will launch two separate AI processes that will play against each other. This is ideal for accelerated data generation and overnight fine-tuning of your model.
  • New Game: Press the N key at any time to reset the board and start a new game.
  • Fallback AI: If the external Go_AI_Backend.py script crashes for any reason, the game will pause and display an error. Press the F key to continue the current game using a simple, built-in random-move AI.

Dataset Generation

Every game you start automatically generates a corresponding .sgf file in the same directory.

  • Format: Standard SGF (Smart Game Format), which is readable by most Go software.
  • Filename: game_YYYYMMDD_HHMMSS.sgf (e.g., game_20250828_224501.sgf).
  • Data Integrity: Moves are saved to the file the moment they are played, ensuring that even incomplete games are preserved for the dataset.

Version History: The Evolution of the Tool

This project has evolved significantly to reach its current state as a machine learning tool.

  • V1.0: The Historic Replay

    • Purpose: A non-interactive historical viewer.
    • Features: This initial script was designed solely to visually reproduce Game 2 of the historic match between Lee Sedol and AlphaGo, famously highlighting AlphaGo's divine "move 37."
  • V2.0: The Interactive Viewer

    • Purpose: To enhance the educational value of game replays.
    • Features: Introduced interactive controls (arrow keys, move number input) and a special "latch" mechanism. The latch would automatically pause the game before a complex sequence (like a ko fight) and display a text box explaining the situation to the user.
  • V3.0: The AI Training Environment

    • Purpose: A major architectural shift from a simple viewer to an interactive AI tool.
    • Features: Decoupled the application into the Frontend and Backend scripts. This version introduced Human vs. AI gameplay, the subprocess communication protocol, and the automatic generation of SGF dataset files for every game played.
  • V3.1: Robustness and Debugging

    • Purpose: To make the system more stable for developers.
    • Features: Hardened the communication logic between the frontend and backend. It can now gracefully handle an AI process crash, preventing the main application from crashing and instead displaying detailed error logs from the AI to aid in debugging.
  • V3.2: User-Friendly Fallbacks

    • Purpose: To ensure a human player's time is never wasted and data collection can continue even if the AI fails.
    • Features: Implemented automatic text-wrapping for error messages. Most importantly, it introduced the Fallback AI Mode, which prompts the user to continue the game against a simple built-in AI if the external backend script crashes.

Current Limitations: The "Dumb Board"

It is critical to understand that the current frontend (V3.2) acts as a "dumb board." Its primary responsibility is to record move coordinates and visualize them. It does not enforce the rules of Go. This means the core game logic is currently unimplemented in the frontend.

Roadmap & Next Steps

This project is a strong foundation, but there is exciting work still to be done. Implementing a full rules engine is the next major step in evolving this tool from a simple data collector into a complete Go-playing application.

The key unimplemented features on the roadmap are:

  1. Implement a Full Go Rules Engine:

    • Automatic Capture of Stones: The engine must automatically detect when a stone or group of stones has lost its last liberty and remove it from the board.
    • Illegal "Suicide" Move Detection: Prevent players from making moves that result in their own stones being captured (unless that move simultaneously captures opponent stones).
    • "Ko" Rule Handling: Implement logic to detect and prevent repeating board positions, which is a fundamental rule in Go.
  2. Integrate a Transformer Model:

    • The Go_AI_Backend.py script is a placeholder. The next step is to replace the random move logic with code that loads a pretrained transformer model, preprocesses the board state into a tensor, and performs inference to choose a move.
  3. Advanced UI Features:

    • A score estimator to show the current territory balance.
    • A feature to load and review the .sgf games generated by the tool.
    • Visual hints for legal moves.
Downloads last month
8