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


Python GameState.draw方法代码示例

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


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

示例1: REPL

# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import draw [as 别名]
class REPL(object):
    def __init__(self):
        n = input("Number of vertices: ")
        p = input("Edge probability: ")
        color = raw_input("Select your color (R/B): ")
        G = nx.erdos_renyi_graph(n, p)
        self.state = GameState(G)

        if color == 'R':
            self.red = player.HumanPlayer(labels.RED)
            self.blue = player.BotPlayer(labels.BLUE)
        else:
            self.red = player.BotPlayer(labels.RED)
            self.blue = player.HumanPlayer(labels.BLUE)

        print os.linesep, 'GAME HAS BEGUN', os.linesep

        plt.ion()
        plt.axis('off')
        plt.show()

    def error(self, e):
        print e

    def run(self):
        while not self.state.is_gameover():
            plt.clf()
            self.state.draw()
            try:
                if self.state.turn is labels.RED:
                    move = self.red.get_move(self.state)
                else:
                    move = self.blue.get_move(self.state)
                if move is None:
                    print move, 'is none'
                self.state.make_move(move)
                self.state.alternate_turn()
                plt.draw()
            except GameoverException, e:
                break
        winner = self.state.winner
        print winner, "is the winner."
开发者ID:Hydrotoast,项目名称:SnortSolver,代码行数:44,代码来源:repl.py


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