Skip to content

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

Notifications You must be signed in to change notification settings

MrTBK/Shadow-Code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โ™Ÿ๏ธ 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

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

2. Install dependencies

Install the required packages via pip:

pip install -r requirements.txt

Note: Requires Python 3.8+ and PyTorch.


๐Ÿง  Running the Game

To start the game:

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.


About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages