def test_run_for_score_with_prog(prog, seed): # Make player bot compiler = Compiler() prog = compiler.compile(prog) room = Room([prog], seed=seed) runner = GameRunner(Game) runner.run(room, playback=False)
def test_run_for_score(seed): # Make default player bot compiler = Compiler() bot = Game.default_prog_for_bot(GameLanguage.LITTLEPY) prog = compiler.compile(bot) room = Room([prog], seed=seed) runner = GameRunner(Game) runner.run(room, playback=False)
def test_run_for_score(seed, playback): # Make default player bot compiler = Compiler() bot = Game.default_prog_for_bot(GameLanguage.LITTLEPY) prog = compiler.compile(bot) prog.name = "Mock" # get computer players players = [] for _ in range(Game.get_number_of_players() - 1): players += [Game.default_prog_for_computer()()] room = Room([prog] + players, seed=seed) runner = GameRunner(Game) runner.run(room, playback=playback)
class LittlePythonProg(Prog): def __init__(self, prog, name="Computer"): super().__init__() self.prog = Compiler().compile(prog) self.name = name def run(self, *args, **kargs): return self.prog.run(*args, **kargs)
#!/usr/bin/python import sys from game import Tron from littlepython import Compiler from CYLGame.Database import GameDB from CYLGame.Comp import MultiplayerComp c_token = sys.argv[1] game = Tron compiler = Compiler() gamedb = GameDB(sys.argv[2]) MultiplayerComp.sim_comp(c_token, gamedb, game, compiler, debug=True)
def __load_language(cls): if cls.language == GameLanguage.LITTLEPY: from littlepython import Compiler cls.compiler = Compiler() else: raise Exception("Invalid language. Could not load hookers.")
def __init__(self, prog, name="Computer"): super().__init__() self.prog = Compiler().compile(prog) self.name = name
def compile(code, features=Features.ALL): compiler = Compiler() return compiler.compile(code, features=features)