Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
#!/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)
Esempio n. 6
0
 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.")
Esempio n. 7
0
 def __init__(self, prog, name="Computer"):
     super().__init__()
     self.prog = Compiler().compile(prog)
     self.name = name
Esempio n. 8
0
def compile(code, features=Features.ALL):
    compiler = Compiler()
    return compiler.compile(code, features=features)