コード例 #1
0
    def test_positional_superko(self):
        move_list = [(0, 3), (0, 4), (1, 3), (1, 4), (2, 3), (2, 4), (2, 2),
                     (3, 4), (2, 1), (3, 3), (3, 1), (3, 2), (3, 0), (4, 2),
                     (1, 1), (4, 1), (8, 0), (4, 0), (8, 1), (0, 2), (8, 2),
                     (0, 1), (8, 3), (1, 0), (8, 4), (2, 0), (0, 0)]

        gs = GameState(size=9)
        for move in move_list:
            gs.do_move(move)
        self.assertTrue(gs.is_legal((1, 0)))

        gs = GameState(size=9, enforce_superko=True)
        for move in move_list:
            gs.do_move(move)
        self.assertFalse(gs.is_legal((1, 0)))
コード例 #2
0
 def test_snapback_is_not_ko(self):
     gs = GameState(size=5)
     # B o W B .
     # W W B . .
     # . . . . .
     # . . . . .
     # . . . . .
     # here, imagine black plays at 'o' capturing
     # the white stone at (2,0). White may play
     # again at (2,0) to capture the black stones
     # at (0,0), (1,0). this is 'snapback' not 'ko'
     # since it doesn't return the game to a
     # previous position
     B = [(0, 0), (2, 1), (3, 0)]
     W = [(0, 1), (1, 1), (2, 0)]
     for (b, w) in zip(B, W):
         gs.do_move(b)
         gs.do_move(w)
     # do the capture of the single white stone
     gs.do_move((1, 0))
     # there should be no ko
     self.assertIsNone(gs.ko)
     self.assertTrue(gs.is_legal((2, 0)))
     # now play the snapback
     gs.do_move((2, 0))
     # check that the numbers worked out
     self.assertEqual(gs.num_black_prisoners, 2)
     self.assertEqual(gs.num_white_prisoners, 1)
コード例 #3
0
ファイル: test_gamestate.py プロジェクト: madallion/AlphaGo
	def test_snapback_is_not_ko(self):
		gs = GameState(size=5)
		# B o W B .
		# W W B . .
		# . . . . .
		# . . . . .
		# . . . . .
		# here, imagine black plays at 'o' capturing
		# the white stone at (2,0). White may play
		# again at (2,0) to capture the black stones
		# at (0,0), (1,0). this is 'snapback' not 'ko'
		# since it doesn't return the game to a
		# previous position
		B = [(0, 0), (2, 1), (3, 0)]
		W = [(0, 1), (1, 1), (2, 0)]
		for (b, w) in zip(B, W):
			gs.do_move(b)
			gs.do_move(w)
		# do the capture of the single white stone
		gs.do_move((1, 0))
		# there should be no ko
		self.assertIsNone(gs.ko)
		self.assertTrue(gs.is_legal((2, 0)))
		# now play the snapback
		gs.do_move((2, 0))
		# check that the numbers worked out
		self.assertEqual(gs.num_black_prisoners, 2)
		self.assertEqual(gs.num_white_prisoners, 1)
コード例 #4
0
    def test_standard_ko(self):
        gs = GameState(size=9)
        gs.do_move((1, 0))  # B
        gs.do_move((2, 0))  # W
        gs.do_move((0, 1))  # B
        gs.do_move((3, 1))  # W
        gs.do_move((1, 2))  # B
        gs.do_move((2, 2))  # W
        gs.do_move((2, 1))  # B

        gs.do_move((1, 1))  # W trigger capture and ko

        self.assertEqual(gs.num_black_prisoners, 1)
        self.assertEqual(gs.num_white_prisoners, 0)

        self.assertFalse(gs.is_legal((2, 1)))

        gs.do_move((5, 5))
        gs.do_move((5, 6))

        self.assertTrue(gs.is_legal((2, 1)))
コード例 #5
0
ファイル: test_gamestate.py プロジェクト: madallion/AlphaGo
	def test_standard_ko(self):
		gs = GameState(size=9)
		gs.do_move((1, 0))  # B
		gs.do_move((2, 0))  # W
		gs.do_move((0, 1))  # B
		gs.do_move((3, 1))  # W
		gs.do_move((1, 2))  # B
		gs.do_move((2, 2))  # W
		gs.do_move((2, 1))  # B

		gs.do_move((1, 1))  # W trigger capture and ko

		self.assertEqual(gs.num_black_prisoners, 1)
		self.assertEqual(gs.num_white_prisoners, 0)

		self.assertFalse(gs.is_legal((2, 1)))

		gs.do_move((5, 5))
		gs.do_move((5, 6))

		self.assertTrue(gs.is_legal((2, 1)))