(╯°□°)╯︵ ┻━┻
This commit is contained in:
parent
f573eaaadd
commit
09973b6cde
5
board.py
5
board.py
|
@ -1,4 +1,3 @@
|
||||||
import pdb
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
|
@ -271,4 +270,6 @@ class Board:
|
||||||
|
|
||||||
return tuple(board)
|
return tuple(board)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def flip(board):
|
||||||
|
return tuple((-x for x in reversed(board)))
|
||||||
|
|
54
test.py
54
test.py
|
@ -551,6 +551,60 @@ class TestLegalMoves(unittest.TestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
self.assertEqual(Board.calculate_legal_states(board, -1, (4,3)), expected_board_set)
|
self.assertEqual(Board.calculate_legal_states(board, -1, (4,3)), expected_board_set)
|
||||||
|
|
||||||
|
class TestBoardFlip(unittest.TestCase):
|
||||||
|
def test_flip_board(self):
|
||||||
|
board = (0,
|
||||||
|
-14, -1, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 1,
|
||||||
|
0)
|
||||||
|
|
||||||
|
expected_board = ( 0,
|
||||||
|
-1, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 1, 14,
|
||||||
|
0 )
|
||||||
|
|
||||||
|
self.assertEqual(Board.flip(board), expected_board)
|
||||||
|
|
||||||
|
def test_flip_board_bar(self):
|
||||||
|
board = (2,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
-7)
|
||||||
|
|
||||||
|
expected_board = (7,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0,
|
||||||
|
-2)
|
||||||
|
|
||||||
|
self.assertEqual(Board.flip(board), expected_board)
|
||||||
|
|
||||||
|
def test_flip_board_extensive(self):
|
||||||
|
board = (4,
|
||||||
|
-5, -1, 0, 4, 3, 0,
|
||||||
|
0, -1, 0, -5, 0, 0,
|
||||||
|
0, 3, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, -1, 0, 1,
|
||||||
|
-2)
|
||||||
|
|
||||||
|
expected_board = (2,
|
||||||
|
-1, 0, 1, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, -3, 0,
|
||||||
|
0, 0, 5, 0, 1, 0,
|
||||||
|
0, -3, -4, 0, 1, 5,
|
||||||
|
-4)
|
||||||
|
|
||||||
|
self.assertEqual(Board.flip(board), expected_board)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user