コード例 #1
0
ファイル: rgcompare.py プロジェクト: Kylar/rgcompare
def comparison_worker(identity, input, output):
    logfile = open(os.getcwd() + "/" + "rgcompare" + "." + str(identity) + ".log", 'w') if log else open(os.devnull, 'w')
    print "Starting worker {0} (logging to {1})".format(identity, logfile.name)
    try:
        with RedirectStdStreams(stdout=logfile, stderr=logfile):
            for match_id, player_fnames, map_fname, turns in iter(input.get, 'STOP'):

                map_data = ast.literal_eval(open(map_fname).read())
                settings.init_map(map_data)
                players = [game.Player(x) for x in player_fnames]
                g = game.Game(players)

                t_start = time.clock()
                for i in range(turns):
                    print (' running turn %d ' % g._state.turn).center(70, '-')
                    g.run_turn()
                t_end = time.clock()

                output.put([g.get_scores(), t_end - t_start])
    finally:
        print "Terminating worker {0}...".format(identity)
コード例 #2
0
ファイル: rgcompare.py プロジェクト: campellcl/rgcompare
def comparison_worker(identity, input, output):
    logfile = open(
        os.getcwd() + "/" + "rgcompare" + "." + str(identity) +
        ".log", 'w') if log else open(os.devnull, 'w')
    print "Starting worker {0} (logging to {1})".format(identity, logfile.name)
    try:
        with RedirectStdStreams(stdout=logfile, stderr=logfile):
            for match_id, player_fnames, map_fname, turns in iter(
                    input.get, 'STOP'):

                map_data = ast.literal_eval(open(map_fname).read())
                settings.init_map(map_data)
                players = [game.Player(x) for x in player_fnames]
                g = game.Game(players)

                t_start = time.clock()
                for i in range(turns):
                    print(' running turn %d ' % g._state.turn).center(70, '-')
                    g.run_turn()
                t_end = time.clock()

                output.put([g.get_scores(), t_end - t_start])
    finally:
        print "Terminating worker {0}...".format(identity)
コード例 #3
0
ファイル: spawn_test.py プロジェクト: saavedra29/rgkit_py3
import ast
import pkg_resources
import unittest

from rgkit.settings import settings
from rgkit.gamestate import GameState

map_data = ast.literal_eval(
    open(pkg_resources.resource_filename('rgkit', 'maps/default.py')).read())
settings.init_map(map_data)


class TestSpawn(unittest.TestCase):
    def test_first_turn_spawning(self):
        state = GameState()

        actions = {}

        state2 = state.apply_actions(actions)

        self.assertEqual(state2.get_scores(),
                         [settings.spawn_per_player,
                          settings.spawn_per_player])

    def test_spawn_kills(self):
        state = GameState()

        state.add_robot((4, 3), 0)

        actions = {
            (4, 3): ['guard']
コード例 #4
0
ファイル: rungame.py プロジェクト: ktp-forked-repos/rgsandbox
def load_map(map_file):
    map_data = ast.literal_eval(open(MAP_FILENAME).read())
    settings.init_map(map_data)
コード例 #5
0
ファイル: rungame.py プロジェクト: RobotGame/rgsandbox
def load_map(map_file):
    map_data = ast.literal_eval(open(MAP_FILENAME).read())
    settings.init_map(map_data)
コード例 #6
0
ファイル: sandbox.py プロジェクト: RobotGame/rgserver
def load_map():
    map_filename = pkg_resources.resource_filename(
        'rgkit', 'maps/default.py')
    map_data = ast.literal_eval(open(map_filename).read())
    settings.init_map(map_data)
コード例 #7
0
def load_map():
    map_filename = pkg_resources.resource_filename('rgkit', 'maps/default.py')
    map_data = ast.literal_eval(open(map_filename).read())
    settings.init_map(map_data)