Skip to content

Commit

Permalink
setup new bot, changed name and settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Drekken committed Apr 23, 2024
1 parent 0cc1648 commit a8c800f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
4 changes: 2 additions & 2 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Can add own unique config options here if desired

# Custom values not used by ares
MyBotName: MyBotName
MyBotRace: Random
MyBotName: AnglerBot
MyBotRace: Protoss
########################

UseData: False
Expand Down
42 changes: 25 additions & 17 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,43 @@
from sc2.data import AIBuild, Difficulty, Race
from sc2.main import run_game
from sc2.player import Bot, Computer
from sc2.bot_ai import BotAI


sys.path.append("ares-sc2/src/ares")
sys.path.append("ares-sc2/src")
sys.path.append("ares-sc2")

import yaml

from bot.main import MyBot
from bot.main import AnglerBot
from ladder import run_ladder_game

# change if non default setup / linux
# if having issues with this, modify `map_list` below manually
MAPS_PATH: str = "C:\\Program Files (x86)\\StarCraft II\\Maps"
MAPS_PATH: str = "D:\\StarCraft II\\Maps"
CONFIG_FILE: str = "config.yml"
MAP_FILE_EXT: str = "SC2Map"
MY_BOT_NAME: str = "MyBotName"
MY_BOT_RACE: str = "MyBotRace"

class DummyBot(BotAI):
def __init__(self):
super().__init__()

async def on_step(self, iteration: int):
target = self.game_info.map_center
if self.enemy_start_locations:
target = self.enemy_start_locations[0]
elif self.enemy_structures:
target = self.enemy_structures.first.position
for unit in self.units.idle:
unit.attack(target)


def main():
bot_name: str = "MyBot"
race: Race = Race.Random
race: Race = Race.Protoss

__user_config_location__: str = path.abspath(".")
user_config_path: str = path.join(__user_config_location__, CONFIG_FILE)
Expand All @@ -42,7 +57,9 @@ def main():
if MY_BOT_RACE in config:
race = Race[config[MY_BOT_RACE].title()]

bot1 = Bot(race, MyBot(), bot_name)
bot1 = Bot(race, AnglerBot(), bot_name)
bot2 = Bot(Race.Random, DummyBot())


if "--LadderServer" in sys.argv:
# Ladder game started by LadderManager
Expand All @@ -52,27 +69,18 @@ def main():
else:
# Local game
map_list: List[str] = [
p.name.replace(f".{MAP_FILE_EXT}", "")
for p in Path(MAPS_PATH).glob(f"*.{MAP_FILE_EXT}")
if p.is_file()
"PlateauMicro_1",
"BotMicroArena_6",
]
# alternative example code if finding the map path is problematic
# map_list: List[str] = [
# "BerlingradAIE",
# "InsideAndOutAIE",
# "MoondanceAIE",
# "StargazersAIE",
# "WaterfallAIE",
# "HardwireAIE",
# ]


random_race = random.choice([Race.Zerg, Race.Terran, Race.Protoss])
print("Starting local game...")
run_game(
maps.get(random.choice(map_list)),
[
bot1,
Computer(random_race, Difficulty.CheatVision, ai_build=AIBuild.Macro),
bot2,
],
realtime=False,
)
Expand Down

0 comments on commit a8c800f

Please sign in to comment.