forked from wrongu/RocAlphaGo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wrongu
committed
Feb 10, 2016
0 parents
commit 4c86839
Showing
29 changed files
with
871 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.pyc | ||
*.npy | ||
*.h5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "interface/opponents/pachi/pachi"] | ||
path = interface/opponents/pachi/pachi | ||
url = https://github.com/pasky/pachi |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import numpy as np | ||
|
||
WHITE = -1 | ||
BLACK = +1 | ||
EMPTY = 0 | ||
|
||
class GameState(object): | ||
"""State of a game of Go and some basic functions to interact with it | ||
""" | ||
|
||
def __init__(self, size=19): | ||
self.board = np.zeros((size, size)) | ||
self.board.fill(EMPTY) | ||
self.size = size | ||
self.turns_played = 0 | ||
self.current_player = BLACK | ||
|
||
def copy(self): | ||
"""get a copy of this Game state | ||
""" | ||
other = GameState(self.size) | ||
other.board = self.board.copy() | ||
other.turns_played = self.turns_played | ||
other.current_player = self.current_player | ||
return other | ||
|
||
def is_legal(self, action): | ||
"""determine if the given action (x,y tuple) is a legal move | ||
""" | ||
(x,y) = action | ||
empty = self.board[x][y] == EMPTY | ||
on_board = x >= 0 and y >= 0 and x < self.size and y < self.size | ||
suicide = False # todo | ||
ko = False # todo | ||
return empty and on_board and (not suicide) and (not ko) | ||
|
||
def do_move(self, action): | ||
"""Play current_player's color at (x,y) | ||
If it is a legal move, current_player switches to the other player | ||
If not, an IllegalMove exception is raised | ||
""" | ||
(x,y) = action | ||
if self.is_legal((x,y)): | ||
self.board[x][y] = self.current_player | ||
self.current_player = -self.current_player | ||
self.turns_played += 1 | ||
else: | ||
raise IllegalMove(str((x,y))) | ||
|
||
def symmetries(self): | ||
"""returns a list of 8 GameState objects: | ||
all reflections and rotations of the current board | ||
does not check for duplicates | ||
""" | ||
copies = [self.copy() for i in range(8)] | ||
# copies[0] is the original. | ||
# rotate CCW 90 | ||
copies[1].board = np.rot90(self.board,1) | ||
# rotate 180 | ||
copies[2].board = np.rot90(self.board,2) | ||
# rotate CCW 270 | ||
copies[3].board = np.rot90(self.board,3) | ||
# mirror left-right | ||
copies[4].board = np.fliplr(self.board) | ||
# mirror up-down | ||
copies[5].board = np.flipud(self.board) | ||
# mirror \ diagonal | ||
copies[6].board = np.transpose(self.board) | ||
# mirror / diagonal (equivalently: rotate 90 CCW then flip LR) | ||
copies[7].board = np.fliplr(copies[1].board) | ||
return copies | ||
|
||
def from_sgf(self, sgf_string): | ||
raise NotImplementedError() | ||
|
||
def to_sgf(self, sgf_string): | ||
raise NotImplementedError() | ||
|
||
|
||
class IllegalMove(Exception): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class MCTS(object): | ||
pass | ||
|
||
class ParallelMCTS(MCTS): | ||
pass |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## Git guide for this project | ||
|
||
Get familiar with git's collaboration model - there are | ||
[plenty](http://rogerdudler.github.io/git-guide/) | ||
[of](https://guides.github.com/introduction/flow/) | ||
[resources](https://www.atlassian.com/git/tutorials/syncing) | ||
for this! | ||
|
||
Fork this repository, and push all your changes to your copy. Make sure your branch is up to date with the central repository before making a pull request. [Git-scm](https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows#Integration-Manager-Workflow) describes this model well. | ||
|
||
Follow these guidelines in particular: | ||
|
||
1. keep `upstream/master` functional | ||
1. write useful commit messages | ||
1. `commit --amend` or `rebase` to avoid publishing a series of "oops" commits (better done on your own branch, not `master`) ([read this](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History)) | ||
1. ..but don't modify published history | ||
1. prefer `rebase master` to `merge master`, again for the sake of keeping histories clean. Don't do this if you're not totally comfortable with how `rebase` works. | ||
1. track issues via GitHub's tools | ||
|
||
## Coding guide | ||
|
||
We are using Python 2.7. I recommend using `virtualenv` to set up an environment; [requirements.txt](requirements.txt) contains the necessary python modules. Beyond that, follow these guidelines: | ||
|
||
1. remember that ["code is read more often than it is written"](https://www.python.org/dev/peps/pep-0008) | ||
1. avoid premature optimization. instead, be pedantic and clear with code and we will make targeted optimizations later using a profiler | ||
1. write [tests](https://docs.python.org/2/library/unittest.html). These are scripts that essentially try to break your own code and make sure your classes and functions can handle what is thrown at them | ||
1. [document](http://epydoc.sourceforge.net/docstrings.html) every class and function, comment liberally |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 University of Rochester | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# AlphaGoReplication | ||
|
||
A replication of DeepMind's 2016 Nature publication, "Mastering the game of Go with deep neural networks and tree search," details of which can be found [on their website](http://deepmind.com/alpha-go.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
(;PB[Fan Hui]PW[AlphaGo]KM[7.5]HA[0]SZ[19]TM[3600]OT[1 moves / 30 sec]RU[Chinese]RE[W+R] | ||
;B[dp] | ||
;W[pp];B[cd] | ||
;W[pd];B[nc] | ||
;W[qf];B[ic] | ||
;W[cj];B[ci] | ||
;W[di];B[ch] | ||
;W[dj];B[dh] | ||
;W[cn];B[ei] | ||
;W[fq];B[eo] | ||
;W[cq];B[cl] | ||
;W[dl];B[cp] | ||
;W[dq];B[dm] | ||
;W[cm];B[el] | ||
;W[dk];B[bl] | ||
;W[bk];B[dn] | ||
;W[bm];B[gp] | ||
;W[gq];B[hp] | ||
;W[iq];B[pb] | ||
;W[qc];B[ld] | ||
;W[ec];B[dc] | ||
;W[db];B[ed] | ||
;W[cc];B[dd] | ||
;W[bb];B[eb] | ||
;W[fc];B[fb] | ||
;W[bd];B[da] | ||
;W[cb];B[be] | ||
;W[ac];B[ek] | ||
;W[bi];B[bh] | ||
;W[fd];B[gb] | ||
;W[id];B[jd] | ||
;W[hc];B[hb] | ||
;W[jc];B[ib] | ||
;W[md];B[je] | ||
;W[mc];B[me] | ||
;W[nd];B[lb] | ||
;W[lc];B[kc] | ||
;W[le];B[ai] | ||
;W[bo];B[lf] | ||
;W[kd];B[jb] | ||
;W[ej];B[fj] | ||
;W[fi];B[bj] | ||
;W[eh];B[ak] | ||
;W[gj];B[fk] | ||
;W[ef];B[fe] | ||
;W[gk];B[ck] | ||
;W[ei];B[fm] | ||
;W[hh];B[ji] | ||
;W[bp];B[ij] | ||
;W[ff];B[ge] | ||
;W[hl];B[jl] | ||
;W[im];B[jo] | ||
;W[jm];B[km] | ||
;W[kn];B[jn] | ||
;W[kl];B[lm] | ||
;W[jk];B[ll] | ||
;W[kk];B[ik] | ||
;W[il];B[lk] | ||
;W[kj];B[mi] | ||
;W[kh];B[jh] | ||
;W[lj];B[mj] | ||
;W[lh];B[ke] | ||
;W[mg];B[lo] | ||
;W[qm];B[ne] | ||
;W[oe];B[ld] | ||
;W[fp];B[hn] | ||
;W[fo];B[gn] | ||
;W[og];B[mb] | ||
;W[od];B[qq] | ||
;W[qp];B[pq] | ||
;W[oq];B[or] | ||
;W[nr];B[rp] | ||
;W[ro];B[op] | ||
;W[nq];B[rr] | ||
;W[sp];B[sq] | ||
;W[rq];B[gl] | ||
;W[hk];B[rp] | ||
;W[pr];B[qr] | ||
;W[rq];B[nh] | ||
;W[ng];B[rp] | ||
;W[mn];B[ln] | ||
;W[rq];B[gi] | ||
;W[hi];B[rp] | ||
;W[ce];B[so] | ||
;W[ee];B[oo] | ||
;W[pj];B[lr] | ||
;W[pn];B[rn] | ||
;W[on];B[mo] | ||
;W[nk];B[mk] | ||
;W[jr];B[qk] | ||
;W[pk];B[qj] | ||
;W[qi];B[rl] | ||
;W[ri];B[kr] | ||
;W[kq];B[lq] | ||
;W[kp];B[lp] | ||
;W[rm];B[sm] | ||
;W[ql];B[po] | ||
;W[rk];B[qb] | ||
;W[rb];B[ra] | ||
;W[rc];B[oc] | ||
;W[hq];B[gc] | ||
;W[de];B[hf] | ||
;W[gh];B[bf] | ||
;W[ig];B[jg] | ||
;W[if];B[ie] | ||
;W[ep];B[do] | ||
;W[fn];B[ip] | ||
;W[jq];B[ko] | ||
;W[no]) |
Oops, something went wrong.