-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
59 lines (43 loc) · 1.54 KB
/
main.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
53
54
55
56
57
58
59
from all_imports_packages import *
from all_imports_ai import *
from Zerg.Zagara.zagara_ai import ZagaraAI
class Humanoid(sc2.BotAI):
async def on_step(self, iteration: int):
pass
# Difficulties:
# VeryEasy
# Easy
# Medium
# MediumHard
# Hard
# Harder
# VeryHard
# CheatVision
# CheatMoney
# CheatInsane
def test_game(AI, race, map, realtime=False):
enemy_race = Race.Protoss
difficulty = Difficulty.VeryHard
replay_name = str(race)[str(race).rfind(".")+1] + "v" + str(enemy_race)[str(enemy_race).rfind(".")+1]
current_directory = os.getcwd() + "\\Replays\\"
with open(current_directory + "Matches.cnt", "r") as file:
cnt = int(file.readline())
replay_name = current_directory + "\\M" + str(cnt) + " " + replay_name + \
" " + str(difficulty)[str(difficulty).rfind(".")+1:]
result = run_game(
maps.get(map), [
# Bot(Race.Zerg, Humanoid()),
Bot(race, AI),
Computer(enemy_race, difficulty)
],
realtime=realtime,
save_replay_as=replay_name
)
termination = " " + str(result)[str(result).rfind(".")+1:] + ".Sc2Replay"
os.rename(replay_name, replay_name + termination)
replay_name += termination
shutil.copyfile(replay_name, current_directory + "Last Replay.Sc2Replay")
with open(current_directory + "Matches.cnt", "w") as file:
file.write(str(cnt+1))
if __name__ == "__main__":
test_game(ZagaraAI(), Race.Zerg, "TritonLE")