(╯°□°)╯︵ ┻━┻

This commit is contained in:
Christoffer Müller Madsen 2018-03-06 11:43:10 +01:00 committed by Alexander Munch-Hansen
parent f573eaaadd
commit 09973b6cde
2 changed files with 57 additions and 2 deletions

View File

@ -1,4 +1,3 @@
import pdb
import numpy as np
import itertools
@ -271,4 +270,6 @@ class Board:
return tuple(board)
@staticmethod
def flip(board):
return tuple((-x for x in reversed(board)))

54
test.py
View File

@ -551,6 +551,60 @@ class TestLegalMoves(unittest.TestCase):
}
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__':
unittest.main()