Skip to content

A Python program that lets you play chess against a computer opponent. The program will have a visual interface showing the chessboard in 2D. The cool part? The AI you play against will be surprisingly strong, yet the code behind it will be easy to understand. : )

Notifications You must be signed in to change notification settings

abdullohtariq/Chess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

β™ŸοΈ Chess (Pygame)

A lightweight 2D chess game built with pygame. Play locally against a simple engine or use it as a base for your own chess experiments.

✨ Features

  • Interactive 2D chessboard with piece images
  • Click-to-move controls
  • Basic move logic & game state tracking (ChessEngine.py)
  • Works out-of-the-box with pygame

πŸ“¦ Requirements

  • Python 3.10+ (tested up to 3.13)
  • pygame β‰₯ 2.6.1

Install pygame:

python -m pip install pygame

Or in a virtual environment:

python -m venv .venv
.\\.venv\\Scripts\\Activate.ps1
python -m pip install --upgrade pip pygame

▢️ Run the game

From the project root:

python Chess/ChessMain.py

Or with an absolute path (Windows example):

& C:/Users/BILAL/AppData/Local/Programs/Python/Python313/python.exe c:/Users/BILAL/Documents/GitHub/Chess/Chess/ChessMain.py

βœ… Images are loaded relative to ChessMain.py, so the game runs regardless of your working directory.

πŸ“‚ Project structure

Chess/
  ChessMain.py        # GUI & main loop
  ChessEngine.py      # Game state & move logic
  Images/             # Piece images (wp.png, bR.png, ...)

πŸ›  Troubleshooting

  • ModuleNotFoundError: No module named 'Chess' β†’ Already fixed (now uses import ChessEngine).

  • Image load errors β†’ Ensure Chess/Images/ has all piece PNGs. Errors will print full paths to help debug.

  • No window / pygame crash β†’ Confirm you’re using the same Python environment where pygame is installed.

🚧 Roadmap

Short-term

  • Full legal moves (castling, en passant, promotion)
  • Undo/redo & move history
  • Move highlighting

Medium-term

  • Stronger engine (minimax + alpha-beta)
  • FEN/PGN save & load
  • Chess clocks

Long-term

  • Online multiplayer
  • Packaged builds (PyInstaller)
  • CI & unit tests

🀝 Contributing

Contributions welcome! Open an issue or draft PR before big changes.

About

A Python program that lets you play chess against a computer opponent. The program will have a visual interface showing the chessboard in 2D. The cool part? The AI you play against will be surprisingly strong, yet the code behind it will be easy to understand. : )

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages