本文整理汇总了Python中View.View.inputStartPlayer方法的典型用法代码示例。如果您正苦于以下问题:Python View.inputStartPlayer方法的具体用法?Python View.inputStartPlayer怎么用?Python View.inputStartPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类View.View
的用法示例。
在下文中一共展示了View.inputStartPlayer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from View import View [as 别名]
# 或者: from View.View import inputStartPlayer [as 别名]
class Game:
def __init__(self):
self.board = Board()
self.evaluation = Evaluation(self.board)
self.view = View(self.board)
def __finish(self, computerPlayer):
if self.evaluation.winner() == computerPlayer:
print "Computer player wins"
elif self.evaluation.isTie():
print "Tie game"
else:
print "Human player wins"
def run(self):
startPlayer = self.view.inputStartPlayer()
computerPlayer = 'X' if startPlayer == 2 else 'O'
ai = AI(computerPlayer, self.board)
while self.evaluation.winner() == None and not self.evaluation.isTie():
self.view.displayBoard()
if self.board.getPlayer() == computerPlayer:
ai.makeMove()
else:
move = self.view.inputMove()
self.board.move(move)
self.view.displayBoard()
self.__finish(computerPlayer)