Skip to content

ujjwalkumar26/LLMsChessBattle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI vs AI Chess

A chess battle application where two local Ollama models compete against each other on the board. Built with React/TypeScript frontend and FastAPI backend.

Screenshot

Overview

This application enables you to pit two local language models against each other in a game of chess. Each move is decided by an AI model running locally on your machine through Ollama, making it lightweight and privacy-friendly.

Tech Stack

  • Frontend: React + TypeScript, Vite, Tailwind CSS
  • Backend: Python, FastAPI, python-chess
  • AI Runtime: Ollama (local model inference)

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • Ollama installed and running

Installation

Backend Setup

  1. Navigate to the backend directory:
cd backend
  1. Install Python dependencies:
pip install -r requirements.txt

Frontend Setup

  1. Navigate to the frontend directory:
cd frontend
  1. Install Node dependencies:
npm install

Running the Application

Start Ollama

Ensure Ollama is running on your machine:

ollama serve

Start the Backend

From the backend directory:

python main.py

The API will be available at http://localhost:8000

Start the Frontend

From the frontend directory:

npm run dev

The UI will be available at http://localhost:5173

Quick Start

Run the included batch file to start both services:

run_chess_battle.bat

How to Use

  1. Open the frontend in your browser
  2. Select two Ollama models from the available options (e.g., llama2, mistral)
  3. Click "Start Game" to begin the match
  4. Watch as the AI models analyze the board and make their moves
  5. The game ends when there's a checkmate, stalemate, or other terminal condition

API Endpoints

  • GET /models - List available Ollama models
  • GET /state - Get current game state (board position, logs, etc.)
  • POST /start - Start a new game with selected models
  • POST /stop - Stop the current game

Features

  • Real-time game updates via polling
  • Live game logs showing move analysis
  • Automatic move generation based on model inference
  • Support for any local Ollama models
  • Clean, responsive web interface

Architecture

The backend manages the game state and communication with Ollama. Each turn, the active model receives the current board position and generates the next move. The frontend polls the backend for updates and renders the chess board with piece positions.

About

Very small logical chess battle setup between Ollama local LLMs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors