MultiAgentLearning / playground

PlayGround: AI Research into Multi-Agent Learning.
https://www.pommerman.com
Apache License 2.0
765 stars 217 forks source link

Fixed train_with_tensorforce.py errors #190

Closed nihal111 closed 5 years ago

nihal111 commented 5 years ago

When running the train_with_tensorforce.py script as-

python3 train_with_tensorforce.py --agents=tensorforce::ppo,test::agents.SimpleAgent,test::agents.SimpleAgent,test::agents.SimpleAgent  --config=PommeFFACompetition-v0 --render

I face two issues-

Relative Imports The relative imports produce an error on my machine:

Traceback (most recent call last):
  File "train_with_tensorforce.py", line 22, in <module>
    from .. import helpers, make
ValueError: attempted relative import beyond top-level package

This is the same error as described here- #83

Adding absolute imports as described here fixes it.

Actions not being unflattened After fixing the imports, I still received an error-

Traceback (most recent call last):
  File "train_with_tensorforce.py", line 153, in <module>
    main()
  File "train_with_tensorforce.py", line 142, in main
    runner.run(episodes=10, max_episode_timesteps=2000)
  File "/home/nihal111/.local/lib/python3.6/site-packages/tensorforce/execution/runner.py", line 104, in run
    state, terminal, step_reward = self.environment.execute(action=action)
TypeError: execute() got an unexpected keyword argument 'action'

Looking at the notebook that appears to do the same thing, I understand that the execute method inside the WrappedEnv class is defined in a different way. The following line was missing in train_with_tensorforce.py-

actions = self.unflatten_action(action=action)

This PR fixes both of these issues on my machine. Hope this helps.

cinjon commented 5 years ago

Thanks for looking into this @nihal111 ! This looks ~lgtm to me. We unfortunately have not kept up to date with Tensorforce modifications and so we depend on these fixes from our contributors.