File size: 2,539 Bytes
1b52fe0
9bf3082
9b2b018
 
40ea17c
9bf3082
9b2b018
 
de280f9
9b2b018
9bf3082
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
title: Chess Engine with Stockfish Integration
emoji: ♟️
colorFrom: green
colorTo: indigo
sdk: docker
sdk_version: "latest"
app_file: app.py
app_port: 8000
pinned: false
---



A Python chess engine with Stockfish integration, providing both a command-line interface and a REST API for playing chess against an AI opponent.

## Features

- **AI Integration**: Play against Stockfish, one of the strongest chess engines available
- **Multiple Interfaces**:
  - Command-line interface for quick games
  - REST API for integration with web or desktop applications
  - Streamlit web interface for graphical gameplay
- **Adjustable Difficulty**: Six difficulty levels from beginner to master
- **Position Analysis**: Get detailed evaluation of board positions
- **Move Hints**: Receive suggestions and explanations for optimal moves
- **Notation Support**: Works with both UCI (e2e4) and SAN (e4) chess notations
- **Game Management**: Start, play, analyze, and save games
- **Comprehensive Evaluation**: Material balance, piece positioning, king safety, mobility, and pawn structure

## Requirements

- Python 3.8+
- Stockfish chess engine (optional, but recommended for AI play)
- Dependencies listed in requirements.txt


## API Documentation

For information please refer Dockerfile

### Example API Usage

Start a new game:
```bash
curl -X POST "http://localhost:8000/game/new" \
  -H "Content-Type: application/json" \
  -d '{"player_color": "white", "difficulty": "medium"}'
```

Make a move:
```bash
curl -X POST "http://localhost:8000/game/move" \
  -H "Content-Type: application/json" \
  -d '{"move": "e2e4"}'
```

Get current game state:
```bash
curl -X GET "http://localhost:8000/game/state"
```

## Testing

Run the test suite:

```bash
python test/run_tests.py
```

For more detailed output:

```bash
python test/run_tests.py -v
```

The test suite includes:
- Board representation and move validation tests
- Position evaluation tests
- Game controller tests
- REST API endpoint tests

## License

### Code
The code in this repository is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

### Assets
The chess piece images and board square assets are licensed under the Creative Commons Attribution-ShareAlike (CC-BY-SA) license. See the [LICENSE-ASSETS.md](LICENSE-ASSETS.md) file for details on attribution and compliance requirements.

**Note:** If you redistribute this project or create derivative works, you must comply with both licenses - MIT for the code and CC-BY-SA for the assets.