当前位置: 首页>>代码示例>>Python>>正文


Python User.not_valid方法代码示例

本文整理汇总了Python中User.not_valid方法的典型用法代码示例。如果您正苦于以下问题:Python User.not_valid方法的具体用法?Python User.not_valid怎么用?Python User.not_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User的用法示例。


在下文中一共展示了User.not_valid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: makes_move

# 需要导入模块: import User [as 别名]
# 或者: from User import not_valid [as 别名]
       def makes_move(self) -> str:
              '''makes the move and also turns it'''
              x = self.everything()
              if len(x) > 0:
                     
                     if self.are_there_moves_left():
                                   
                     
                            if self.valid_position() and self.board[self.row_move][self.col_move] == NONE:
                                   
                                   User.valid()
                                   if self.whose_turn == 'W':
                                          self.board[self.row_move][self.col_move] = WHITE
                                          
                                          for rowz, colz in DIR:
                                                 turn_x = self.row_move
                                                 turn_y = self.col_move
                                   
                                                 turn_updated_x = rowz + turn_x
                                                 turn_updated_y = colz + turn_y
                            
                                                  
                                                 if self.check_location(turn_updated_x, turn_updated_y) and self.board[turn_updated_x][turn_updated_y] == BLACK:
                                                        storage = []

                                                        while True:
                                                               if not self.check_location(turn_x, turn_y):
                                                                      break

                                                               elif self.board[turn_x][turn_y] == BLACK:
                                                                      storage.append((turn_x, turn_y))
                                                                      pass
                                                               elif self.board[turn_x][turn_y] == WHITE:
                                                                      for element in storage:
                                                                             self.board[element[0]][element[1]] = WHITE
                                                                             
                                                                             
                                                               turn_x+= rowz
                                                               turn_y += colz
                                   

                                          
                                   elif self.whose_turn == 'B':
                                          self.board[self.row_move][self.col_move] = BLACK
                                                        
                                          for black_rowz, black_colz in DIR:
                                                 black_x = self.row_move
                                                 black_y = self.col_move
                                                 
                                                 new_x = black_x + black_rowz
                                                 new_y = black_y + black_colz
                                                 
                                                 if self.check_location(new_x, new_y) and self.board[new_x][new_y] == WHITE:
                                                        storage = []

                                                        while True:
                                                               
                                                               if not self.check_location(black_x,black_y):
                                                                      break
                                                                      
                                                               elif self.board[black_x][black_y] == WHITE:
                                                                      storage.append( (black_x, black_y))
                                                                      pass
                                                                      
                                                                      
                                                               elif  self.board[black_x][black_y] == BLACK:
                                                                      for item in storage:
                                                                             self.board[item[0]][item[1]] = BLACK                                                                             
                                                               black_x += black_rowz
                                                               black_y += black_colz
                                   
                                   self.opp_turn()
                                   return self.whose_turn

                                   
                            else:
                                   User.not_valid()
                                   self.same_turn()
                                   return self.whose_turn
                     else:
                            self.opp_turn()
                            return self.whose_turn
                     
                                   
              else:
                     self.opp_turn()
                     return self.whose_turn
开发者ID:mazarady,项目名称:Othello_Game,代码行数:89,代码来源:games.py


注:本文中的User.not_valid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。