ISO9001认证
日期:2025-05-16 | 人气:114

5th-Grade-Project
How to run
First, ensure you have a Python interpreter installed. This project has currently been test on version 3.5.2
Clone this repo, or download and extract the zip file
Run: `python3 main.py`
A GUI should appear. This GUI can be used to interact with the game.
Game
Start by click the "New Game" button. This should initialize the game. Note that you must select a player color (black always goes first). Once you hit "Start", a black and white piece will appear at opposite ends of the board.
The board contains 64 squares (8x8). Black and white pieces are initially placed at (3,3) and (3,4) respectively.
A piece can be placed by selecting a piece color from the dropdown, followed by clicking the square you wish the desired piece to be placed. The game will automatically fill in any flippable pieces after a move is made.
The game is a turn based, no player is able to place a piece if it is not their turn. The game will automatically force a player to forfeit their turn if no legal move is available. The game ends when both players have no more moves available.
A running total of the score is kept on the bottom right of the screen.
Rules
If you are unfamiliar with the rules of Othello, please visit: https://en.wikipedia.org/wiki/ReversiRules
Technical Notes
The Game class encapsulates the entire game logic. The GameGrid class is a canvas which draws the current board state, and receives piece placements events through mouse clicks.
Piece state is stored as a 2D list in the Game class. Each time a move is made, the Game class validates the move, flips pieces as appropriate, and then finally updates the GameGrid to reflect the new board state.
Known Issues
There appears to be a bug in the AI Minimax algorithm preventing it from performing moves that do not capture pieces. This is currently preventing the AI from being able to make many of the end-game moves (where no more pieces can be captured). I believe the issue is in the heuristic I'm using to evaluate the game state, but I have not been able to find the root cause just yet.
The current heuristic I'm using simply evaluates the sum of the score. In the original game, black is min, white is max. However, as the number of possible moves goes down, the heuristic should take into account the number of possible moves available to each side.
Author
Cameron Rodriguez
Future Improvements
Improvements I had intended to make, given more time:
1) Solve the bug in the Minimax algorithm
2) Add a difficulty setting (maybe different heuristic functions based on number of moves available)
3) Let player choose which piece they would like (and whether they would like to go first)
4) Improve the game logic code
a) I'd have used a bitboard approach, or more efficient approach to checking which pieces to flip (maybe precompute valid moves for each piece?)
标签:


19842199029 在线咨询
');
})();