-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.py
53 lines (44 loc) · 1.55 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import argparse
import os
import sys
from sc2 import maps
from sc2.data import Race, Difficulty
from sc2.main import run_game
sys.path.insert(1, "sharpy-sc2")
sys.path.insert(1, os.path.join("sharpy-sc2", "python-sc2"))
sys.path.insert(1, "SC2MapAnalysis")
sys.path.insert(1, "bossman-sc2")
from chance import run_ladder_game
from chance.chance import Chance
from sc2.player import Bot, Computer
race_map = {
'terran': Race.Terran,
'zerg': Race.Zerg,
'protoss': Race.Protoss,
'random': Race.Random,
}
# Start game
if __name__ == '__main__':
if "--LadderServer" in sys.argv:
# Ladder game started by LadderManager
print("Starting ladder game...")
bot = Bot(Race.Random, Chance())
run_ladder_game(bot)
else:
# Local game
print("Starting local game...")
parser = argparse.ArgumentParser()
parser.add_argument('--ForceRace', type=str, nargs="?", help='Force a specific race')
parser.add_argument('--ForceStrategy', type=str, nargs="?", help='Force a specific strategy')
args, _ = parser.parse_known_args()
bot: Bot
if args.ForceRace is None:
bot = Bot(Race.Random, Chance())
elif args.ForceStrategy is None:
bot = Bot(race_map[args.ForceRace], Chance())
else:
bot = Bot(race_map[args.ForceRace], Chance(args.ForceStrategy))
run_game(maps.get("RoyalBloodAIE"), [
bot,
Computer(Race.Random, Difficulty.VeryHard),
], save_replay_as=f'replays/replay.SC2Replay', realtime=False)