コード例 #1
0
ファイル: ats.py プロジェクト: suryansh2020/arimaa
 def __init__(self, test_files, engine_cmd, time_settings):
     self.engine = EngineController(StdioEngine(engine_cmd, log))
     self.time_settings = time_settings
     self.tests = [
         Test(test_file, self.time_settings.time_per_test)
         for test_file in test_files
     ]
コード例 #2
0
ファイル: ats.py プロジェクト: suryansh2020/arimaa
class Suite:
    """
        Some collection of tests.
    """
    def __init__(self, test_files, engine_cmd, time_settings):
        self.engine = EngineController(StdioEngine(engine_cmd, log))
        self.time_settings = time_settings
        self.tests = [
            Test(test_file, self.time_settings.time_per_test)
            for test_file in test_files
        ]

    def run(self):
        print("Running the test suite...")
        passed = {}
        i = 0
        for test in self.tests:
            for c in xrange(self.time_settings.cycles):
                i += 1
                log.debug("trial %d", i)
                res = test.do_test(self.engine)
                passed[test] = passed.get(test, 0) + res
                log.debug("%s %3.2f%%.", test, res * 100)

        passed_num = sum(passed.values())
        for test in self.tests:
            print("%s scored %0.2f of %d" %
                  (test, passed.get(test, 0), self.time_settings.cycles))
        print("scored %0.2f of %d" %
              (passed_num, self.time_settings.cycles * len(self.tests)))

    def __del__(self):
        self.engine.quit()
        self.engine.cleanup()
コード例 #3
0
ファイル: ats.py プロジェクト: bakshinder/akimot
class Suite:
    """
        Some collection of tests.
    """
    def __init__(self, test_files, engine_cmd, time_settings):
        self.engine = EngineController(StdioEngine(engine_cmd, log))
        self.time_settings = time_settings
        self.tests = [ Test(test_file, self.time_settings.time_per_test) for test_file in test_files]

    def run(self):
        print("Running the test suite...") 
        passed = {}
        i = 0
        for test in self.tests:
            for c in xrange(self.time_settings.cycles):
                i += 1 
                log.debug("trial %d", i) 
                res = test.do_test(self.engine)
                passed[test] = passed.get(test, 0) + res 
                log.debug("%s %3.2f%%.", test, res * 100) 
                
        passed_num = sum(passed.values())
        for test in self.tests:
            print ("%s scored %0.2f of %d" % (test, passed.get(test,0), self.time_settings.cycles))
        print("scored %0.2f of %d" % (passed_num, self.time_settings.cycles * len(self.tests)))
    
    def __del__(self):
        self.engine.quit()
        self.engine.cleanup()
コード例 #4
0
ファイル: main.py プロジェクト: suryansh2020/arimaa
 def add_engine(self, name, cmd):
     self.engines[name] = EngineController(StdioEngine(cmd, None))
コード例 #5
0
ファイル: rabbits.py プロジェクト: serialhex/arimaa
        if not goal_pos.is_goal():
            wrong["goal"] = True

    if len(wrong) > 0:
        print "========================="
        print pos.to_long_str()
        print result

        if wrong.has_key("goal"):
            print "Wrong goal move generated"
            print extra
        if wrong.has_key("result"):
            print "should be", move


if __name__ == "__main__":
    try:
        rabbits_pos_fn = sys.argv[1]
    except IndexError:
        print "Usage: %s rabbits_pos_file" % sys.argv[0]
        sys.exit(1)

    engine_cmd = "./akimot -c default.cfg -l"
    engine = EngineController(StdioEngine(engine_cmd, log))

    for pos, move in map(lambda x: x.split("#"), (open(rabbits_pos_fn, "r").readlines())):
        do_test(engine, pos.strip(), move.strip())

    engine.quit()
    engine.cleanup()
コード例 #6
0
ファイル: ats.py プロジェクト: bakshinder/akimot
 def __init__(self, test_files, engine_cmd, time_settings):
     self.engine = EngineController(StdioEngine(engine_cmd, log))
     self.time_settings = time_settings
     self.tests = [ Test(test_file, self.time_settings.time_per_test) for test_file in test_files]
コード例 #7
0
ファイル: rabbits.py プロジェクト: suryansh2020/arimaa
            wrong['goal'] = True

    if (len(wrong) > 0):
        print "========================="
        print pos.to_long_str()
        print result

        if wrong.has_key('goal'):
            print "Wrong goal move generated"
            print extra
        if wrong.has_key('result'):
            print "should be", move


if __name__ == '__main__':
    try:
        rabbits_pos_fn = sys.argv[1]
    except IndexError:
        print "Usage: %s rabbits_pos_file" % sys.argv[0]
        sys.exit(1)

    engine_cmd = './akimot -c default.cfg -l'
    engine = EngineController(StdioEngine(engine_cmd, log))

    for pos, move in map(lambda x: x.split('#'),
                         (open(rabbits_pos_fn, 'r').readlines())):
        do_test(engine, pos.strip(), move.strip())

    engine.quit()
    engine.cleanup()