An open API service indexing awesome lists of open source software.

https://github.com/mrtbk/shadow-code

๐ŸŽฎ A feature-rich chess game with Deep Reinforcement Learning (DRL) AI and real-time online multiplayer โ€” built with Python and Pygame.
https://github.com/mrtbk/shadow-code

ai chess deep-learning dqn game-development multiplayer pygame python reinforcement-learning socket-programming

Last synced: 5 months ago
JSON representation

๐ŸŽฎ A feature-rich chess game with Deep Reinforcement Learning (DRL) AI and real-time online multiplayer โ€” built with Python and Pygame.

Awesome Lists containing this project

README

          

# โ™Ÿ๏ธ Shadow-Code

**Shadow-Code** is a feature-rich chess game that supports both local AI battles and online multiplayer. Play against a Deep Reinforcement Learning (DRL) agent trained from scratch or connect with friends over a real-time socket-based networkโ€”all with an elegant Pygame-based interface and animated visuals.

---

## ๐Ÿš€ Features

- โœ… **Local Play vs AI**
Play against a trained Deep Q-Network (DQN)-based DRL agent.

- ๐ŸŒ **Online Multiplayer**
Host or join real-time matches using TCP sockets.

- ๐ŸŽž๏ธ **Smooth Animations**
Enjoy sliding piece animations for a polished experience.

- ๐Ÿ‘‘ **Promotion Interface**
Promote pawns with a clean graphical selection.

- ๐Ÿ”Š **Sound Effects**
Custom sounds for moves, captures, and promotions.

- ๐Ÿ“‹ **Move History Sidebar**
Track your game progress with a live move list.

---

## ๐Ÿ›  Installation

### 1. Clone the repository

```bash
git clone https://github.com/MrTBK/Shadow-Code.git
cd Shadow-Code
```

### 2. Install dependencies

Install the required packages via pip:

```bash
pip install -r requirements.txt
```

> **Note**: Requires Python 3.8+ and PyTorch.

---

## ๐Ÿง  Running the Game

To start the game:

```bash
python main.py
```

---

## ๐ŸŽฎ Modes of Play

### ๐Ÿง‘โ€๐Ÿ’ป Local Play (vs DRL)

- Select **Local** from the menu.
- Play against a Deep Q-Learning agent trained on legal chess states.

### ๐ŸŒ Online Multiplayer

#### Host a Game

- Select **Online** โ†’ **Host**.
- Wait for an opponent to connect.
- Game starts automatically after connection.

#### Join a Game

- Select **Online** โ†’ **Join**.
- Enter the IP address of the host machine.
- Connect and start playing.

---

## ๐Ÿ“ Project Structure

```
Shadow-Code/
โ”œโ”€โ”€ assets/ # Piece images & sound files
โ”œโ”€โ”€ dqn.py # DQN agent definition and utilities
โ”œโ”€โ”€ game.py # Game logic and rendering
โ”œโ”€โ”€ interface.py # UI handling (board, promotion UI, sounds)
โ”œโ”€โ”€ server.py # Socket-based networking
โ”œโ”€โ”€ main.py # Entry point
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ requirements.txt
```

---

## ๐Ÿง  DRL Agent Training

Our AI uses a Deep Q-Network with a flat board tensor input. Training code and logs are included in the project for reproducibility. If no `dqn_checkpoint.pt` exists, training can be resumed automatically.

---