def input_hand(board: Board): while True: try: hand = parse(input()) except Exception: print("invalid input!!") continue if is_valid_hand(hand, board): return hand else: print("invalid hand!!")
def test_jump(self): board = Board.init_board() board.board[4][5] = 1 actual = is_valid_hand((4, 6), board) self.assertFalse(actual)
def test_diagonal(self): board = Board.init_board() board.board[3][3] = 1 actual = is_valid_hand((5, 5), board) self.assertTrue(actual)
def test_index_array_of_bound(self): board = Board(np.ones((8, 8)), False) board.board[1][1] = 0 # errorが起きないことを確認 actual = is_valid_hand((1, 1), board) self.assertFalse(actual)
def test_invalid(self): board = Board.init_board(False) actual = is_valid_hand((4, 5), board) self.assertFalse(actual)
def test_valid(self): board = Board.init_board() actual = is_valid_hand((4, 5), board) self.assertTrue(actual)