示例#1
0
    def setUp(self):
        self.board = go.Board(19)
        s2board(
            self.board, """
   A B C D E F G H J K L M N O P Q R S T 
19 . X . . . . . . . . . . . . . . . . . 19
18 . O X . O . O . O . . . . . . . . . . 18
17 . O . X X O . O X . . . . X . . . . . 17
16 X X X X O O . O X + . . . . . X X X . 16
15 . O O O O . . O X . . . . . . O X O . 15
14 . . . X X X . . X . . . . . . O O . . 14
13 . O . X O O O O . . . . . . . . . . . 13
12 . X X X X X . . . X . . . . O O X . . 12
11 . X O O X . O O O O . . . . . X O . . 11
10 X O O X X . X X . + . . . . . X O . . 10
 9 . X O O X . X . . . . . . . X O O O . 9 
 8 . . . . O O . . X . . X . . X O O X . 8 
 7 . . X O . O . O . . . . . . O X O X . 7 
 6 . O X X X X O O O O O O O . O X X X . 6 
 5 . X . X O O X X O X . X . . O . . . . 5 
 4 . O X O O X . X O + . . . . . O O X . 4 
 3 . X O O O O O X X O O X . . . O X X . 3 
 2 . X X O X . O X . X O O . . . . O X . 2 
 1 . . . X . O X X X . X . . . . . . . . 1 
   A B C D E F G H J K L M N O P Q R S T 
White to play
"""[1:-1])
        self.eboard = go.Board(19)
        s2board(
            self.eboard, """
   A B C D E F G H J K L M N O P Q R S T 
19 O . O . O . O . O O O O X . X O O . O 19
18 . O . O . O . O O X O X X X X X O O . 18
17 O . O . O . O O O X X X X O O O O . O 17
16 . O . O . O O . O X X X . X O O . O O 16
15 O . O . O . O O O X O X X X O O O X X 15
14 . O O O . O O O . O O X X X O X O O X 14
13 O . O . O . O O O O X O O X O X O X X 13
12 O O . O . O X X O O X O O O O X X . X 12
11 X O O . O O X . X O X X O O X X X X X 11
10 X X O O X O X X X X X O O X . X . X . 10
 9 . X X O X X . X . X X O O X X . X X X 9 
 8 X X X X X . X . X X . X O X X X X X . 8 
 7 O O O X . X . X X X X X O O O X . X X 7 
 6 O O . O X X X . X . X X O O X . X X O 6 
 5 . O O O O X . X . X . X O X X X O O O 5 
 4 O O X O X . X . X + X X O O X O O O . 4 
 3 O X X X . X . X . X X X O X X X O . O 3 
 2 O O X X X X X . X . X O O O X . X O . 2 
 1 . O X . X . X X . X X O O X X X X O O 1 
   A B C D E F G H J K L M N O P Q R S T 
Black to play
"""[1:-1])
        self.eboard.captured[0] = 7
        self.eboard.captured[1] = 14
示例#2
0
def test_reverse(mdl_file):

    import copy

    # 黒白入替テスト
    policy = PolicyClient(mdl_file)

    board0 = go.Board(19)
    test_go.s2board(
        board0, """
   A B C D E F G H J K L M N O P Q R S T
19 . X . . . . . . . . . . . . . . . . . 19
18 . O X . O . O . O . . . . . . . . . . 18
17 . O . X X O . O X . . . . X . . . . . 17
16 X X X X O O . O X + . . . . . X X X . 16
15 . O O O O . . O X . . . . . . O X O . 15
14 . . . X X X . . X . . . . . . O O . . 14
13 . O . X O O O O . . . . . . . . . . . 13
12 . X X X X X . . . X . . . . O O X . . 12
11 . X O O X . O O O O . . . . . X O . . 11
10 X O O X X . X X . + . . . . . X O . . 10
 9 . X O O X . X . . . . . . . X O O O . 9
 8 . . . . O O . . X . . X . . X O O X . 8
 7 . . X O . O . O . . . . . . O X O X . 7
 6 . O X X X X O O O O O O O . O X X X . 6
 5 . X . X O O X X O X . X . . O . . . . 5
 4 . O X O O X . X O + . . . . . O O X . 4
 3 . X O O O O O X X O O X . . . O X X . 3
 2 . X X O X . O X . X O O . . . . O X . 2
 1 . . . X . O X X X . X . . . . . . . . 1
   A B C D E F G H J K L M N O P Q R S T
White to play
"""[1:-1])

    board0.koZ = 100

    board1 = copy.deepcopy(board0)
    board1.reverse()

    img0 = go.to_image(board0, go.BLACK)
    img1 = go.to_image(board1, go.WHITE)

    print(board0.to_string())
    print(board1.to_string())

    p0 = policy.calc(img0)
    p1 = policy.calc(img1)

    for i, p in enumerate(p0):
        print(p0[i], p1[i])

    return 0
示例#3
0
 def clear_board(self):
     self.board = go.Board()
示例#4
0
 def __init__(self):
     self.board = go.Board()
示例#5
0
 def set_length(self, l):
     print_error('Engine.set_length()')
     self.length = l
     self.board = go.Board(l)
     self.init_game([])
示例#6
0
 def __init__(self, l, time_limit):
     self.board = go.Board(l)
     self.policy = None
     self.org_time_limit = time_limit
示例#7
0
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

import go
import tui
import sys
import copy
import calico

if len(sys.argv) < 2:
    board = go.Board()
else:
    dim = int(sys.argv[1])
    board = go.Board(dim, dim)

tui.display(board)

g = calico.UCTMoveGenerator(board)
move = (1000, 1000)

try:
    while True:

        # user's turn
        try:
            move = tui.read_move()