def test_victory_via_no_moves(self): # make a board full of the same tile pieces = [[tile(0, 0) for i in range(4)] for j in range(4)] # set the Previous Tile to something incompatible board = Position(pieces, black(), tile(1, 1)) # black to move, so red wins self.assertEqual(board.check_victory(), red()) # now reverse the roles and check again board = Position(pieces, red(), tile(1, 1)) self.assertEqual(board.check_victory(), black())
def test_moves_with_previous(self): pieces = self.pieces board = Position(pieces,black(),tile(0,0)) # all the pieces close to tile(0,0) analogous = [tile(i,0) for i in range(4)] + \ [tile(0,i) for i in range(4)] moves = board.get_moves() self.assertGreater(len(moves),0) for move in moves: (i,j) = move.get_location() self.assertIn(pieces[i][j],analogous)
def test_moves_with_previous(self): pieces = self.pieces board = Position(pieces, black(), tile(0, 0)) # all the pieces close to tile(0,0) analogous = [tile(i,0) for i in range(4)] + \ [tile(0,i) for i in range(4)] moves = board.get_moves() self.assertGreater(len(moves), 0) for move in moves: (i, j) = move.get_location() self.assertIn(pieces[i][j], analogous)
def test_victory_via_no_moves(self): # make a board full of the same tile pieces = [[tile(0,0) for i in range(4)] for j in range(4)] # set the Previous Tile to something incompatible board = Position(pieces,black(), tile(1,1)) # black to move, so red wins self.assertEqual(board.check_victory(),red()) # now reverse the roles and check again board = Position(pieces,red(), tile(1,1)) self.assertEqual(board.check_victory(),black())
def setUp(self): pieces = [[tile(i,j) for i in range(4)] for j in range(4)] self.pieces = pieces
def setUp(self): pieces = [[tile(i, j) for i in range(4)] for j in range(4)] self.pieces = pieces