Downloads · 30 days
0
Skyhigh-2203/tictactoe-gpt-1m
tictactoe-gpt-1m is a reinforcement learning model from Skyhigh-2203. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
A compact, ultra-fast GPT-style transformer model (~1.59M parameters) trained to play optimal, unbeatable Tic-Tac-Toe.
Downloads · 30 days
0
Access
Public
Updated Aug 18, 2026
Repo size
19.1 MB
Likes
1
Public
Click a slice to open those files.
.pt38.2 MB · 100%
From the Hugging Face model README
A compact, ultra-fast GPT-style transformer model (~1.59M parameters) trained to play optimal, unbeatable Tic-Tac-Toe.
Tested on an NVIDIA GeForce RTX 4060 Laptop GPU:
The board is represented by 11 tokens:
[turn] [cell 0] [cell 1] ... [cell 8] [dummy prediction token]
0 (X's turn), 1 (O's turn)4 (Empty), 5 (X), 6 (O)78..16 mapping to cells 0..8import torch
import numpy as np
from model import ModelConfig, build_model
from tokenization import encode_board, EMPTY
# Download 'best.pt' from this repo
checkpoint = torch.load("best.pt", map_location="cpu", weights_only=False)
config = ModelConfig(**checkpoint["model_config"])
model = build_model(config)
model.load_state_dict(checkpoint["model_state"])
model.eval()
# Board state: 0 for empty, 1 for X, -1 for O
board = (0,) * 9 # Empty board
player = 1 # X to move
# Tokenize and predict move
inputs = torch.from_numpy(encode_board(board, player).astype(np.int64)).unsqueeze(0)
with torch.no_grad():
logits = model(inputs)[0]
legal = inputs[0, 1:10] == EMPTY
move = int(logits.masked_fill(~legal, -torch.inf).argmax().item())
print(f"Model chose cell index: {move}")