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
- Assignment 1 starter code
- Lecture 3, St. Petersburg Paradox
- Lecture 5, Trees and DAGs
- Lecture 6, Profiling and Optimization
- Go2, optimized version of Go1
- Assignment2 Starter Code
- 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)
- Lecture 12, Simulation methods
-
Solutions for Selected Activities
- Assignment 3 starter code
- Go3
- (No new code for Lecture 13)
- Lecture 14, Probabilistic simulation policies and Bernoulli experiments
- Lecture 15 and 16, MCTS
- Go4 and Go5 programs
- Lecture 19, Introduction to Neural Networks
First Go programs - Go0 and Go1
Download go.tgz
and unpack it.
The go
directory contains the following files:
- Go0.py - the Go0 class and the main function of program Go0
- Go1.py - the Go1 class and the main function of program Go1
- board.py - the class GoBoard implementing a basic Go board
- board_util.py - board-related utility functions
- test_board.py - INCOMPLETE but functional - unit tests for board.py
- gtp_connection.py - the class GtpConnection implementing a Go Text Protocol (GTP) connection
- gtp_connection_go1.py - example for how to extend a GTP connection with more commands
Lecture 2, 2d Go board
- go2d.py
Small code fragment for Go board implemented
as "2-dimensional" list-of-lists.
Assignment 1 starter code
Download assignment1.tgz
and unpack it.
For description of contents, see
Assignment 1
Lecture 3, St. Petersburg Paradox
Lecture 5, Trees and DAGs
Lecture 6, Profiling and Optimization
Go2, optimized version of Go1
- Download go2.tgz
and unpack it.
The go2 directory contains the program Go2,
which is the optimized version of Go1 as discussed in Lecture 6.
You can run
profile_Go2.py
and compare it
with the Go1 profile.
Assignment2 Starter Code
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
Lecture 12, Simulation methods
Solutions for Selected Activities
- Activities Lecture 5 some solutions:
count_dag_solution.py
Calls count_dag.py to compute and print the answers.
- Activities 8a and 8b solutions:
min_proof_tree.py
Compute size of minimal proof trees for (b,d) tree model.
Counts level by level in a loop, does not use a closed formula.
Go3
Assignment 3 starter code
Lecture 14, Probabilistic simulation policies
and Bernoulli experiments
Lecture 15 and 16, MCTS
Lecture 19, Introduction to Neural Networks (NN)
Go4 and Go5 programs
Created: Jan 3, 2018 Last modified: Nov 16, 2020
Martin Müller and Ting-Han Wei