def test_jump_collide_reverse(self): game_state = np.empty((8, 8), dtype=object) game_state[0][1] = piece.CheckersPiece(2, 0) game_state[1][2] = piece.CheckersPiece(1, 0) game_state[2][3] = piece.CheckersPiece(2, 0) game = board.CheckersGame(game_state, 2) self.assertRaises(Exception, game.move_piece, 2, 3, 0, 1)
def test_jump_over_invalid(self): game_state = np.empty((8, 8), dtype=object) game_state[0][1] = piece.CheckersPiece(1, 0) game_state[1][2] = piece.CheckersPiece(1, 0) game_state[2][3] = piece.CheckersPiece(0, 0) game = board.CheckersGame(game_state, 1) self.assertRaises(Exception, game.move_piece, 0, 1, 2, 3)
def test_legal_board_move_reverse(self): game_state = np.empty((8, 8), dtype=object) game_state[0][1] = piece.CheckersPiece(0, 0) game_state[1][2] = piece.CheckersPiece(2, 0) game = board.CheckersGame(game_state, 2) game.move_piece(1, 2, 0, 1) self.assertEqual(game.val_at_loc(1, 2), 0) self.assertEqual(game.val_at_loc(0, 1), 2) self.assertEqual(game.player_turn(), 1)
def default_init(cls): _init_board = np.empty((8, 8), dtype=object) for i in range(8): for j in range(8): if (((i + j) % 2) == 1): if (i <= 2): _init_board[i][j] = piece.CheckersPiece(1, 0) elif (i >= 5): _init_board[i][j] = piece.CheckersPiece(2, 0) else: _init_board[i][j] = piece.CheckersPiece(0, 0) else: _init_board[i][j] = piece.CheckersPiece(0, 0) return cls(_init_board, 1)
def test_move_location_invalid(self): game_state = np.empty((8, 8), dtype=object) game_state[0][1] = piece.CheckersPiece(1, 0) game = board.CheckersGame(game_state, 1) self.assertRaises(Exception, game.move_piece, 0, 1, 1, 1)