The dataset is currently empty. Upload or create new data files. Then, you will be able to explore them in the Dataset Viewer.

Connect Four teacher corpus (GF(256) project)

The training and holdout data for Christof Ckal's Connect Four model β€” a GF(2⁸) integer network whose trunk does XOR, table lookups and integer adds instead of float multiply-accumulates.

Everything here is synthetic. The corpus was generated by a search teacher playing Connect Four against itself; it contains no personal data, no scraped text and no third-party content.

What is in it

Path Rows What it is
train/corpus_320k.txt 320,000 the training corpus: one game per line, board states in the v2 byte transcript
train/perply_targets.npz 320,000 the per-ply target sidecar for the same rows
holdout/corpus.txt 4,000 a board-disjoint holdout corpus
holdout/perply_targets.npz 4,000 the per-ply target sidecar for the holdout rows
SHA256SUMS β€” checksums for all four files

The corpus format

Each line of a corpus file is one game, encoded in the v2 byte transcript β€” a dense encoding with a fixed stride.

Each ply occupies exactly 10 bytes (PLY_LEN = 10):

Byte Meaning
0–6 one column byte per column A–G
7 the last move (0x41 + column, or NO_LAST)
8 whose turn it is
9 the move that was played

A column byte encodes the column's height and which player owns each cell, not just the height:

bits = sum(1 << r for r in range(h) if cell(r, c) == P1)
byte = 0x80 | (1 << h) | bits
  • bit 7 (0x80) set marks the byte as a column byte
  • bit h set is the height marker β€” h is that bit's index
  • bits 0..h-1: P1 owns row r iff bit r is set, P2 owns the rest

That makes the map a bijection onto column states, so decoding reconstructs both player masks exactly. (The v1 format stored column heights only, which cannot distinguish two different boards with the same heights β€” that was the measured 16 % win-in-1 error. v2 fixes it at zero extra bytes.)

So a line's length is 10 Γ— (number of plies) + 1 for the newline:

row 0: 10 bytes   (one ply)
row 1: 20 bytes   (two plies)
row 2: 30 bytes   (three plies)

The files are binary β€” open them in binary mode.

with open("train/corpus_320k.txt", "rb") as f:
    for row in f:
        game = row.rstrip(b"\r\n")      # one game, 10 bytes per ply

Decode it with the project's own module:

from src.c4.transcript_v2 import decode_game
moves = decode_game(game)

The sidecar

perply_targets.npz holds four arrays, all aligned to the corpus rows:

Array Shape dtype Meaning
target (320000, 19, 7) float32 per-ply, per-column target mass (7-way)
ply_of (320000, 19) int16 which ply each target slot refers to
teacher (320000, 19) int8 which solver produced the label (see below)
n_plies (320000,) int16 number of slots filled in that row

Slot order is newest-first. Slot 0 of a row refers to the last ply of the game, slot 1 to the one before it, and so on; ply_of gives the absolute ply index for each slot (-1 = no label). ply_of is what you need β€” read the slot order from it, do not assume it.

# row 3 of a 4-ply game -> ply_of = [3, 2, 1, 0, -1, ...]

teacher is a solver flag, not a column index

Value Meaning Slots (train)
0 no label at this slot 1,516,339 (25.0 %)
1 bounded exact solver (max_empty=7) 47,209 (1.0 %)
2 negamax alpha-beta search teacher 4,516,452 (99.0 % of labelled slots)

So 99 % of the labels come from the alpha-beta search teacher, not from the exact solver.

Targets are mostly one-hot

The target is multi-label in principle: when the solver had several equally good moves, the mass is spread over them instead of being collapsed onto one column.

In practice that is rare, and it is concentrated in the exact-solver slots:

Source Labelled slots Mean active columns Slots with >1 column
flag 1 (exact) 47,209 2.56 30,947 (65.6 %)
flag 2 (alpha-beta) 4,516,452 1.00 0 (0.0 %)

A row's target mass sums exactly to the number of labelled plies in that row (target.sum(axis=(1,2)) == (ply_of >= 0).sum(axis=1), true for all 320,000 rows).

The teacher β€” and what it is not

Two solvers labelled this corpus, recorded per slot in the teacher array:

  • 99.0 % of labelled slots β€” the negamax alpha-beta search teacher (src/c4/strong_solver.py). It returns a single move, so its targets are one-hot.
  • 1.0 % of labelled slots β€” the bounded exact solver (src/c4/exact_solver.py, max_empty=7). It returns the full set of equally-best moves, so its targets are multi-label. This is where every multi-label target in the dataset comes from.

The teacher is a search policy, not a proof of optimality. Connect Four is a solved game, but this corpus does not contain the full solution: the alpha-beta teacher has a depth and budget limit, and the exact solver only applies in the endgame (max_empty=7). The model imitates a bounded search.

So: no label in this dataset should be read as "the set of optimal moves", and nothing here supports a claim of perfect or provably optimal play.

The holdout is board-disjoint

holdout/corpus.txt contains boards the model has never seen β€” it is disjoint from the training corpus at the board level, not just split at the row level. That is what makes the holdout agreement number a generalisation measure rather than a fit measure.

Verify before use

sha256sum -c SHA256SUMS

The training corpus passes the project's integrity gate with zero violations:

from src.c4.corpus_integrity import assert_corpus_consistent
r = assert_corpus_consistent("train/corpus_320k.txt")
assert r["clean"]

An earlier corpus had a corrupt trailing field in 126,537 of 320,000 rows (39.5 %). The file published here is the repaired one (corpus_320k_fixed.txt); the unrepaired original is not published.

Use it

git clone https://huggingface.co/datasets/Chris4K/connect-four-gf256
cd connect-four-gf256
# clone the code repository next to it
git clone https://github.com/Ckal/connect-four-gf256.git

# train from this corpus
cd connect-four-gf256
python -m src.c4.train \
  --load-corpus ../connect-four-gf256/train/corpus_320k.txt \
  --perply-targets ../connect-four-gf256/train/perply_targets.npz \
  --holdout-corpus ../connect-four-gf256/holdout/corpus.txt \
  --holdout-targets ../connect-four-gf256/holdout/perply_targets.npz \
  --transcript v2 --move-loss 7way --soft-w 1.0 \
  --steps 100000 --batch 16 --ctx 192 --lr 0.0006 --seed 32 \
  --corpus-source teacher --hard-start 0 --hard-ramp 1000 --hard-w 0.5

The project code, papers and tests are at https://github.com/Ckal/connect-four-gf256; the model checkpoint is at https://huggingface.co/Chris4K/connect-four-gf256.

License

MIT. See the LICENSE file in the code repository.

Christof Ckal Β· ZeroFLops

Downloads last month
-

Space using Chris4K/connect-four-gf256 1