This AI Chess Application is a sophisticated web-based chess game that allows users to play against various AI opponents or watch AI vs AI matches. The application leverages different AI models and algorithms to provide a challenging and educational chess experience.
- Interactive chessboard with drag-and-drop functionality
- Multiple game modes: Player vs AI, AI vs AI
- Various AI models: Minimax, A*, and OpenAI
- Adjustable AI difficulty levels
- Real-time game status updates
- Captured pieces display
- Move history logging
- Responsive design for different screen sizes
- Burger menu for quick access to game options
- Toast notifications for important game events
- React.js
- chess.js
- react-chessboard
- Web Workers for AI processing
- OpenAI API (optional)
-
Clone the repository:
git clone https://github.com/yourusername/ai-chess-application.git
-
Navigate to the project directory:
cd ai-chess-application
-
Install dependencies:
npm install
-
Start the development server:
npm start
- Open the application in your web browser.
- Use the burger menu to select a game mode.
- Choose AI models for each player (if applicable).
- Start the game and make moves by dragging and dropping pieces.
- Watch the AI respond with its moves.
- Use the reset option in the burger menu to start a new game.
- Implementation:
chessLogic.js
- Description: A depth-first search algorithm that evaluates future game states.
- Configuration: Adjust the
depth
parameter inChessGame.js
to change difficulty.
- Implementation:
astarChess.js
- Description: A best-first search algorithm using heuristics to evaluate moves.
- Configuration: Modify the
depth
andheuristicWeight
inChessGame.js
.
- Implementation:
openAIBot.js
- Description: Utilizes OpenAI's language models to generate chess moves.
- Configuration: Requires an OpenAI API key. Set the key in the UI or as an environment variable.
- Main component that manages the game state and AI interactions.
- Handles user interactions and updates the game board.
- Provides options for resetting the game and changing game modes.
- Allows users to choose AI models for each player.
- Displays notifications for important game events.
- Player First: Human plays as White, AI as Black.
- Computer First: AI plays as White, Human as Black.
- Computer vs Computer: Two AI players compete against each other.
- AI model selection: Modify the
aiModels
state inChessGame.js
. - Board size: Adjust the
boardSize
state for different screen sizes. - AI thinking time: Change the timeout in the
useEffect
hook inChessGame.js
.
- Fork the repository.
- Create a new branch for your feature:
git checkout -b feature-name
. - Make your changes and commit them:
git commit -m 'Add some feature'
. - Push to your fork:
git push origin feature-name
. - Create a pull request describing your changes.