Sun Chess is a Vietnamese board game implemented in Python using the Pygame library. This game features special movement rules, a distinctive win condition centered around the "Sun" piece, and an AI opponent powered by a minimax algorithm.
-
Board: The game is played on a 7x7 board.
-
Pieces: Each player has 14 pieces:
- 13 numbered pieces (values 1-4)
- 1 Sun piece (value 0)
-
Initial Setup:
- Row 1: [4, 3, 2, 0, 2, 3, 4]
- Row 2: [1, 2, 3, 4, 3, 2, 1]
- (Mirrored for the opposite player)
-
Movement:
- Pieces move in a straight line (horizontal, vertical, or diagonal).
- The number of squares moved must exactly match the piece's value.
- The Sun piece (0) moves like a piece with value 1 (one square in any direction).
- Pieces can move through other pieces (both friendly and opponent pieces).
-
Capture: A piece captures by moving to a square occupied by an opponent's piece.
-
Win Condition: The game ends when a player's Sun piece is captured. The player who loses their Sun piece loses the game.
- Interactive GUI with a game board and info panel
- Turn indicator
- Valid move highlighting
- New Game and Exit buttons
- Winner display
- AI opponent using minimax algorithm with alpha-beta pruning
- Python 3.x
- Pygame 2.6.0
- Ensure you have Python installed on your system.
- Clone this repository or download the source files.
- Install requirements by running:
pip install -r requirements.txt
- Run the script:
python main.py
- The game window will open, showing the board on the left and an info panel on the right.
- You play as the Red pieces, and the AI controls the Black pieces.
- Players take turns moving pieces:
- Click on a piece to select it.
- Valid moves will be highlighted with green circles.
- Click on a highlighted square to move the piece.
- The info panel shows whose turn it is or who has won.
- Use the "New Game" button to reset the board at any time.
- Use the "Exit" button or close the window to end the game.
The game features an AI opponent that uses the minimax algorithm with alpha-beta pruning. The AI:
- Evaluates the board based on piece values and the presence of Sun pieces.
- Prioritizes capturing the opponent's Sun and protecting its own.
- Looks ahead several moves to make strategic decisions.
- Has a time limit of 5 seconds per move to ensure responsiveness.
Feel free to fork this project and submit pull requests with improvements or bug fixes. You can also open issues for any bugs you find or features you'd like to suggest.
This project is open source and available under the MIT License.