Пример #1
0
def by_gdl(gdl):
    try:
        gdl_str = gdl
        if not isinstance(gdl, str):
            lines = []
            for s in gdl:
                lines.append(str(s))
            gdl_str = "\n".join(lines)

        db = get_database()
        try:
            info, mapping = db.lookup(gdl_str)

        except LookupFailed as exc:
            etype, value, tb = sys.exc_info()
            traceback.print_exc()
            raise LookupFailed("Did not find game %s" % exc)

        return mapping, info

    except Exception as exc:
        # creates temporary files
        log.error("Lookup failed: %s" % exc)

        model, sm = builder.build_sm(gdl)
        info = TempGameInfo("unknown", gdl, sm, model)
        return None, info
Пример #2
0
    def lazy_load(self, the_game_store):
        if self.sm is None:
            # ok here we can cache the game XXX

            self.model, self.sm = builder.build_sm(self.gdl_str,
                                                   the_game_store=the_game_store,
                                                   add_to_game_store=True)

            log.verbose("Lazy loading done for %s" % self.game)
Пример #3
0
    def go(gdl_str):
        _, sm = builder.build_sm(gdl_str)

        sm.reset()

        sm2 = sm.dupe()
        interface.dealloc_statemachine(sm)
        sm2.reset()

        log.info("Doing depth charges on %s" % sm2)
        msecs_taken, rollouts, _ = interface.depth_charge(sm2, 2)
        rollouts_per_second = (rollouts / float(msecs_taken)) * 1000
        log.info("rollouts per second %.2f" % rollouts_per_second)

        # test from python
        depth_charges(sm2, 1)

        interface.dealloc_statemachine(sm2)
Пример #4
0
def test_create_and_play_with_goalless_sm():
    ' plays a simple game of tictactoe, ensuring correct states throughtout'
    gdl_str = helper.get_gdl_for_game("ticTacToe")
    _, sm = builder.build_sm(gdl_str, try_combined=False)
    create_and_play(sm)