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


Python Emulator.suppress_prints方法代码示例

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


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

示例1: evaluate

# 需要导入模块: from emulator import Emulator [as 别名]
# 或者: from emulator.Emulator import suppress_prints [as 别名]
def evaluate():
    #Set this color as the default
    print white, ''

    maps_list = glob.glob('maps/*.map')
    maps_list.sort()

    maps_points = {}
    maps_points_old = {}

    if os.path.exists(cache_file):
        maps_points_old = pickle.load(open(cache_file, 'r'))

    for map_file in maps_list:
        lifterEmu = Emulator(open(map_file, 'r'), '')
        lifterEmu.suppress_prints = True
        lifterEmu.print_points = False
        l = Lifter()
        l.emu = lifterEmu
        commands = l.createCommands()
        emu = Emulator(open(map_file, 'r'), commands)
        emu.suppress_prints = True
        emu.print_points = False

        while not emu.quit:
            emu.processCommand()

        points = emu.points

        maps_points[map_file] = points

        delta_points = 0
        delta_value = ''

        #Check cache...
        old_points = maps_points_old.get(map_file)
        if old_points:
            delta_points = points - old_points
            if old_points > points:
                color = red
            elif old_points < points:
                delta_value = '+'
                color = green
            else:
                color = brown

        else:
            color = brown

        if delta_points == 0:
            delta_points = ''

        print map_file, '\t' + color + str(points) + ' ' + delta_value + str(delta_points) + white

    #Dump to the cache
    pickle.dump(maps_points, open(cache_file, 'w'))
开发者ID:chris-hudson,项目名称:ICFP,代码行数:58,代码来源:evaluate.py

示例2: createEmu

# 需要导入模块: from emulator import Emulator [as 别名]
# 或者: from emulator.Emulator import suppress_prints [as 别名]
def createEmu(map_file):
    f = open(map_file, "r")
    emu = Emulator(f, "")
    emu.suppress_prints = True
    f.close()
    return emu
开发者ID:chris-hudson,项目名称:ICFP,代码行数:8,代码来源:results.py


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