sino30535 / pysc2_simple64_agent

A Deep Q learning agent that aims to play starcraft2 simple64 map
Apache License 2.0
5 stars 0 forks source link

How to run the code? #1

Open nanxintin opened 6 years ago

nanxintin commented 6 years ago

Hi, I followed the skib's tutorial and find your project. This is a meaningful work to extend the attack_agent with DQN. I had tried to run your agent with "python main.py" and "python -m pysc2.bin.agent --map Simple64 --agent dan_agent.DQNAgent --agent_race T", but neither worked. Can you give me some advice on how to run the code? Thanks.

sino30535 commented 6 years ago

Hi, I made some changes to the codes. Please try download it again and open a terminal, cd to the pysc2_simple64_agent directory, and run with following command: python -m agent_m --map Simple64 --agent agent.dqn_agent.DQNAgent --agent_race "T" --max_agent_steps 100000 Let me know if you run into any error, thanks.

nanxintin commented 6 years ago

Hi, I followed your command and had another error: Traceback (most recent call last): File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.5/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/shao/projects-py3/sc2-projects/pysc2_simple64_agent/agent_m.py", line 97, in app.run(main) File "/home/shao/projects-py3/lib/python3.5/site-packages/absl/app.py", line 274, in run _run_main(main, argv) File "/home/shao/projects-py3/lib/python3.5/site-packages/absl/app.py", line 238, in _run_main sys.exit(main(argv)) File "/home/shao/projects-py3/sc2-projects/pysc2_simple64_agent/agent_m.py", line 83, in main run_thread(agent_cls, FLAGS.map, FLAGS.render) File "/home/shao/projects-py3/sc2-projects/pysc2_simple64_agent/agent_m.py", line 62, in run_thread run_loop([agent], env, FLAGS.max_agent_steps) File "/home/shao/projects-py3/sc2-projects/pysc2_simple64_agent/run_loop_m.py", line 28, in run_loop for agent, timestep in zip(agents, timesteps)] File "/home/shao/projects-py3/sc2-projects/pysc2_simple64_agent/run_loop_m.py", line 28, in for agent, timestep in zip(agents, timesteps)] File "/home/shao/projects-py3/sc2-projects/pysc2_simple64_agent/agent/dqn_agent.py", line 187, in step super(DQNAgent, self).step(obs, timeframe) TypeError: step() takes 2 positional arguments but 3 were given. What should I do to fix this error?

sino30535 commented 6 years ago

Sorry I forgot that I changed the original base_agent file, please update base_agent and dqn_agent.

nanxintin commented 6 years ago

Hi, thanks for your help. I run the code and got another error: "" File "D:\pythonProjects\pysc2_simple64_agent\agent\dqn_agent.py", line 177, in class DQNAgent(base_agent.BaseAgent): NameError: name 'base_agent' is not defined "" After I changed the line 177 in dqn_agent.py to "class DQNAgent(BaseAgent):", I could successfully run the code.

Besides, I think it is still very difficult for DQN agent to learn appropriate policies in large scale StarCraft II games. More efficient state and action representation method, reward function and learning algorithm are necessary to improve the agent.

Thanks again.

sino30535 commented 6 years ago

You are right, it is hard to define proper states and reward in SC2 because there are so many feature layers and possible action combinations. You may also notice that the coordinate selection in this code is quite naive and definitely need some improvement. I am currently trying to analyze the data extracted from player replays and hope that can benefit AI in the early game.