File size: 3,821 Bytes
b9ab1bb
 
 
 
 
 
 
 
 
 
 
664e68f
 
b9ab1bb
78c0948
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b9ab1bb
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
---
license: mit
task_categories:
- token-classification
- text-classification
- text-generation
language:
- en
pretty_name: ChessSet-Community
size_categories:
- 1K<n<10K
tags:
- ChessAI-Community
---
# Chess Positions with Stockfish Evaluations

This dataset contains a collection of chess positions in Forsyth-Edwards Notation (FEN), each paired with a corresponding evaluation from the Stockfish chess engine. It is designed for use in training machine learning models for chess, analyzing chess positions, or for any application requiring a large set of evaluated positions.

## Data Format

The data is stored in a simple CSV (Comma-Separated Values) format without a header row. Each line in the file represents a single chess position and its evaluation.

The format is as follows:
`"FEN_string",evaluation`

### Fields

| Field       | Description                                                                                                                                                                                                                         |
|-------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `FEN_string`| A standard FEN string representing a specific board state. This includes piece placement, active color, castling availability, en passant target square, halfmove clock, and fullmove number. [Learn more about FEN](https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation). |
| `evaluation`| The Stockfish engine's evaluation of the position in centipawns. <br> - A positive value (`+110`) indicates an advantage for White. <br> - A negative value (`-95`) indicates an advantage for Black. <br> - A value near zero suggests a balanced position. <br> - Mate-in-N is represented as `#N` (e.g., `#3` for mate in 3 for the side to move) or `#-N` (e.g., `#-2` if the side to move is being mated in 2). |

### Example Data

```csv
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",+25
"r1bqkbnr/pp1ppppp/2n5/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3",+15
"r4rk1/pp1n1ppp/2pbp3/q2n2B1/3PN3/3Q1N2/PPP2PPP/1K1R3R b - - 5 13",-80
"4r1k1/pp1r1p1p/1qp1n1p1/4P3/3p1P2/2Q4P/PP1R2P1/3R2K1 w - - 0 29",#4
```

## How to Use

Here is a basic Python script to read and parse the data from a file named `chess_data.csv`.

```python
import csv

def load_chess_data(file_path='chess_data.csv'):
    """
    Loads and prints chess positions and their evaluations from the dataset.
    """
    positions = []
    try:
        with open(file_path, 'r', encoding='utf-8') as f:
            reader = csv.reader(f)
            for row in reader:
                if not row:
                    continue
                fen_string = row[0]
                evaluation = row[1]
                positions.append({'fen': fen_string, 'eval': evaluation})
                print(f"FEN: {fen_string}, Evaluation: {evaluation}")
    except FileNotFoundError:
        print(f"Error: The file {file_path} was not found.")
    except IndexError:
        print(f"Error: Malformed row found in {file_path}.")
    
    return positions

if __name__ == '__main__':
    # Assuming your data is in 'chess_data.csv'
    chess_dataset = load_chess_data()
    if chess_dataset:
        print(f"
Successfully loaded {len(chess_dataset)} positions.")

```

## Data Generation (Example)

This dataset was generated using:
*   **Engine**: Stockfish 16
*   **Search**: 15 seconds per position
*   **Source**: A curated list of positions from grandmaster games.

## License

This dataset is released under the [MIT License](https://opensource.org/licenses/MIT). You are free to use, modify, and distribute it for any purpose.