本文整理汇总了Python中gui.Gui.show_options方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.show_options方法的具体用法?Python Gui.show_options怎么用?Python Gui.show_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gui.Gui
的用法示例。
在下文中一共展示了Gui.show_options方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gui import Gui [as 别名]
# 或者: from gui.Gui import show_options [as 别名]
class Othello:
def __init__(self):
self.gui = Gui()
self.setup_game()
def read_board_file(self, file_name):
f = open(file_name)
lines = [line.strip() for line in f]
f.close()
board = np.zeros((8, 8), dtype=np.integer)
# Read In Board File
i = 0
for line in lines[:8]:
j = 0
for char in line.split():
board[i][j] = int(char)
j += 1
i += 1
# Set Current Turn
if int(lines[8]) == WHITE:
self.now_playing, self.other_player = self.other_player, self.now_playing
return board
def setup_game(self):
options = self.gui.show_options()
if options['player_1'] == COMPUTER:
self.now_playing = player.ComputerPlayer(BLACK, int(options['player_1_time']), self.gui)
else:
self.now_playing = player.HumanPlayer(BLACK, gui=self.gui)
if options['player_2'] == COMPUTER:
self.other_player = player.ComputerPlayer(WHITE, int(options['player_2_time']), self.gui)
else:
self.other_player = player.HumanPlayer(WHITE, gui=self.gui)
if options.has_key('load_file'):
self.board = board.Board(self.read_board_file(options['load_file']))
else:
self.board = board.Board()
def run(self):
self.gui.show_game(self.board)
while True:
winner = self.board.game_won()
if winner is not None:
break
self.now_playing.set_current_board(self.board)
if self.board.get_valid_moves(self.now_playing.color) != []:
self.board = self.now_playing.get_move()
self.gui.update(self.board, self.other_player)
self.now_playing, self.other_player = self.other_player, self.now_playing
self.gui.show_winner(winner, self.board)
self.restart()
def restart(self):
self.setup_game()
self.run()