oxwhirl / smac

SMAC: The StarCraft Multi-Agent Challenge
MIT License
1.04k stars 227 forks source link

Render Method & PettingZoo API #71

Closed rodrigodelazcano closed 3 years ago

rodrigodelazcano commented 3 years ago

The purpose of this PR is to add the following capabilities to the smac repository:

First of all, the render method shows the actions of the agents in each step in a simplified 2D pygame window. The render shows the map height, unit team, type, and health. As well as, the number of steps and score for each episode in the upper right of the window. This method is useful for visualization purposes and debugging.

Second, PettingZoo is a universal Python API with a variety of multi-agent environments. PettingZoo was developed with the goal of accelerating research in Multi-Agent Reinforcement Learning ("MARL"), by making work more interchangeable, accessible and reproducible akin to what OpenAI's Gym library did for single-agent reinforcement learning. PettingZoo's API, while inheriting many features of Gym, is unique amongst MARL APIs in that it's based around the novel Agent Environment Cycle ("AEC") games model. In this PR it is included a wrapper that creates a PettingZoo environment from the StarCraft2Env smac base environment. This feature will allow the increasing number of user of PettingZoo API to benefit from the smac environment and vice versa.

The render method has been tested with the smac environment in the file random_agents.py. While an example of a PettingZoo environment played as an AEC game can be tested with the file random_demo.py. The arguments for initializing the sc2 PettingZoo environment are the same as for the smac environment except for an additional one , max_cycles, which specifies the number of frames (a step for each agent) until game terminates.

A final example of the render method visualization using the PettingZoo environment wrapper in the "2c_vs_64zg" map is shown bellow.

I hope you find these new features interesting and thank you for your time,

Rodrigo

render_smac

KaleabTessera commented 3 years ago

This is a really great feature! Looking forward to having this merged in :)

rodrigodelazcano commented 3 years ago

This is a really great feature! Looking forward to having this merged in :)

Thank you Kaleab! I am glad you liked it!!

rodrigodelazcano commented 3 years ago

Hi Mikayel! Thank you so much for taking your time to review the code. I think now it should be all set. Please let me know if you need anything else. Thanks again!

samvelyan commented 3 years ago

Hey @rodrigodelazcano . I've merged this branch through another PR https://github.com/oxwhirl/smac/pull/77 (with some minor changes).

Thank you again for this amazing contribution! 🙌

rodrigodelazcano commented 3 years ago

Thank you for the merge @samvelyan!!! I just have a small doubt. Is it possible to appear as a contributor to the repo?

samvelyan commented 3 years ago

Oh, apparently you weren't added automatically because I squash-merged. I can add in the Readme file that you added the PettingZoo API and rendering, if you want.

rodrigodelazcano commented 3 years ago

No problem at all. My fault for working on the master branch. Yes that would be great if possible, I can answer any questions related to those topics. You can add my github account as a link.

Thanks

El lun, 19 jul 2021 a las 8:44, Mika @.***>) escribió:

Oh, apparently you weren't added automatically because I squash-merged. I can add in the Readme file that you added the PettingZoo API and rendering, if you want.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/oxwhirl/smac/pull/71#issuecomment-882517055, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOOTFAUDTSQIGOAGSIWIXODTYQM3VANCNFSM45UWIYQA .

samvelyan commented 3 years ago

I was able to override the author of 9b73622 commit. Now you're a contributor!

rodrigodelazcano commented 3 years ago

Thank you so much Mikayel! :)

El lun, 19 jul 2021 a las 9:02, Mika @.***>) escribió:

I was able to override the author of 9b73622 https://github.com/oxwhirl/smac/commit/9b7362222bbec162f44d61aea7d96dcf20140f1f commit. Now you're a contributor!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/oxwhirl/smac/pull/71#issuecomment-882527942, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOOTFAURAJUNGYCPHLXY5XDTYQO7ZANCNFSM45UWIYQA .

samvelyan commented 3 years ago

Of course! Also added info in the README.