def test_Board_extractRowCol_001(self): (row, col) = Board.extractRowCol("A1") self.assertEqual(0, row) self.assertEqual(0, col) (row, col) = Board.extractRowCol("B3") self.assertEqual(1, row) self.assertEqual(2, col) (row, col) = Board.extractRowCol("Z99") self.assertEqual(25, row) self.assertEqual(98, col) try: (row, col) = Board.extractRowCol("") self.fail() except FormatException: pass
def main(): index: int = 0 board: Board = Board(9, 9) while True: sys.stdout.flush() sys.stdout.write(str(board)) sys.stdout.write("Input A1 - I9 or ! \r\n") input: str = sys.stdin.readline() if (0 <= input.find("!")): break else: extracted = Board.extractRowCol(input) row: int = extracted[0] col: int = extracted[1] if (0 <= row and row <= 9) and (0 <= col and col <= 9): board.setState( row, col, BoardState.BLACK if index % 2 == 0 else BoardState.WHITE) index += 1 pass