unismac 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. unismac-0.1.0/.gitignore +22 -0
  2. unismac-0.1.0/CITATION.cff +20 -0
  3. unismac-0.1.0/LICENSE +21 -0
  4. unismac-0.1.0/NOTICE +140 -0
  5. unismac-0.1.0/PKG-INFO +198 -0
  6. unismac-0.1.0/README.md +162 -0
  7. unismac-0.1.0/README_zh.md +162 -0
  8. unismac-0.1.0/docs/architecture.md +155 -0
  9. unismac-0.1.0/docs/benchmarks.md +159 -0
  10. unismac-0.1.0/docs/interface.md +235 -0
  11. unismac-0.1.0/docs/profiles-and-config.md +174 -0
  12. unismac-0.1.0/examples/quickstart_vec.py +132 -0
  13. unismac-0.1.0/examples/sc2_eval.py +146 -0
  14. unismac-0.1.0/examples/self_play.py +155 -0
  15. unismac-0.1.0/pyproject.toml +122 -0
  16. unismac-0.1.0/tests/test_assets.py +165 -0
  17. unismac-0.1.0/tests/test_boundary.py +79 -0
  18. unismac-0.1.0/tests/test_contract.py +123 -0
  19. unismac-0.1.0/tests/test_env.py +249 -0
  20. unismac-0.1.0/tests/test_env_accel.py +1552 -0
  21. unismac-0.1.0/tests/test_env_dual.py +478 -0
  22. unismac-0.1.0/tests/test_env_generators.py +128 -0
  23. unismac-0.1.0/tests/test_env_invariance.py +125 -0
  24. unismac-0.1.0/tests/test_env_mirror.py +357 -0
  25. unismac-0.1.0/tests/test_env_opponents.py +189 -0
  26. unismac-0.1.0/tests/test_env_rng.py +155 -0
  27. unismac-0.1.0/tests/test_env_sc2.py +137 -0
  28. unismac-0.1.0/tests/test_env_scripted_rust.py +749 -0
  29. unismac-0.1.0/tests/test_env_seeds.py +309 -0
  30. unismac-0.1.0/tests/test_env_smac_hard.py +157 -0
  31. unismac-0.1.0/tests/test_env_smacv2.py +284 -0
  32. unismac-0.1.0/tests/test_presets.py +242 -0
  33. unismac-0.1.0/tests/test_public_api.py +371 -0
  34. unismac-0.1.0/tests/test_pyref.py +481 -0
  35. unismac-0.1.0/tests/test_pyref_acquire_center.py +137 -0
  36. unismac-0.1.0/tests/test_pyref_align_diag.py +140 -0
  37. unismac-0.1.0/tests/test_pyref_assist_pick.py +149 -0
  38. unismac-0.1.0/tests/test_pyref_assist_tie.py +200 -0
  39. unismac-0.1.0/tests/test_pyref_attack_commit.py +258 -0
  40. unismac-0.1.0/tests/test_pyref_avoid_closing.py +132 -0
  41. unismac-0.1.0/tests/test_pyref_avoid_cross.py +132 -0
  42. unismac-0.1.0/tests/test_pyref_avoid_parallel.py +157 -0
  43. unismac-0.1.0/tests/test_pyref_avoid_share.py +310 -0
  44. unismac-0.1.0/tests/test_pyref_batch.py +290 -0
  45. unismac-0.1.0/tests/test_pyref_collision_gaps.py +290 -0
  46. unismac-0.1.0/tests/test_pyref_crowd_cover.py +224 -0
  47. unismac-0.1.0/tests/test_pyref_dead_target_move.py +132 -0
  48. unismac-0.1.0/tests/test_pyref_defer_memory.py +95 -0
  49. unismac-0.1.0/tests/test_pyref_follow_lock.py +498 -0
  50. unismac-0.1.0/tests/test_pyref_heal.py +454 -0
  51. unismac-0.1.0/tests/test_pyref_hit_assist.py +155 -0
  52. unismac-0.1.0/tests/test_pyref_kill_hold.py +30 -0
  53. unismac-0.1.0/tests/test_pyref_kill_no_retreat.py +181 -0
  54. unismac-0.1.0/tests/test_pyref_kill_rescan.py +283 -0
  55. unismac-0.1.0/tests/test_pyref_kill_rescan_order.py +219 -0
  56. unismac-0.1.0/tests/test_pyref_mmm_orders.py +247 -0
  57. unismac-0.1.0/tests/test_pyref_mover_push_approach.py +335 -0
  58. unismac-0.1.0/tests/test_pyref_mover_push_axis.py +286 -0
  59. unismac-0.1.0/tests/test_pyref_mover_push_lone_half.py +362 -0
  60. unismac-0.1.0/tests/test_pyref_mover_push_same_half.py +285 -0
  61. unismac-0.1.0/tests/test_pyref_mover_speed_cap.py +79 -0
  62. unismac-0.1.0/tests/test_pyref_new_target.py +242 -0
  63. unismac-0.1.0/tests/test_pyref_p2.py +230 -0
  64. unismac-0.1.0/tests/test_pyref_p5.py +321 -0
  65. unismac-0.1.0/tests/test_pyref_p6.py +280 -0
  66. unismac-0.1.0/tests/test_pyref_p7.py +160 -0
  67. unismac-0.1.0/tests/test_pyref_passive.py +84 -0
  68. unismac-0.1.0/tests/test_pyref_pin_after_fire.py +129 -0
  69. unismac-0.1.0/tests/test_pyref_pin_lag.py +120 -0
  70. unismac-0.1.0/tests/test_pyref_pin_sidestep.py +285 -0
  71. unismac-0.1.0/tests/test_pyref_pin_sidestep_lat.py +153 -0
  72. unismac-0.1.0/tests/test_pyref_pin_sidestep_lat_scope.py +143 -0
  73. unismac-0.1.0/tests/test_pyref_pin_sidestep_tangent.py +177 -0
  74. unismac-0.1.0/tests/test_pyref_pin_tie_grid.py +199 -0
  75. unismac-0.1.0/tests/test_pyref_retarget_acquire.py +249 -0
  76. unismac-0.1.0/tests/test_pyref_retarget_after_move.py +168 -0
  77. unismac-0.1.0/tests/test_pyref_retarget_busy.py +132 -0
  78. unismac-0.1.0/tests/test_pyref_scan_after_move.py +164 -0
  79. unismac-0.1.0/tests/test_pyref_scan_phase.py +288 -0
  80. unismac-0.1.0/tests/test_pyref_scan_phase_rotate.py +179 -0
  81. unismac-0.1.0/tests/test_pyref_scan_phase_tag.py +127 -0
  82. unismac-0.1.0/tests/test_pyref_terrain.py +653 -0
  83. unismac-0.1.0/tests/test_pyref_unit_overrides.py +115 -0
  84. unismac-0.1.0/tests/test_sc2_backend.py +515 -0
  85. unismac-0.1.0/tests/test_scenarios.py +117 -0
  86. unismac-0.1.0/tests/test_smac_bot.py +399 -0
  87. unismac-0.1.0/tests/test_unit_overrides.py +157 -0
  88. unismac-0.1.0/tests/test_zgame.py +2225 -0
  89. unismac-0.1.0/tests/test_zgame_env.py +1131 -0
  90. unismac-0.1.0/tests/test_zgame_m3.py +798 -0
  91. unismac-0.1.0/unismac/__init__.py +7 -0
  92. unismac-0.1.0/unismac/__main__.py +3 -0
  93. unismac-0.1.0/unismac/assets/__init__.py +312 -0
  94. unismac-0.1.0/unismac/assets/map_abilities.json +258 -0
  95. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__10m_vs_11m.npz +0 -0
  96. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__1c3s5z.npz +0 -0
  97. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__25m.npz +0 -0
  98. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__27m_vs_30m.npz +0 -0
  99. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__2c_vs_64zg.npz +0 -0
  100. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__2m_vs_1z.npz +0 -0
  101. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__2s3z.npz +0 -0
  102. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__2s_vs_1sc.npz +0 -0
  103. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__32x32_flat.npz +0 -0
  104. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__3m.npz +0 -0
  105. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__3s5z.npz +0 -0
  106. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__3s5z_vs_3s6z.npz +0 -0
  107. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__3s_vs_3z.npz +0 -0
  108. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__3s_vs_4z.npz +0 -0
  109. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__3s_vs_5z.npz +0 -0
  110. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__5m_vs_6m.npz +0 -0
  111. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__6h_vs_8z.npz +0 -0
  112. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__8m.npz +0 -0
  113. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__8m_vs_9m.npz +0 -0
  114. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__MMM.npz +0 -0
  115. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__MMM2.npz +0 -0
  116. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__bane_vs_bane.npz +0 -0
  117. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__corridor.npz +0 -0
  118. unismac-0.1.0/unismac/assets/maps/SMAC_Maps__so_many_baneling.npz +0 -0
  119. unismac-0.1.0/unismac/assets/maps/new_maps__10m_vs_11m.npz +0 -0
  120. unismac-0.1.0/unismac/assets/maps/new_maps__1c3s5z.npz +0 -0
  121. unismac-0.1.0/unismac/assets/maps/new_maps__25m.npz +0 -0
  122. unismac-0.1.0/unismac/assets/maps/new_maps__27m_vs_30m.npz +0 -0
  123. unismac-0.1.0/unismac/assets/maps/new_maps__2c_vs_64zg.npz +0 -0
  124. unismac-0.1.0/unismac/assets/maps/new_maps__2m_vs_1z.npz +0 -0
  125. unismac-0.1.0/unismac/assets/maps/new_maps__2s3z.npz +0 -0
  126. unismac-0.1.0/unismac/assets/maps/new_maps__2s_vs_1sc.npz +0 -0
  127. unismac-0.1.0/unismac/assets/maps/new_maps__2vr_vs_3sc.npz +0 -0
  128. unismac-0.1.0/unismac/assets/maps/new_maps__3hl_vs_24zl.npz +0 -0
  129. unismac-0.1.0/unismac/assets/maps/new_maps__3m.npz +0 -0
  130. unismac-0.1.0/unismac/assets/maps/new_maps__3rp_vs_24zl.npz +0 -0
  131. unismac-0.1.0/unismac/assets/maps/new_maps__3rp_vs_5zl.npz +0 -0
  132. unismac-0.1.0/unismac/assets/maps/new_maps__3s5z.npz +0 -0
  133. unismac-0.1.0/unismac/assets/maps/new_maps__3s5z_vs_3s6z.npz +0 -0
  134. unismac-0.1.0/unismac/assets/maps/new_maps__3s_vs_5z.npz +0 -0
  135. unismac-0.1.0/unismac/assets/maps/new_maps__3st_vs_5zl.npz +0 -0
  136. unismac-0.1.0/unismac/assets/maps/new_maps__5m_vs_6m.npz +0 -0
  137. unismac-0.1.0/unismac/assets/maps/new_maps__6h_vs_8z.npz +0 -0
  138. unismac-0.1.0/unismac/assets/maps/new_maps__6m_vs_10m.npz +0 -0
  139. unismac-0.1.0/unismac/assets/maps/new_maps__7q_vs_2bc.npz +0 -0
  140. unismac-0.1.0/unismac/assets/maps/new_maps__8m.npz +0 -0
  141. unismac-0.1.0/unismac/assets/maps/new_maps__8m_vs_9m.npz +0 -0
  142. unismac-0.1.0/unismac/assets/maps/new_maps__MMM.npz +0 -0
  143. unismac-0.1.0/unismac/assets/maps/new_maps__MMM2.npz +0 -0
  144. unismac-0.1.0/unismac/assets/maps/new_maps__bane_vs_bane.npz +0 -0
  145. unismac-0.1.0/unismac/assets/maps/new_maps__corridor.npz +0 -0
  146. unismac-0.1.0/unismac/assets/maps/new_maps__mmmt.npz +0 -0
  147. unismac-0.1.0/unismac/assets/maps/new_maps__mmmt_vs_zhb.npz +0 -0
  148. unismac-0.1.0/unismac/assets/maps/new_maps__mmmt_vs_zspi.npz +0 -0
  149. unismac-0.1.0/unismac/assets/maps/new_maps__so_many_baneling.npz +0 -0
  150. unismac-0.1.0/unismac/assets/measured.json +353 -0
  151. unismac-0.1.0/unismac/assets/static_data.json +1090 -0
  152. unismac-0.1.0/unismac/assets/unit_overrides.json +48 -0
  153. unismac-0.1.0/unismac/backends/__init__.py +1 -0
  154. unismac-0.1.0/unismac/backends/pyref/__init__.py +11 -0
  155. unismac-0.1.0/unismac/backends/pyref/backend.py +248 -0
  156. unismac-0.1.0/unismac/backends/pyref/batch.py +68 -0
  157. unismac-0.1.0/unismac/backends/pyref/config.py +748 -0
  158. unismac-0.1.0/unismac/backends/pyref/navmesh.py +582 -0
  159. unismac-0.1.0/unismac/backends/pyref/pipeline.py +86 -0
  160. unismac-0.1.0/unismac/backends/pyref/rng.py +26 -0
  161. unismac-0.1.0/unismac/backends/pyref/sim.py +994 -0
  162. unismac-0.1.0/unismac/backends/pyref/subsystems/__init__.py +5 -0
  163. unismac-0.1.0/unismac/backends/pyref/subsystems/abilities.py +312 -0
  164. unismac-0.1.0/unismac/backends/pyref/subsystems/attack.py +241 -0
  165. unismac-0.1.0/unismac/backends/pyref/subsystems/collision.py +894 -0
  166. unismac-0.1.0/unismac/backends/pyref/subsystems/commands.py +558 -0
  167. unismac-0.1.0/unismac/backends/pyref/subsystems/damage.py +708 -0
  168. unismac-0.1.0/unismac/backends/pyref/subsystems/kinematics.py +563 -0
  169. unismac-0.1.0/unismac/backends/pyref/subsystems/native.py +2636 -0
  170. unismac-0.1.0/unismac/backends/pyref/subsystems/native_combat.py +653 -0
  171. unismac-0.1.0/unismac/backends/pyref/subsystems/pathing.py +327 -0
  172. unismac-0.1.0/unismac/backends/pyref/subsystems/steering.py +1076 -0
  173. unismac-0.1.0/unismac/backends/pyref/subsystems/targeting.py +1323 -0
  174. unismac-0.1.0/unismac/backends/pyref/subsystems/visibility.py +135 -0
  175. unismac-0.1.0/unismac/backends/pyref/terrain.py +177 -0
  176. unismac-0.1.0/unismac/backends/sc2/__init__.py +9 -0
  177. unismac-0.1.0/unismac/backends/sc2/_runtime.py +85 -0
  178. unismac-0.1.0/unismac/backends/sc2/backend.py +753 -0
  179. unismac-0.1.0/unismac/backends/sc2/extract.py +276 -0
  180. unismac-0.1.0/unismac/backends/sc2/session.py +206 -0
  181. unismac-0.1.0/unismac/backends/zgame/__init__.py +10 -0
  182. unismac-0.1.0/unismac/backends/zgame/backend.py +659 -0
  183. unismac-0.1.0/unismac/cli.py +234 -0
  184. unismac-0.1.0/unismac/contract/__init__.py +50 -0
  185. unismac-0.1.0/unismac/contract/backend.py +104 -0
  186. unismac-0.1.0/unismac/contract/conformance.py +190 -0
  187. unismac-0.1.0/unismac/contract/types.py +494 -0
  188. unismac-0.1.0/unismac/env/__init__.py +225 -0
  189. unismac-0.1.0/unismac/env/abilities.py +123 -0
  190. unismac-0.1.0/unismac/env/accel.py +236 -0
  191. unismac-0.1.0/unismac/env/actions.py +286 -0
  192. unismac-0.1.0/unismac/env/catalog.py +461 -0
  193. unismac-0.1.0/unismac/env/classic.py +147 -0
  194. unismac-0.1.0/unismac/env/config.py +648 -0
  195. unismac-0.1.0/unismac/env/core.py +974 -0
  196. unismac-0.1.0/unismac/env/dual.py +469 -0
  197. unismac-0.1.0/unismac/env/features.py +440 -0
  198. unismac-0.1.0/unismac/env/generators.py +219 -0
  199. unismac-0.1.0/unismac/env/manifest.py +235 -0
  200. unismac-0.1.0/unismac/env/native.py +483 -0
  201. unismac-0.1.0/unismac/env/native_rust.py +582 -0
  202. unismac-0.1.0/unismac/env/opponents.py +140 -0
  203. unismac-0.1.0/unismac/env/reward.py +117 -0
  204. unismac-0.1.0/unismac/env/rng.py +88 -0
  205. unismac-0.1.0/unismac/env/rust_manifest.json +68 -0
  206. unismac-0.1.0/unismac/env/scripted/__init__.py +23 -0
  207. unismac-0.1.0/unismac/env/scripted/api.py +274 -0
  208. unismac-0.1.0/unismac/env/scripted/base.py +106 -0
  209. unismac-0.1.0/unismac/env/scripted/common.py +138 -0
  210. unismac-0.1.0/unismac/env/scripted/maps/__init__.py +9 -0
  211. unismac-0.1.0/unismac/env/scripted/maps/s_1c3s5z.py +156 -0
  212. unismac-0.1.0/unismac/env/scripted/maps/s_27m.py +93 -0
  213. unismac-0.1.0/unismac/env/scripted/maps/s_2c_vs_64zg.py +158 -0
  214. unismac-0.1.0/unismac/env/scripted/maps/s_2s3z.py +116 -0
  215. unismac-0.1.0/unismac/env/scripted/maps/s_2vr_vs_3sc.py +109 -0
  216. unismac-0.1.0/unismac/env/scripted/maps/s_3hl_vs_24zl.py +81 -0
  217. unismac-0.1.0/unismac/env/scripted/maps/s_3rp_vs_5zl.py +112 -0
  218. unismac-0.1.0/unismac/env/scripted/maps/s_3s5z.py +128 -0
  219. unismac-0.1.0/unismac/env/scripted/maps/s_3s_vs_3z.py +201 -0
  220. unismac-0.1.0/unismac/env/scripted/maps/s_3s_vs_4z.py +204 -0
  221. unismac-0.1.0/unismac/env/scripted/maps/s_3s_vs_5z.py +205 -0
  222. unismac-0.1.0/unismac/env/scripted/maps/s_3st_vs_5zl.py +209 -0
  223. unismac-0.1.0/unismac/env/scripted/maps/s_6h_vs_8z.py +102 -0
  224. unismac-0.1.0/unismac/env/scripted/maps/s_6m_vs_10m.py +119 -0
  225. unismac-0.1.0/unismac/env/scripted/maps/s_7q_vs_2bc.py +100 -0
  226. unismac-0.1.0/unismac/env/scripted/maps/s_8m.py +132 -0
  227. unismac-0.1.0/unismac/env/scripted/maps/s_corridor.py +153 -0
  228. unismac-0.1.0/unismac/env/scripted/maps/s_mmm.py +273 -0
  229. unismac-0.1.0/unismac/env/scripted/maps/s_mmmt.py +330 -0
  230. unismac-0.1.0/unismac/env/scripted/maps/s_mmmt_vs_zhb.py +202 -0
  231. unismac-0.1.0/unismac/env/scripted/maps/s_mmmt_vs_zspi.py +230 -0
  232. unismac-0.1.0/unismac/env/scripted/opponent.py +288 -0
  233. unismac-0.1.0/unismac/env/services.py +87 -0
  234. unismac-0.1.0/unismac/env/settle.py +104 -0
  235. unismac-0.1.0/unismac/env/smac_bot.py +501 -0
  236. unismac-0.1.0/unismac/env/spotter.py +89 -0
  237. unismac-0.1.0/unismac/env/termination.py +81 -0
  238. unismac-0.1.0/unismac/env/terrain.py +96 -0
  239. unismac-0.1.0/unismac/env/units.py +181 -0
  240. unismac-0.1.0/unismac/env/visibility.py +50 -0
  241. unismac-0.1.0/unismac/presets/__init__.py +17 -0
  242. unismac-0.1.0/unismac/presets/registry.py +70 -0
  243. unismac-0.1.0/unismac/presets/smac.py +75 -0
  244. unismac-0.1.0/unismac/presets/smac_hard.py +116 -0
  245. unismac-0.1.0/unismac/presets/smacv2.py +186 -0
  246. unismac-0.1.0/unismac/profiles.py +440 -0
  247. unismac-0.1.0/unismac/scenarios/__init__.py +17 -0
  248. unismac-0.1.0/unismac/scenarios/data.py +1104 -0
  249. unismac-0.1.0/unismac/scenarios/registry.py +86 -0
  250. unismac-0.1.0/unismac/scenarios/spawns.json +3954 -0
  251. unismac-0.1.0/unismac/scenarios/spawns.py +106 -0
  252. unismac-0.1.0/unismac/scenarios/spawns_hard.json +5018 -0
@@ -0,0 +1,22 @@
1
+ # Python build & packaging artifacts
2
+ /dist/
3
+ /build/
4
+ *.egg-info/
5
+ .venv/
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # Legacy local native extension artifacts (use standalone `zgame` wheel instead)
11
+ unismac/backends/zgame/_zgame*.so
12
+ unismac/backends/zgame/_zgame*.pyd
13
+ unismac/backends/zgame/_zgame.build.json
14
+
15
+ # Tool caches
16
+ .pytest_cache/
17
+ .ruff_cache/
18
+ .mypy_cache/
19
+
20
+ # OS & editor files
21
+ .DS_Store
22
+ Thumbs.db
@@ -0,0 +1,20 @@
1
+ cff-version: 1.2.0
2
+ title: "UniSMAC: Unified Multi-Backend StarCraft Multi-Agent Challenge"
3
+ message: "If you use UniSMAC in your research, please cite this software."
4
+ type: software
5
+ version: "0.1.0"
6
+ date-released: "2026-11-25"
7
+ license: "MIT"
8
+ repository-code: "https://github.com/Z-Foundry/UniSMAC"
9
+ url: "https://github.com/Z-Foundry/UniSMAC"
10
+ keywords:
11
+ - multi-agent reinforcement learning
12
+ - smac
13
+ - smacv2
14
+ - smac-hard
15
+ - starcraft
16
+ - sim-to-real transfer
17
+ authors:
18
+ - family-names: "Wang"
19
+ given-names: "Jiale"
20
+ email: "jialewang@bupt.edu.cn"
unismac-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jiale Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
unismac-0.1.0/NOTICE ADDED
@@ -0,0 +1,140 @@
1
+ UniSMAC
2
+ Copyright (c) 2026 Jiale Wang
3
+ Repository: https://github.com/Z-Foundry/UniSMAC
4
+
5
+ This software is licensed under the MIT License (see LICENSE).
6
+
7
+ ================================================================================
8
+ THIRD-PARTY NOTICES AND ATTRIBUTIONS
9
+ ================================================================================
10
+
11
+ UniSMAC incorporates derivative adaptations and re-implementations of benchmark
12
+ specifications, scenario tables, observation/reward/action semantics, and
13
+ decision-tree opponent scripts from the following open-source projects:
14
+
15
+ --------------------------------------------------------------------------------
16
+ 1. SMAC (StarCraft Multi-Agent Challenge)
17
+ Repository: https://github.com/oxwhirl/smac
18
+ License: MIT License
19
+ Scope in UniSMAC:
20
+ - unismac/presets/smac.py
21
+ - unismac/scenarios/data.py (SMAC scenario metadata)
22
+ - unismac/env/{actions,catalog,features,reward,termination,terrain,units,visibility}.py
23
+ --------------------------------------------------------------------------------
24
+
25
+ MIT License
26
+
27
+ Copyright (c) 2019 whirl
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining a copy
30
+ of this software and associated documentation files (the "Software"), to deal
31
+ in the Software without restriction, including without limitation the rights
32
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33
+ copies of the Software, and to permit persons to whom the Software is
34
+ furnished to do so, subject to the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be included in all
37
+ copies or substantial portions of the Software.
38
+
39
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45
+ SOFTWARE.
46
+
47
+ --------------------------------------------------------------------------------
48
+ 2. SMACv2
49
+ Repository: https://github.com/oxwhirl/smacv2
50
+ License: MIT License
51
+ Scope in UniSMAC:
52
+ - unismac/presets/smacv2.py
53
+ - unismac/scenarios/data.py (SMACv2 scenario metadata)
54
+ - unismac/env/{generators,spotter,visibility}.py
55
+ --------------------------------------------------------------------------------
56
+
57
+ MIT License
58
+
59
+ Copyright (c) 2019 whirl
60
+
61
+ Permission is hereby granted, free of charge, to any person obtaining a copy
62
+ of this software and associated documentation files (the "Software"), to deal
63
+ in the Software without restriction, including without limitation the rights
64
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
65
+ copies of the Software, and to permit persons to whom the Software is
66
+ furnished to do so, subject to the following conditions:
67
+
68
+ The above copyright notice and this permission notice shall be included in all
69
+ copies or substantial portions of the Software.
70
+
71
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
72
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
73
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
74
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
75
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
76
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
77
+ SOFTWARE.
78
+
79
+ --------------------------------------------------------------------------------
80
+ 3. SMAC-Hard
81
+ Repository: https://github.com/devindeng94/smac-hard
82
+ License: MIT License
83
+ Scope in UniSMAC:
84
+ - unismac/env/scripted/ (45 scripted opponent policies and helper utilities)
85
+ - unismac/env/abilities.py
86
+ - unismac/presets/smac_hard.py
87
+ - unismac/scenarios/data.py (SMAC-Hard scenario metadata)
88
+ --------------------------------------------------------------------------------
89
+
90
+ MIT License
91
+
92
+ Copyright (c) 2024 devin
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy
95
+ of this software and associated documentation files (the "Software"), to deal
96
+ in the Software without restriction, including without limitation the rights
97
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
98
+ copies of the Software, and to permit persons to whom the Software is
99
+ furnished to do so, subject to the following conditions:
100
+
101
+ The above copyright notice and this permission notice shall be included in all
102
+ copies or substantial portions of the Software.
103
+
104
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
+ SOFTWARE.
111
+
112
+ --------------------------------------------------------------------------------
113
+ 4. Runtime and Optional Dependencies (Not Bundled)
114
+ --------------------------------------------------------------------------------
115
+
116
+ - NumPy (BSD-3-Clause): https://github.com/numpy/numpy
117
+ - ZGame / zfoundry-zgame (MIT): https://github.com/Z-Foundry/ZGame (companion Rust acceleration engine)
118
+ - PySC2 (Apache-2.0, optional [sc2] extra): https://github.com/google-deepmind/pysc2
119
+ - s2clientprotocol (MIT, optional [sc2] extra): https://github.com/Blizzard/s2client-proto
120
+ - protobuf (BSD-3-Clause, optional [sc2] extra): https://github.com/protocolbuffers/protobuf
121
+
122
+ ================================================================================
123
+ TRADEMARK, NON-AFFILIATION, AND ASSET PROVENANCE DISCLAIMER
124
+ ================================================================================
125
+
126
+ StarCraft and StarCraft II are registered trademarks or trademarks of Blizzard
127
+ Entertainment, Inc. in the U.S. and/or other countries. UniSMAC is an
128
+ independent open-source multi-agent reinforcement learning research library and
129
+ is not affiliated with, endorsed by, or sponsored by Blizzard Entertainment,
130
+ Inc.
131
+
132
+ This repository does NOT distribute any StarCraft II game binaries, proprietary
133
+ game media, or original .SC2Map files. The JSON and NPZ files under
134
+ unismac/assets/ and unismac/scenarios/ contain only simplified numerical grids
135
+ (32x32 / 40x40 passability and elevation arrays), unit balance tables, and
136
+ initial spawn coordinates derived via Blizzard's MIT-licensed s2clientprotocol
137
+ API and black-box empirical gameplay measurements for benchmark reproducibility.
138
+ Users who wish to run the optional live SC2 backend or regenerate derived assets
139
+ locally from SC2PATH must obtain StarCraft II and community map files separately
140
+ and comply with the Blizzard StarCraft II AI and Machine Learning License.
unismac-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,198 @@
1
+ Metadata-Version: 2.5
2
+ Name: unismac
3
+ Version: 0.1.0
4
+ Summary: Unified multi-agent StarCraft combat environments (SMAC / SMACv2 / SMAC-Hard) with pluggable backends
5
+ Project-URL: Homepage, https://github.com/Z-Foundry/UniSMAC
6
+ Project-URL: Repository, https://github.com/Z-Foundry/UniSMAC
7
+ Project-URL: Issues, https://github.com/Z-Foundry/UniSMAC/issues
8
+ Author-email: Jiale Wang <jialewang@bupt.edu.cn>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Keywords: marl,multi-agent,reinforcement-learning,smac,smac-hard,smacv2
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Classifier: Operating System :: POSIX :: Linux
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
26
+ Requires-Python: >=3.10
27
+ Requires-Dist: numpy>=1.26
28
+ Requires-Dist: zfoundry-zgame<0.2.0,>=0.1.0; (sys_platform == 'linux' and (platform_machine == 'x86_64' or platform_machine == 'aarch64')) or (sys_platform == 'darwin' and (platform_machine == 'arm64' or platform_machine == 'x86_64')) or (sys_platform == 'win32' and platform_machine == 'AMD64')
29
+ Provides-Extra: sc2
30
+ Requires-Dist: protobuf==3.20.3; extra == 'sc2'
31
+ Requires-Dist: pysc2==4.0.0; extra == 'sc2'
32
+ Requires-Dist: s2clientprotocol==5.0.16.97563.0; extra == 'sc2'
33
+ Provides-Extra: zgame
34
+ Requires-Dist: zfoundry-zgame<0.2.0,>=0.1.0; extra == 'zgame'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # UniSMAC
38
+
39
+ English | [Chinese (zh-CN)](README_zh.md)
40
+
41
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
42
+ [![Python](https://img.shields.io/badge/Python-3.10%2B-green.svg)](https://www.python.org/)
43
+ [![ZGame](https://img.shields.io/badge/Backend-ZGame%20Rust-orange.svg)](https://github.com/Z-Foundry/ZGame)
44
+
45
+ **UniSMAC** is a unified, backend-swappable StarCraft Multi-Agent Challenge environment that brings **SMAC**, **SMACv2**, and **SMAC-Hard** under one clean API, one vectorized contract, and three interchangeable simulation backends:
46
+
47
+ - **`zgame`** (Rust, via [Z-Foundry/ZGame](https://github.com/Z-Foundry/ZGame), PyPI package `zfoundry-zgame`, imported as `zgame`): High-performance, deterministic simulation with **27×–91×** single-core speedups over Python and **zero StarCraft II dependency**.
48
+ - **`pyref`** (Pure Python / NumPy): Readable, hackable executable reference specification with bitwise parity against `zgame`.
49
+ - **`sc2`** (StarCraft II via PySC2, optional `[sc2]` extra): Real StarCraft II client backend for ground-truth evaluation and upstream parity verification.
50
+
51
+ ## Highlights
52
+
53
+ - **3 Benchmarks, 1 Process, Zero Conflicts**: Consolidates **84** registered benchmark scenarios across SMAC (23), SMACv2 (26), and SMAC-Hard (35) into 6 named presets (`smac`, `smacv2`, `smac-hard`, and 3 backend-portable `*-portable` presets). Eliminates upstream PySC2 map-registry collisions and patched-PySC2 conflicts so all benchmarks coexist in one process.
54
+ - **76/84 Portable Scenarios Out-of-the-Box**: **76 / 84** scenarios run immediately on both `pyref` and `zgame` (`smac-portable` 23/23, `smacv2-portable` 26/26, `smac-hard-portable` 27/35; the remaining 8 SMAC-Hard maps either lack map/spawn assets or crash in SC2 4.10), with **76 / 76** automatically hitting full Rust environment acceleration (`accel='rust'`).
55
+ - **Native Two-Sided Self-Play**: Built-in `opponent.kind='external'` mode with mirror spawning and the unbiased `sc2-symmetric` profile runs on **75 / 76** portable scenarios (all hitting `accel='rust'`), achieving mirror win-rate 95% CIs covering `0.50` across `2s3z`, `3s5z`, and `8m`.
56
+ - **High-Fidelity SC2 Alignment & Zero-Shot Transfer**: Policies trained purely in `zgame` transfer zero-shot to real StarCraft II 4.10 with dramatic improvements over heuristic baselines.
57
+ - **Drop-In RL Ecosystem Interfaces**: `make_vec_env()` returns a batched `VecEnv` with per-episode `seeds` (batch-position invariant) and per-episode opponent selection; `make_env(..., batch_size=1)` returns a PyMARL/EPyMARL-compatible `UnismacEnv`.
58
+
59
+ ## Verified Benchmarks
60
+
61
+ ### Throughput & Speedup (`OMP_NUM_THREADS=1`, `accel='rust'`)
62
+
63
+ | Benchmark | Baseline | `zgame` + `accel='rust'` | Speedup |
64
+ | --- | ---: | ---: | ---: |
65
+ | 57-unit L3 suite (`sc2-native`, 128 ep/unit, 1 core) | 7,067.7 s (`pyref`) | **115.1 s** | **61.4×** |
66
+ | Single-core representative maps (`8m` / `2c_vs_64zg` + 3D) | 86.1 / 3.9 step/s (`pyref`) | **6,219 / 358 step/s** | **72.2× / 91.4×** |
67
+ | `8m` MAPPO (`B=128`, 1T / 4T) | 602 step/s (10 SC2, ~4.1 cores) | **14.4k / 24.1k step/s** | **24×–40×** |
68
+ | `2s3z` MAPPO (`B=128`, 1T / 4T) | 719 step/s (10 SC2, ~4.0 cores) | **22.6k / 34.8k step/s** | **31×–48×** |
69
+ | `sc2-native` MAPPO end-to-end (`8m` / `2s3z`, 1T) | 7,064 s / 2,486 s (`pyref`) | **286 s / 96 s** | **24.7× / 25.8×** |
70
+
71
+ ### Behavioral Fidelity & Sim-to-SC2 Zero-Shot Transfer
72
+
73
+ | Evaluation | Baseline (`aligned-v4`) | `sc2-native` (`STANDARD_PROFILE`) | `sc2-explore` (`STANDARD_EXPLORE_PROFILE`) |
74
+ | --- | --- | --- | --- |
75
+ | 54-cell env-level alignment (exceeds-threshold cells) | 28 / 54 | **1 / 54** screening (**2 / 54** at 960 ep; SMACv2 0/18, SMAC-Hard 0/18) | 4 / 54 |
76
+ | Policy-pool ranking vs real SC2 (166 MAPPO ckpts) | `2s3z` ρ=0.650 / `8m` ρ=0.606 | **`2s3z` ρ=0.955** (`\|gap\|`=0.083, slope=0.983) / **`8m` ρ=0.870** | `2s3z` ρ=0.930 / `8m` ρ=0.875 |
77
+ | `zgame` ↔ `pyref` bitwise parity | — | **6,179 / 6,179** probes + **246 / 246** terrain/charge probes `L∞=0.0`; **57 / 57** L3 `1.000` | Bitwise identical (`L∞=0.0`) |
78
+ | `2s3z` zero-shot SC2 4.10 win rate (3× MAPPO) | 37.4% (gap `+47.5 pp`) | **64.6%** (10 seeds, **+27.2 pp** `[+9.8, +44.7]`, gap `+11.3 pp`, 0 stuck) | **86.3%** (5 seeds, gap **`+0.3 pp`**) |
79
+ | Two-sided mirror symmetry (`sc2-symmetric`, 95% CI) | Biased (`2s3z` 0.609, `3s5z` 0.671) | **Unbiased** (`2s3z` **0.490**, `3s5z` **0.535**, `8m` **0.512** — all CIs cover 0.50) | — |
80
+
81
+ ## Installation
82
+
83
+ On mainstream platforms (Linux `x86_64`/`aarch64`, macOS `arm64`/`x86_64`, Windows `AMD64`, Python 3.10–3.14), `pip install unismac` automatically installs the prebuilt `zfoundry-zgame` Rust acceleration package (imported as `zgame`):
84
+
85
+ ```bash
86
+ pip install unismac
87
+ ```
88
+
89
+ ### Pure-Python / Unsupported Platform Fallback
90
+
91
+ On platforms without a matching `cp310-abi3` `zfoundry-zgame` wheel (e.g., glibc < 2.28, Alpine ARM64, RISC-V, or free-threaded Python 3.13t/3.14t), install UniSMAC in pure-Python mode (`pyref` backend, `accel='python'`):
92
+
93
+ ```bash
94
+ pip install --no-deps unismac && pip install "numpy>=1.26"
95
+ ```
96
+
97
+ If a Rust ≥ 1.85 toolchain is available, you can build `zfoundry-zgame` from source with `pip install "unismac[zgame]"`.
98
+
99
+ ### Optional Real StarCraft II Backend (`[sc2]`)
100
+
101
+ ```bash
102
+ pip install "unismac[sc2]"
103
+ export SC2PATH=/path/to/StarCraftII
104
+ ```
105
+
106
+ > **Python 3.14 note for `[sc2]`**: Upstream `pysc2==4.0.0` depends on `pygame`, which only publishes prebuilt wheels up to Python 3.13 (and pins `protobuf==3.20.3` and `s2clientprotocol==5.0.16.97563.0`). For the optional `[sc2]` extra, **Python 3.10–3.13** works out-of-the-box; on Python 3.14, install `pygame-ce>=2.5.8` (or use a Python 3.12/3.13 environment for SC2 evaluation). Note that `unismac` requires no `[sc2]` extra for `zgame` or `pyref`, and automatically patches PySC2's removed 2-argument `random.shuffle` call on Python 3.11+.
107
+
108
+ ## 30-Second Quickstart
109
+
110
+ ### 1. Fast Zero-SC2 Vectorized Rollout (`zgame`)
111
+
112
+ ```python
113
+ import numpy as np
114
+ from unismac import make_vec_env
115
+ from unismac.profiles import profile_overrides
116
+
117
+ _, overrides = profile_overrides("sc2-native")
118
+ env = make_vec_env(
119
+ "smac-portable", "8m", backend="zgame", batch_size=64, seed=0, overrides=overrides
120
+ )
121
+ obs, state = env.reset() # obs: [64, 8, D], state: [64, S]; env.accel == "rust"
122
+
123
+ rng = np.random.default_rng(0)
124
+ for _ in range(100):
125
+ avail = env.get_avail_actions()
126
+ actions = np.array([[int(rng.choice(np.flatnonzero(r))) for r in row] for row in avail])
127
+ rewards, terminated, infos = env.step(actions)
128
+ if terminated.any():
129
+ env.reset(np.flatnonzero(terminated).tolist())
130
+ env.close()
131
+ ```
132
+
133
+ ### 2. Symmetric Two-Sided Self-Play
134
+
135
+ ```python
136
+ import numpy as np
137
+ from unismac import make_vec_env
138
+ from unismac.profiles import merge_overrides, profile_overrides
139
+
140
+ _, sym = profile_overrides("sc2-symmetric")
141
+ overrides = merge_overrides(sym, {"opponent.kind": "external"})
142
+ env = make_vec_env(
143
+ "smac-portable", "2s3z", backend="zgame", batch_size=32, seed=0, overrides=overrides
144
+ )
145
+ env.reset()
146
+
147
+ obs_p1, obs_p2 = env.get_obs(side=1), env.get_obs(side=2)
148
+ avail_p1, avail_p2 = env.get_avail_actions(side=1), env.get_avail_actions(side=2)
149
+ r_p1, terminated, infos = env.step(avail_p1.argmax(-1), enemy_actions=avail_p2.argmax(-1))
150
+ r_p2 = np.array([info.get("reward_enemy", 0.0) for info in infos])
151
+ env.close()
152
+ ```
153
+
154
+ ### 3. One-Line Switch to Real SC2 Evaluation or Pure-Python `pyref`
155
+
156
+ ```python
157
+ from unismac import make_env
158
+
159
+ # Real StarCraft II evaluation (requires `pip install "unismac[sc2]"` and SC2PATH)
160
+ sc2_env = make_env("smac-portable", "8m", backend="sc2", seed=0) # MultiAgentEnv-compatible UnismacEnv
161
+
162
+ # Or readable pure-Python reference backend (no SC2 or Rust needed)
163
+ pyref_env = make_env("smac-portable", "8m", backend="pyref", seed=0)
164
+ ```
165
+
166
+ Runnable scripts are in [`examples/`](examples/quickstart_vec.py):
167
+ - [`examples/quickstart_vec.py`](examples/quickstart_vec.py) — vectorized single-side rollout
168
+ - [`examples/self_play.py`](examples/self_play.py) — two-sided symmetric self-play
169
+ - [`examples/sc2_eval.py`](examples/sc2_eval.py) — backend switching (`zgame` / `pyref` / `sc2`)
170
+
171
+ ## CLI
172
+
173
+ ```bash
174
+ unismac info # Package, contract, and zgame acceleration status
175
+ unismac list-scenarios --preset smac-portable # List scenarios for a preset
176
+ unismac list-profiles # List public profiles (add --all for legacy aliases)
177
+ unismac bench --preset smac-portable --scenario 8m \
178
+ --backend zgame --batch-size 64 --steps 200 # Quick throughput benchmark
179
+ ```
180
+
181
+ ## Documentation
182
+
183
+ | Document | Contents |
184
+ | --- | --- |
185
+ | [Architecture](docs/architecture.md) | Layered design, backend contract, SC2 / PyRef / ZGame backends, and cross-package versioning |
186
+ | [Environment Interface](docs/interface.md) | Public `VecEnv`/`UnismacEnv` API, two-sided self-play, per-episode seeds/opponents, `accel` tiers, and `NativeSMACOpponent` |
187
+ | [Benchmarks & Presets](docs/benchmarks.md) | SMAC / SMACv2 / SMAC-Hard differences, 84 scenarios (76 portable runnable), SC2 setup & asset extraction |
188
+ | [Profiles & Configuration](docs/profiles-and-config.md) | Public profiles (`sc2-native`, `sc2-explore`, `sc2-symmetric`), legacy aliases, and `PyrefConfig` reference |
189
+
190
+ ## Citation
191
+
192
+ If you use UniSMAC in your research, please cite it using [CITATION.cff](CITATION.cff).
193
+
194
+ ## License & Disclaimer
195
+
196
+ Licensed under the [MIT License](LICENSE). Third-party attributions (including SMAC, SMACv2, and SMAC-Hard) are listed in [NOTICE](NOTICE).
197
+
198
+ StarCraft® II is a registered trademark of Blizzard Entertainment, Inc. UniSMAC is an independent open-source research project and is not affiliated with, endorsed by, or sponsored by Blizzard Entertainment, Inc.
@@ -0,0 +1,162 @@
1
+ # UniSMAC
2
+
3
+ English | [Chinese (zh-CN)](README_zh.md)
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
+ [![Python](https://img.shields.io/badge/Python-3.10%2B-green.svg)](https://www.python.org/)
7
+ [![ZGame](https://img.shields.io/badge/Backend-ZGame%20Rust-orange.svg)](https://github.com/Z-Foundry/ZGame)
8
+
9
+ **UniSMAC** is a unified, backend-swappable StarCraft Multi-Agent Challenge environment that brings **SMAC**, **SMACv2**, and **SMAC-Hard** under one clean API, one vectorized contract, and three interchangeable simulation backends:
10
+
11
+ - **`zgame`** (Rust, via [Z-Foundry/ZGame](https://github.com/Z-Foundry/ZGame), PyPI package `zfoundry-zgame`, imported as `zgame`): High-performance, deterministic simulation with **27×–91×** single-core speedups over Python and **zero StarCraft II dependency**.
12
+ - **`pyref`** (Pure Python / NumPy): Readable, hackable executable reference specification with bitwise parity against `zgame`.
13
+ - **`sc2`** (StarCraft II via PySC2, optional `[sc2]` extra): Real StarCraft II client backend for ground-truth evaluation and upstream parity verification.
14
+
15
+ ## Highlights
16
+
17
+ - **3 Benchmarks, 1 Process, Zero Conflicts**: Consolidates **84** registered benchmark scenarios across SMAC (23), SMACv2 (26), and SMAC-Hard (35) into 6 named presets (`smac`, `smacv2`, `smac-hard`, and 3 backend-portable `*-portable` presets). Eliminates upstream PySC2 map-registry collisions and patched-PySC2 conflicts so all benchmarks coexist in one process.
18
+ - **76/84 Portable Scenarios Out-of-the-Box**: **76 / 84** scenarios run immediately on both `pyref` and `zgame` (`smac-portable` 23/23, `smacv2-portable` 26/26, `smac-hard-portable` 27/35; the remaining 8 SMAC-Hard maps either lack map/spawn assets or crash in SC2 4.10), with **76 / 76** automatically hitting full Rust environment acceleration (`accel='rust'`).
19
+ - **Native Two-Sided Self-Play**: Built-in `opponent.kind='external'` mode with mirror spawning and the unbiased `sc2-symmetric` profile runs on **75 / 76** portable scenarios (all hitting `accel='rust'`), achieving mirror win-rate 95% CIs covering `0.50` across `2s3z`, `3s5z`, and `8m`.
20
+ - **High-Fidelity SC2 Alignment & Zero-Shot Transfer**: Policies trained purely in `zgame` transfer zero-shot to real StarCraft II 4.10 with dramatic improvements over heuristic baselines.
21
+ - **Drop-In RL Ecosystem Interfaces**: `make_vec_env()` returns a batched `VecEnv` with per-episode `seeds` (batch-position invariant) and per-episode opponent selection; `make_env(..., batch_size=1)` returns a PyMARL/EPyMARL-compatible `UnismacEnv`.
22
+
23
+ ## Verified Benchmarks
24
+
25
+ ### Throughput & Speedup (`OMP_NUM_THREADS=1`, `accel='rust'`)
26
+
27
+ | Benchmark | Baseline | `zgame` + `accel='rust'` | Speedup |
28
+ | --- | ---: | ---: | ---: |
29
+ | 57-unit L3 suite (`sc2-native`, 128 ep/unit, 1 core) | 7,067.7 s (`pyref`) | **115.1 s** | **61.4×** |
30
+ | Single-core representative maps (`8m` / `2c_vs_64zg` + 3D) | 86.1 / 3.9 step/s (`pyref`) | **6,219 / 358 step/s** | **72.2× / 91.4×** |
31
+ | `8m` MAPPO (`B=128`, 1T / 4T) | 602 step/s (10 SC2, ~4.1 cores) | **14.4k / 24.1k step/s** | **24×–40×** |
32
+ | `2s3z` MAPPO (`B=128`, 1T / 4T) | 719 step/s (10 SC2, ~4.0 cores) | **22.6k / 34.8k step/s** | **31×–48×** |
33
+ | `sc2-native` MAPPO end-to-end (`8m` / `2s3z`, 1T) | 7,064 s / 2,486 s (`pyref`) | **286 s / 96 s** | **24.7× / 25.8×** |
34
+
35
+ ### Behavioral Fidelity & Sim-to-SC2 Zero-Shot Transfer
36
+
37
+ | Evaluation | Baseline (`aligned-v4`) | `sc2-native` (`STANDARD_PROFILE`) | `sc2-explore` (`STANDARD_EXPLORE_PROFILE`) |
38
+ | --- | --- | --- | --- |
39
+ | 54-cell env-level alignment (exceeds-threshold cells) | 28 / 54 | **1 / 54** screening (**2 / 54** at 960 ep; SMACv2 0/18, SMAC-Hard 0/18) | 4 / 54 |
40
+ | Policy-pool ranking vs real SC2 (166 MAPPO ckpts) | `2s3z` ρ=0.650 / `8m` ρ=0.606 | **`2s3z` ρ=0.955** (`\|gap\|`=0.083, slope=0.983) / **`8m` ρ=0.870** | `2s3z` ρ=0.930 / `8m` ρ=0.875 |
41
+ | `zgame` ↔ `pyref` bitwise parity | — | **6,179 / 6,179** probes + **246 / 246** terrain/charge probes `L∞=0.0`; **57 / 57** L3 `1.000` | Bitwise identical (`L∞=0.0`) |
42
+ | `2s3z` zero-shot SC2 4.10 win rate (3× MAPPO) | 37.4% (gap `+47.5 pp`) | **64.6%** (10 seeds, **+27.2 pp** `[+9.8, +44.7]`, gap `+11.3 pp`, 0 stuck) | **86.3%** (5 seeds, gap **`+0.3 pp`**) |
43
+ | Two-sided mirror symmetry (`sc2-symmetric`, 95% CI) | Biased (`2s3z` 0.609, `3s5z` 0.671) | **Unbiased** (`2s3z` **0.490**, `3s5z` **0.535**, `8m` **0.512** — all CIs cover 0.50) | — |
44
+
45
+ ## Installation
46
+
47
+ On mainstream platforms (Linux `x86_64`/`aarch64`, macOS `arm64`/`x86_64`, Windows `AMD64`, Python 3.10–3.14), `pip install unismac` automatically installs the prebuilt `zfoundry-zgame` Rust acceleration package (imported as `zgame`):
48
+
49
+ ```bash
50
+ pip install unismac
51
+ ```
52
+
53
+ ### Pure-Python / Unsupported Platform Fallback
54
+
55
+ On platforms without a matching `cp310-abi3` `zfoundry-zgame` wheel (e.g., glibc < 2.28, Alpine ARM64, RISC-V, or free-threaded Python 3.13t/3.14t), install UniSMAC in pure-Python mode (`pyref` backend, `accel='python'`):
56
+
57
+ ```bash
58
+ pip install --no-deps unismac && pip install "numpy>=1.26"
59
+ ```
60
+
61
+ If a Rust ≥ 1.85 toolchain is available, you can build `zfoundry-zgame` from source with `pip install "unismac[zgame]"`.
62
+
63
+ ### Optional Real StarCraft II Backend (`[sc2]`)
64
+
65
+ ```bash
66
+ pip install "unismac[sc2]"
67
+ export SC2PATH=/path/to/StarCraftII
68
+ ```
69
+
70
+ > **Python 3.14 note for `[sc2]`**: Upstream `pysc2==4.0.0` depends on `pygame`, which only publishes prebuilt wheels up to Python 3.13 (and pins `protobuf==3.20.3` and `s2clientprotocol==5.0.16.97563.0`). For the optional `[sc2]` extra, **Python 3.10–3.13** works out-of-the-box; on Python 3.14, install `pygame-ce>=2.5.8` (or use a Python 3.12/3.13 environment for SC2 evaluation). Note that `unismac` requires no `[sc2]` extra for `zgame` or `pyref`, and automatically patches PySC2's removed 2-argument `random.shuffle` call on Python 3.11+.
71
+
72
+ ## 30-Second Quickstart
73
+
74
+ ### 1. Fast Zero-SC2 Vectorized Rollout (`zgame`)
75
+
76
+ ```python
77
+ import numpy as np
78
+ from unismac import make_vec_env
79
+ from unismac.profiles import profile_overrides
80
+
81
+ _, overrides = profile_overrides("sc2-native")
82
+ env = make_vec_env(
83
+ "smac-portable", "8m", backend="zgame", batch_size=64, seed=0, overrides=overrides
84
+ )
85
+ obs, state = env.reset() # obs: [64, 8, D], state: [64, S]; env.accel == "rust"
86
+
87
+ rng = np.random.default_rng(0)
88
+ for _ in range(100):
89
+ avail = env.get_avail_actions()
90
+ actions = np.array([[int(rng.choice(np.flatnonzero(r))) for r in row] for row in avail])
91
+ rewards, terminated, infos = env.step(actions)
92
+ if terminated.any():
93
+ env.reset(np.flatnonzero(terminated).tolist())
94
+ env.close()
95
+ ```
96
+
97
+ ### 2. Symmetric Two-Sided Self-Play
98
+
99
+ ```python
100
+ import numpy as np
101
+ from unismac import make_vec_env
102
+ from unismac.profiles import merge_overrides, profile_overrides
103
+
104
+ _, sym = profile_overrides("sc2-symmetric")
105
+ overrides = merge_overrides(sym, {"opponent.kind": "external"})
106
+ env = make_vec_env(
107
+ "smac-portable", "2s3z", backend="zgame", batch_size=32, seed=0, overrides=overrides
108
+ )
109
+ env.reset()
110
+
111
+ obs_p1, obs_p2 = env.get_obs(side=1), env.get_obs(side=2)
112
+ avail_p1, avail_p2 = env.get_avail_actions(side=1), env.get_avail_actions(side=2)
113
+ r_p1, terminated, infos = env.step(avail_p1.argmax(-1), enemy_actions=avail_p2.argmax(-1))
114
+ r_p2 = np.array([info.get("reward_enemy", 0.0) for info in infos])
115
+ env.close()
116
+ ```
117
+
118
+ ### 3. One-Line Switch to Real SC2 Evaluation or Pure-Python `pyref`
119
+
120
+ ```python
121
+ from unismac import make_env
122
+
123
+ # Real StarCraft II evaluation (requires `pip install "unismac[sc2]"` and SC2PATH)
124
+ sc2_env = make_env("smac-portable", "8m", backend="sc2", seed=0) # MultiAgentEnv-compatible UnismacEnv
125
+
126
+ # Or readable pure-Python reference backend (no SC2 or Rust needed)
127
+ pyref_env = make_env("smac-portable", "8m", backend="pyref", seed=0)
128
+ ```
129
+
130
+ Runnable scripts are in [`examples/`](examples/quickstart_vec.py):
131
+ - [`examples/quickstart_vec.py`](examples/quickstart_vec.py) — vectorized single-side rollout
132
+ - [`examples/self_play.py`](examples/self_play.py) — two-sided symmetric self-play
133
+ - [`examples/sc2_eval.py`](examples/sc2_eval.py) — backend switching (`zgame` / `pyref` / `sc2`)
134
+
135
+ ## CLI
136
+
137
+ ```bash
138
+ unismac info # Package, contract, and zgame acceleration status
139
+ unismac list-scenarios --preset smac-portable # List scenarios for a preset
140
+ unismac list-profiles # List public profiles (add --all for legacy aliases)
141
+ unismac bench --preset smac-portable --scenario 8m \
142
+ --backend zgame --batch-size 64 --steps 200 # Quick throughput benchmark
143
+ ```
144
+
145
+ ## Documentation
146
+
147
+ | Document | Contents |
148
+ | --- | --- |
149
+ | [Architecture](docs/architecture.md) | Layered design, backend contract, SC2 / PyRef / ZGame backends, and cross-package versioning |
150
+ | [Environment Interface](docs/interface.md) | Public `VecEnv`/`UnismacEnv` API, two-sided self-play, per-episode seeds/opponents, `accel` tiers, and `NativeSMACOpponent` |
151
+ | [Benchmarks & Presets](docs/benchmarks.md) | SMAC / SMACv2 / SMAC-Hard differences, 84 scenarios (76 portable runnable), SC2 setup & asset extraction |
152
+ | [Profiles & Configuration](docs/profiles-and-config.md) | Public profiles (`sc2-native`, `sc2-explore`, `sc2-symmetric`), legacy aliases, and `PyrefConfig` reference |
153
+
154
+ ## Citation
155
+
156
+ If you use UniSMAC in your research, please cite it using [CITATION.cff](CITATION.cff).
157
+
158
+ ## License & Disclaimer
159
+
160
+ Licensed under the [MIT License](LICENSE). Third-party attributions (including SMAC, SMACv2, and SMAC-Hard) are listed in [NOTICE](NOTICE).
161
+
162
+ StarCraft® II is a registered trademark of Blizzard Entertainment, Inc. UniSMAC is an independent open-source research project and is not affiliated with, endorsed by, or sponsored by Blizzard Entertainment, Inc.