예제 #1
0
class RandomAgent(object):
    def __init__(self, action_space):
        self.action_space = action_space

    def act(self):
        return self.action_space.sample()


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--ip', help='server ip', default='192.168.11.1')
    parser.add_argument('--port', help='server port', default='11111"')
    parser.add_argument('--speed', help='game speed', default=0)
    args = parser.parse_args()

    env = sc.SingleBattleEnv(args.ip, args.port, args.speed)
    env.seed(123)
    agent = RandomAgent(env.action_space)

    episodes = 0
    while episodes < 50:
        obs = env.reset()
        done = False
        while not done:
            action = agent.act()
            obs, reward, done, info = env.step(action)
        episodes += 1

    env.close()
예제 #2
0

class RandomAgent(object):
    def __init__(self, action_space):
        self.action_space = action_space

    def act(self):
        return self.action_space.sample()


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--ip', help='server ip')
    parser.add_argument('--port', help='server port', type=int, default=11111)
    args = parser.parse_args()

    env = sc.SingleBattleEnv(args.ip, args.port, frame_skip=2)
    env.seed(123)
    agent = RandomAgent(env.action_space)

    episodes = 0
    while episodes < 50:
        obs = env.reset()
        done = False
        while not done:
            action = agent.act()
            obs, reward, done, info = env.step(action)
        episodes += 1

    env.close()
예제 #3
0

class HumanAgent(object):
    def __init__(self, action_space):
        self.action_space = action_space

    def act(self):
        return None


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--ip', help='server ip')
    parser.add_argument('--port', help='server port', default="11111")
    args = parser.parse_args()

    env = sc.SingleBattleEnv(args.ip, args.port, speed=60)
    env.seed(123)
    agent = HumanAgent(env.action_space)

    episodes = 0
    while True:
        obs = env.reset()
        done = False
        while not done:
            action = agent.act()
            obs, reward, done, info = env.step(action)
        episodes += 1

    env.close()
예제 #4
0

class RandomAgent(object):
    def __init__(self, action_space):
        self.action_space = action_space

    def act(self):
        return self.action_space.sample()


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--ip', help='server ip')
    parser.add_argument('--port', help='server port', default="11111")
    args = parser.parse_args()

    env = sc.SingleBattleEnv(args.ip, args.port)
    env.seed(123)
    agent = RandomAgent(env.action_space)

    episodes = 0
    while episodes < 50:
        obs = env.reset()
        done = False
        while not done:
            action = agent.act()
            obs, reward, done, info = env.step(action)
        episodes += 1

    env.close()