def selectInitialX(self, board): game_rules.printBoard(board) pt = (0, 0, 0) # obviously not a valid location on a 2-D board validMoves = game_rules.getFirstMovesForX(board) while pt not in validMoves: pt = self._promptForPoint("Enter a valid starting location for player X (in the format 'row column'): ") return pt
def _handleInitialX(self, playerBoard, board): pt = self.p1.selectInitialX(playerBoard) if pt in game_rules.getFirstMovesForX(board): self.board[pt[0]][pt[1]] = " " self.state = AWAITING_INITIAL_O else: self.state = O_VICTORY
def _handleInitialX(self, playerBoard, board, move_pair): #move = move_pair[0] if isinstance(self.p1, HumanPlayer) else self.p1.selectInitialX(playerBoard) print('initial X, move_pair', move_pair) move = move_pair[ 0] if move_pair is not None else self.p1.selectInitialX( playerBoard) print('move', move) if move in game_rules.getFirstMovesForX(board): self.log.write(str(move) + '\n') self.board[move[0]][move[1]] = " " self.state = AWAITING_INITIAL_O
def selectInitialX(self, board): validMoves = game_rules.getFirstMovesForX(board) return random.choice(list(validMoves))
def _handleInitialX(self, playerBoard, board, move_pair): move = move_pair[0] if isinstance( self.p1, HumanPlayer) else self.p1.selectInitialX(playerBoard) if move in game_rules.getFirstMovesForX(board): self.board[move[0]][move[1]] = " " self.state = AWAITING_INITIAL_O