{"id":13686290,"url":"https://github.com/islamelnabarawy/sc2gym","last_synced_at":"2025-05-01T09:30:57.416Z","repository":{"id":217604947,"uuid":"104585675","full_name":"islamelnabarawy/sc2gym","owner":"islamelnabarawy","description":"PySC2 OpenAI Gym Environments","archived":false,"fork":false,"pushed_at":"2019-01-23T18:08:03.000Z","size":71,"stargazers_count":48,"open_issues_count":1,"forks_count":14,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-12T09:48:21.727Z","etag":null,"topics":["openai-gym","pysc2","sc2","starcraft-ii","starcraft2"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/islamelnabarawy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-23T17:24:25.000Z","updated_at":"2024-06-04T12:56:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"402c4786-202f-4678-8f97-e591a336f86a","html_url":"https://github.com/islamelnabarawy/sc2gym","commit_stats":null,"previous_names":["islamelnabarawy/sc2gym"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamelnabarawy%2Fsc2gym","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamelnabarawy%2Fsc2gym/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamelnabarawy%2Fsc2gym/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamelnabarawy%2Fsc2gym/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/islamelnabarawy","download_url":"https://codeload.github.com/islamelnabarawy/sc2gym/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251852647,"owners_count":21654440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["openai-gym","pysc2","sc2","starcraft-ii","starcraft2"],"created_at":"2024-08-02T15:00:27.749Z","updated_at":"2025-05-01T09:30:57.410Z","avatar_url":"https://github.com/islamelnabarawy.png","language":"Python","funding_links":[],"categories":["Software Packages"],"sub_categories":[],"readme":"# PySC2 OpenAI Gym Environments\n\nOpenAI Gym Environments for the StarCraft II PySC2 environment.\n\n## Installation:\n\nAfter cloning the repository, you can use the environments in\none of two ways:\n\n1. Add the directory where you cloned the repo to your `PYTHON_PATH`\n2. Install the package in development mode using pip: `pip install -e .`\n\nIf you use the first option, you need to manually make sure the\ndependencies are installed.\n\nThe second option will install the package into your `pip` environment\nas a link to the directory, so it will reflect the changes when\nyou `git pull` or make any changes to the code.\n\n## Usage:\n\nYou need the following minimum code to run any environment:\n\nImport gym and this package:\n\n    import gym\n    import sc2gym.envs\n\nImport and initialize absl.flags: (this is due to `pysc2` dependency)\n\n    import sys\n    from absl import flags\n    FLAGS = flags.FLAGS\n    FLAGS(sys.argv)\n\nCreate and initialize the specific environment as indicated in the\nnext section.\n\n## Available environemnts:\n\n### SC2Game:\n\nThe full StarCraft II game environment. Initialize as follows:\n\n    env = gym.make('SC2Game-v0')\n    env.settings['map_name'] = '\u003cdesired map name\u003e'\n\nVersions:\n- `SC2Game-v0`: The full game with complete access to action and\nobservation space.\n\n#### Notes:\n- The action space for this environment doesn't require the call to\n`functionCall` like `pysc2` does. You just need to call it with an\narray of action and arguments. For example:\n\n        _SELECT_ARMY = actions.FUNCTIONS.select_army.id\n        _SELECT_ALL = [0]\n        env.step([_SELECT_ARMY, _SELECT_ALL])\n\n    It will check the first element in the array (the action) and make\n    sure it's available before trying to pass it along to the\n    `pysc2` environment.\n- This environment doesn't specify the `observation_space` and\n`action_space` members like traditional `gym` environments. Instead,\nit provides access to the `observation_spec` and `action_spec` objects\nfrom the `pysc2` environment.\n\n### MoveToBeacon:\n\nThe MoveToBeacon mini game. Initialize as follows:\n\n    env = gym.make('SC2MoveToBeacon-v0')\n\nVersions:\n- 'SC2MoveToBeacon-v0': The observation is a `[1, 64, 64]` numpy\narray that represents the `obs.observation['screen'][_PLAYER_RELATIVE]`\nplane from the `pysc2` observation. The action is a number\nbetween 0 and 4095 (64x64-1), which is a 1-d representation of the\nscreen coordinates to move the marine towards. The environment\npre-selects the marine at the start of each episode.\n- 'SC2MoveToBeacon-v1': The observation is a `[1, 64, 64]` numpy\narray that represents the `obs.observation['screen'][_PLAYER_RELATIVE]`\nplane from the `pysc2` observation. The action is an array of\ntwo numbers, each between 0 and 63, representing the screen coordinates\nto move the marine towards. The environment pre-selects the marine at\nthe start of each episode.\n\n### CollectMineralShards:\n\nThe CollectMineralShards mini game. Initialize as follows:\n\n    env = gym.make('SC2CollectMineralShards-v0')\n\nVersions:\n- 'SC2CollectMineralShards-v0': The observation is a `[1, 64, 64]` numpy\narray that represents the `obs.observation['screen'][_PLAYER_RELATIVE]`\nplane from the `pysc2` observation. The action is a number\nbetween 0 and 4095 (64x64-1), which is a 1-d representation of the\nscreen coordinates to move the marines towards. The environment\npre-selects both marines at the start of each episode.\n- 'SC2CollectMineralShards-v1': The observation is a `[1, 64, 64]` numpy\narray that represents the `obs.observation['screen'][_PLAYER_RELATIVE]`\nplane from the `pysc2` observation. The action is an array of\ntwo numbers, each between 0 and 63, representing the screen coordinates\nto move the marines towards. The environment pre-selects the marine at\nthe start of each episode.\n- 'SC2CollectMineralShards-v2': The observation is a `[2, 64, 64]` numpy\narray that represents the `obs.observation['screen'][_PLAYER_RELATIVE]`\nand the `obs.observation['screen'][_SELECTED]` planes from the `pysc2`\nobservation. The action is an array of three numbers. The first number\nis between 0 and 2, representing which control group to move.\nThe remaining two numbers are integers between 0 and 63, representing the screen coordinates\nto move the marines in this control group towards.\nThe environment automatically creates the following control groups at\nthe start of each episode.\n__Each episode starts with control group 3 pre-selected.__\n    * Group 1 [index 0]: Both marines\n    * Group 2 [index 1]: Marine 1\n    * Group 3 [index 2]: Marine 2\n\n\n### General Notes:\n* Per the Gym environment specifications, the reset function returns an\nobservation, and the step function returns a tuple\n(observation, reward, done, info), where info is an empty dictionary and\nthe observation is the observation object from the pysc2 environment.\nThe reward is the same as observation.reward, and done is equal true if\nobservation.step_type is LAST.\n* In addition to `step()` and `reset()`, the environments define a\n`save_replay()` method, that takes a single parameter, `replay_dir`,\nwhich is the name of the replay directory to save to inside the\n`StarCraft II/Replays/` folder.\n* All the environments have `action_spec` and `observation_spec` properties,\nin addition to the `action_space` and `observation_space` properties defined\nfor the mini game environments.\n* All the environments have the following additional properties:\n    - `episode`: The current episode number\n    - `num_step`: The total number of steps taken\n    - `episode_reward`: The total reward received this episode\n    - `total_reward`: The total reward received for all episodes\n* The examples folder contains examples of using the various environments.\n\n---\n    \n    Copyright 2017 Islam Elnabarawy\n    \n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n    \n    http://www.apache.org/licenses/LICENSE-2.0\n    \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fislamelnabarawy%2Fsc2gym","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fislamelnabarawy%2Fsc2gym","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fislamelnabarawy%2Fsc2gym/lists"}