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


Python File.test_file方法代码示例

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


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

示例1: interactive

# 需要导入模块: from File import File [as 别名]
# 或者: from File.File import test_file [as 别名]
def interactive(ply):
    g = Game()
    mode, end = g.game_type()
    end = int(end)

    if mode:  # mode is true means new game
        player_x = Player("x")
        player_y = Player("y")
        b = Board(player_x, player_y)
        ai = Ai(ply)
        remain = ["PlayerX King", "PlayerX Rook", "PlayerY King"]
        g.ask_piece(b, player_x, player_y, remain)
        b.display()

        File.prompt("Who am I, PlayerX or PlayerY?")
        localPlayer = input("Player [x/y]: ")
        if re.match(r"[Xx]", localPlayer):
            localPlayer = "x"
        else:
            localPlayer = "y"

            # if local player is playerX, PlayerX is our ai moves
            # PlayerY is opponents moves inputted by us
        if localPlayer == "x":
            for i in range(0, end):
                # b.ai_move(player_x)
                ai.move(b, player_x)
                b.display()
                File.debug(ai.value(b))
                File.debug(ai.number_of_states)
                ai.opponent_move(player_y, b)
                b.display()
        else:
            for i in range(0, end):
                ai.opponent_move(player_x, b)
                b.display()
                # b.ai_move(player_y)
                ai.move(b, player_y)
                b.display()
                File.debug(ai.value(b))
                File.debug(ai.number_of_states)
    else:
        player_x = Player("x")
        player_y = Player("y")
        b = Board(player_x, player_y)
        File.test_file(b, g, player_x, player_y)

        ai = Ai(ply)

        # AI random moves test:
        for i in range(0, end):
            ai.move(b, player_x)
            b.display()
            File.debug(ai.value(b))
            File.debug(ai.number_of_states)
            ai.move(b, player_y)
            b.display()
            File.debug(ai.value(b))
            File.debug(ai.number_of_states)
开发者ID:mittman,项目名称:pycheckmate,代码行数:61,代码来源:main.py


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