Skip to content

Instantly share code, notes, and snippets.

@aymen-mouelhi
Created January 4, 2018 09:43
Show Gist options
  • Save aymen-mouelhi/e53498a8f67488bfb55739764a15b040 to your computer and use it in GitHub Desktop.
Save aymen-mouelhi/e53498a8f67488bfb55739764a15b040 to your computer and use it in GitHub Desktop.
Multi Threaded Gym Environment - Extract
if __name__ == '__main__':
env = gym.make('Mario-Kart-Luigi-Raceway-Multi-v0')
obs = env.reset()
env.render()
while not end_episode:
# Action should be multi-threaded + setting agent
for i in range(num_agents):
agent = i+1
# Set current agent
CurrentAgent.set_current_agent(agent)
# CReate Thread
thread = AgentThread(target=get_action, args=(agent, obs,actors[i],))
thread.start()
# Get action
action = thread.join()
# cprint('[Gym Thread] Got action %s for agent %i' %((action,agent)),'red')
obs, reward, end_episode, info = env.step(action)
env.render()
#self.queue.put('render')
total_reward += reward
@frozenfoxx
Copy link

Hello, I was wondering if you could share where the modified multiplayer environment code used is being pulled from? I had a look in gym-mupen64plus and while I see the MarioKart environment I don't believe I'm finding the multi environment you're using.

@claudio-vellage
Copy link

I'm looking for the same thing. Also end_episode is not defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment