cs234-dreamchess
Stanford CS234 Reinforcement Learning Class Project
Science Score: 31.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.6%) to scientific vocabulary
Keywords
Repository
Stanford CS234 Reinforcement Learning Class Project
Basic Info
Statistics
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
cs234-dreamchess
Stanford CS234 Reinforcement Learning: Class Project
Datasets
We used the following dataset from Kaggle: 3.5 Million Chess Games, a text file export of ChessDB (docs).
Here's how to easily download the datasets with the Kaggle API:
console
kaggle datasets download -p data/chess-games --unzip milesh1/35-million-chess-games
Interpreting Entries
There is a slight learning curve to understand the dataset.
- Each row of the
all_with_filtered_anotations_since1998.txtfile contains the data for one chess game. - There is a header (game information) and body (moves), separated by
###. - The header contains information like game date, ELO of each player, and if an initial position was specified (e.g. Fischer Random Chess).
A chess board is an 8 x 8 grid where:
- Rows ("rank"): numbered 1 (bottom row) to 8 (top row).
- Cols ("file"): lettered a (left column) to h (right column).
Moves are written in Portable Game Notation, which uses Algebraic Notation (also known as standard algebraic notation (SAN) or standard notation) to describe each move as movetext.
Stated with regex-like notation,
movetext is governed by ab.(c?d?e|O-O|O-O-O|e=f):
a: player, either whiteWor blackB.- Note: in Forsyth–Edwards Notation (FEN) notation,
used by the
chesslibrary, white pieces are designated with capital letters, and black pieces are designated with lowercase letters.
- Note: in Forsyth–Edwards Notation (FEN) notation,
used by the
b: one-indexed turn number..: separator.
The rest could be one of several options:
- Normal move:
c?: piece, either pawn (no letter,Pin other contexts), kingK, queenQ, rookR, bishopB, or knightN(Sin other contexts).d?: capture, either no capture (no letter) or capturex.e: board destination. When 2+ pieces could have reached the destination, the piece's original rank (row), file (column), or both are included. For example,g5means the piece moved tog5,df8means the piece moved fromd8tof8,1a3means the piece moved froma1toa3, andh4e1means the piece moved fromh4toe1.
- Kingside castle:
O-O. - Queenside castle:
O-O-O. - Pawn promotion:
e: board destination (see above).=: indicates promotion.- Note: 'underpromotion' is a term for promoting a pawn to a non-queen piece.
f: exchanged piece.
And lastly if the move leads to a check + or checkmate #.
To help connect the dots, check this May 1783 blindfolded match's visualization.
Chess Engine
We are using the open source chess engine stockfish (source code).
To integrate with the stockfish engine,
we use the Python wrapper stockfish.
Developers
This project was developed using Python 3.10.
Getting Started: OS
To install OS-level dependencies on macOS:
console
brew install stockfish
After, run whereis stockfish to find
the engine was installed at /opt/homebrew/bin/stockfish.
Getting Started: Python
Here is how to create a virtual environment and install the core project dependencies:
console
python -m venv venv
source venv/bin/activate
python -m pip install -r requirements.txt
QA Tooling
Here is how to also install code quality assurance tooling:
console
python -m pip install -r requirements-qa.txt
pre-commit install
Getting Started: AWS
I launched several AWS
Deep Learning AMI GPU PyTorch 1.13.1 (Ubuntu 20.04) 20230315's
with instance type t2.2xlarge. Here's how they were configured:
```console
source activate pytorch python --version Python 3.9.16 ```
Whew, I almost used conda, that was a close call.
Step 1: install and configure Python 3.10:
console
python3 --version # 3.8.10
sudo apt update && sudo apt upgrade -y
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo apt install -y python3.10 python3.10-venv
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
python3 --version # 3.10.10
Step 2: git clone and install requirements into a venv:
console
git clone --recurse-submodules https://github.com/jamesbraza/cs234-dreamchess.git
cd cs234-dreamchess
python3 -m venv venv
source venv/bin/activate
python -m pip install -r requirements.txt --progress-bar off \
-r requirements-qa.txt \
torch==1.13.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
Note the torch==1.13.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
trick installs a CPU-only version of PyTorch 1.13.1
(since t2.2xlarge has no GPU).
I didn't want to use PyTorch 2.0 since it was released this week, and likely has some bugs.
Step 3: kick off your azg_chess script:
console
tmux
source venv/bin/activate
python -m azg_chess.script
Owner
- Name: James Braza
- Login: jamesbraza
- Kind: user
- Location: San Francisco Bay Area, CA, USA
- Company: AI Research @Future-House
- Website: jamesbraza.com
- Repositories: 45
- Profile: https://github.com/jamesbraza
Just a man eating spaghetti
Citation (CITATION.cff)
---
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: 'DreamChess: RL for Chess Play'
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: James
family-names: Braza
email: jamesbraza@stanford.edu
orcid: 'https://orcid.org/0000-0002-1444-5313'
affiliation: Stanford University School of Engineering
repository-code: 'https://github.com/jamesbraza/cs234-dreamchess'
abstract: >-
AlphaGo Zero-style reinforcement learning implementation
for standard chess.
keywords:
- chess
- reinforcement learning
- AlphaGo Zero
license: MIT
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 0
- Total pull requests: 26
- Average time to close issues: N/A
- Average time to close pull requests: less than a minute
- Total issue authors: 0
- Total pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 25
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
- jamesbraza (24)
- lasha81 (2)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- coverage *
- ipython *
- mypy *
- pre-commit *
- pylint *
- pytest *
- types-tqdm *
- chess *
- coloredlogs *
- kaggle *
- matplotlib *
- numpy >=1.21
- tensorboard *
- torch *
- tqdm *