---
license: mit
task_categories:
- text-classification
- text-generation
- text2text-generation
language:
- en
pretty_name: Cot-dataset
---
# Version 1 of the dataset
## Structure of the dataset:
- ### Opening_type:
The title of the opening being played.
- ### Context:
A string representing a list of moves, each move is represented by the previous state of the board, the move that is going to be made, and the effect that the move had on the board.
- The board is represented as an 8*8 grid of characters where each character represents a piece or an empty square:
~~~
r . . q k b n r
p p p . p . p p
. . n . . p . .
. . . p . b . .
. . . P . . . B
. . . . P N . .
P P P . . P P P
R N . Q K B . R
~~~
- The move is represented by the uci format g8f6, specifying that the piece is square g8 moves to the square f6
- The type of move is represented by a list of integers separated by ',' where each integer represents the effect that the move will have on the board.
- 0 if it is a move without capture
- 1 if it is a move with capture
- 2 if a check is being made
- 3 if it is check mate
- 4 if it is en passant capture
- 5 if it is king side castling
- 6 if it is queenside castling
- 7 if it is a draw by stalemate
- 8 if there is a draw by insufficient material
- 9 if it is a draw by seventy-five moves rule
- 10 if it is a draw by fivefold repetition
- The whole context can look something like this:
After each board, there is a move, and the effect of the move generates the next board. A context list always ends with a board because the following two columns represent the move to be played and the effect that it'll have on the next board.
~~~
r . . q k b n r
p p p . p . p p
. . n . . p . .
. . . p . b . .
. . . P . . . B
. . . . P N . .
P P P . . P P P
R N . Q K B . R
m:e7e5
t:0
r . . q k b n r
p p p . . . p p
. . n . . p . .
. . . p p b . .
. . . P . . . B
. . . . P N . .
P P P . . P P P
R N . Q K B . R
m:d4e5
t:1
r . . q k b n r
p p p . . . p p
. . n . . p . .
. . . p P b . .
. . . . . . . B
. . . . P N . .
P P P . . P P P
R N . Q K B . R
m:f6e5
t:1
r . . q k b n r
p p p . . . p p
. . n . . . . .
. . . p p b . .
. . . . . . . B
. . . . P N . .
P P P . . P P P
R N . Q K B . R
~~~
- ## Move_type_pred:
- Follows the same format described in the context column with Type move
- ## Move_pred:
- Follows the same format described in the context column with move
## Creation process:
- ### Loading the Dataset:
- The code loads a dataset of chess games in PGN format using the Hugging Face **datasets** library. The dataset is called [patrickfrank1/chess-pgn-games](https://huggingface.co/datasets/patrickfrank1/chess-pgn-games)!.
- ### Parsing and Organizing Game Text:
- It extracts game text from the dataset and organizes it based on metadata and moves information.
- ### Parsing Game Information:
- It extracts relevant information from the game headers, such as player Elo ratings and opening names.
- ### Iterating Through Games:
- It iterates through each game and processes it if it has a specified opening and if at least one player has an Elo rating greater than 1700.
- ### Sampling Moves for Context:
- For selected games, it randomly samples subarrays of moves from the mainline of the game.
- ### Recording Context Information:
- It records the board state, move information, and move type prediction for each move in the sampled context.
- ### Storing Processed Data:
- The extracted information is stored in a dictionary and then converted to a data frame. The data frame is uploaded to the Huggingface Dataset hub. (As you can see)
- The code to create this dataset can be found here: [chess_openings_teacher/ML/Dataset_Creation](https://github.com/bit2424/chess_openings_teacher/tree/main/ML/Dataset_Creation)!
## Intuitions behind the design:
- The idea is that by creating the whole board grid, the model can learn to grasp the effect that a move has on the board and create a richer representation of the game.
- One of the aims of this representation is to help predict logical moves even without needing the game's history, just using the current state of the board in the grid representation.