python-sc2 icon indicating copy to clipboard operation
python-sc2 copied to clipboard

Add example script to re-use a SC2 instance

Open BurnySc2 opened this issue 5 years ago • 1 comments

When developing bots, it can be annoying to wait for SC2 to launch before the bot connects to it.

Following idea could speed up development:

  1. Script to launch a SC2 instance (ready state)
  2. Script to launch the bot and let the bot connect to the SC2 instance, and play the game
  3. Script to terminate the bot and disconnects it from the SC2 instance, then puts SC2 back into the ready state

This way you have to launch script 1) once, then can use scripts 2) and 3) over and over without having to wait for SC2 to launch.

The fastreload.py script seems to achieve this somewhat: https://github.com/BurnySc2/python-sc2/blob/develop/examples/fastreload.py

Also: https://github.com/BurnySc2/python-sc2/blob/40765d879f27b409b7d5db19b462020b6571f740/sc2/main.py#L717

BurnySc2 avatar Jun 14 '20 16:06 BurnySc2

That is very nice. Have any ideas how i can implement there some random? Like: race_choice = random.choice([Race.Terran, Race.Protoss, Race.Zerg, Race.Random]) map_name = random.choice(["Ephemeron", "DeathAuraLE", "EternalEmpireLE", "EverDreamLE", "GoldenWallLE", "IceandChromeLE", "NightshadeLE"])

it is working for: sc2.run_game(sc2.maps.get(map_name), [ #Human(Race.Terran), bot, Computer(race_choice, Difficulty.Hard) # CheatInsane VeryHard Hard Medium Easy ], realtime=False, save_replay_as="Example.SC2Replay")

but no luck here

leaverpool avatar Aug 14 '20 02:08 leaverpool