Python Sample Code
All sample code is written in Python 3.
Code is used for activities and assignments.
Code includes a series of Go programs,
starting from the basics and leading up to simple re-implementations
of many of the techniques used by AlphaGo.
Contents
- First Go programs - Go0 and Go1
- Lecture 2, 2d Go board
- Lecture 3, St. Petersburg Paradox
- Lecture 5, Trees and DAGs
- Lecture 6, Profiling and Optimization
- Go2, optimized version of Go1
- Lecture 7, Search
- Lecture 8, Minimax
- Lecture 9, Minimax and Alphabeta part 2
- Lecture 10, Minimax and Alphabeta part 3
- (No new code for Lecture 11)
- Go3
- Lecture 12, Simulation methods
- (No new code for Lecture 13)
- Lecture 14, Probabilistic simulation policies and Bernoulli experiments
- Lecture 15 and 16, MCTS
- Lecture 18, Go4 and Go5 programs
- Lecture 19, Introduction to Neural Networks and Neural Net for TicTacToe
First Go programs - Go0 and Go1
See First Go programs - Go0 and Go1
and
Sample Session with the Go1 Program.
Lecture 2, 2d Go board
- go2d.py
Small code fragment for Go board implemented
as "2-dimensional" list-of-lists.
Lecture 3, St. Petersburg Paradox
Lecture 5, Trees and DAGs
Lecture 6, Profiling and Optimization
- Use
profile_Go1.py
in your go0and1
folder to profile the Go1
program.
Go2, optimized version of Go1
See Go2
Lecture 7, Blind Search
Lecture 8, Minimax and Alphabeta part 1
Lecture 9, Minimax and Alphabeta part 2
Lecture 10, Minimax and Alphabeta part 3
Simulation-based Go player Go3
See Go3
Lecture 12, Simulation methods
Lecture 14, Probabilistic simulation policies
and Bernoulli experiments
Lecture 15 and 16, MCTS
Go4 and Go5 programs
Lecture 19, Introduction to Neural Networks (NN) and Neural Net for TicTacToe
- nn.py
Two layer neural net from
iamtrask blog
- nn3.py
Three layer neural net from
iamtrask blog
- Code and data for learning neural net for TicTacToe.
Download tictactoe_nnet.tgz .
Code and data are in a directory tictactoe_nnet
. There are python files for training and play, and two data files
with the training examples (all solved TicTacToe positions) and a trained network. The most important files are:
- README.md in markdown format (simple html like text)
- multilayer_perceptron.py - implementation of the network
- tic_tac_toe_train_nnet.py - training the network
- nn_player.py - a player using the trained neural net data/tic_tac_toe_NN.npz
- db_player.py - a perfect player using the ttt database in data/tic_tac_toe_DB
- data/tic_tac_toe_DB - perfect play database
- data/tic_tac_toe_NN.npz - neural net trained for TicTacToe
- Some more python files to support standalone GTP-based players
Last modified: Aug 28, 2024 by Martin Müller