Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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.")
Ejemplo n.º 7
0
 def __init__(self, prog, name="Computer"):
     super().__init__()
     self.prog = Compiler().compile(prog)
     self.name = name
Ejemplo n.º 8
0
def compile(code, features=Features.ALL):
    compiler = Compiler()
    return compiler.compile(code, features=features)