File size: 1,910 Bytes
6318d0e
 
cddfa09
 
4d96fdb
 
 
 
 
 
 
cddfa09
 
 
 
 
 
 
 
6318d0e
a9a76d4
3d58a70
 
 
a9a76d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fc09e0c
a9a76d4
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
---
license: mit
source_datasets:
- BlueSunflower/chess_games_base
configs:
- config_name: default
  data_files:
  - split: train
    path: "train.jsonl"
  - split: test
    path: "test.jsonl"
dataset_info:
  features:
    - name: fen
      dtype: string
    - name: move
      dtype: string
    - name: result
      dtype: string
---

# Dataset Card for stockfish-debug

See my [blog post](https://yp-edu.github.io/projects/training-gpt2-on-stockfish-games) for additional details.

## Columns

The datase contain the following columns:

- **fen:** The FEN string of the board.
- **move:** The move that was played.
- **result:** The result of the game (with `"-"` for unfinished games).

## Data details

Pre-processing of the Stockfish games provided by [BlueSunflower/chess_games_base](https://huggingface.co/datasets/BlueSunflower/chess_games_base).

Code used:
```python
import jsonlines
import chess
import tqdm


def preprocess_games(in_path, out_path):
    with jsonlines.open(in_path) as reader:
        with jsonlines.open(out_path, "w") as writer:
            for obj in tqdm.tqdm(reader):
                state_action = []
                parsed_moves = [m for m in obj["moves"].split() if not m.endswith(".")]
                board = chess.Board()
                for m in parsed_moves:
                    fen = board.fen()
                    move = board.push_san(m)
                    state_action.append({"fen": fen, "move":move.uci()})
                outcome = board.outcome()
                if outcome is None:
                    result = "-"
                else:
                    result = outcome.result()
                writer.write_all([
                    {**sa, "result":result} for sa in state_action
                ])
```

## Use the Dataset

Using basic `dataset` code:

```python
from datasets import load_dataset


dataset = load_dataset("yp-edu/stockfish-debug")
```