예제 #1
0
파일: player.py 프로젝트: dunmatt/konane
 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
예제 #2
0
 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
예제 #3
0
 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
예제 #4
0
 def selectInitialX(self, board):
     validMoves = game_rules.getFirstMovesForX(board)
     return random.choice(list(validMoves))
예제 #5
0
 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
예제 #6
0
파일: player.py 프로젝트: dunmatt/konane
 def selectInitialX(self, board):
   validMoves = game_rules.getFirstMovesForX(board)
   return random.choice(list(validMoves))