BurnySc2 / python-sc2

A StarCraft II bot api client library for Python 3
MIT License
509 stars 157 forks source link

Add example script to re-use a SC2 instance #56

Open BurnySc2 opened 4 years ago

BurnySc2 commented 4 years ago

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

leaverpool commented 4 years ago

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