-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from FredNoonienSingh/restucture_for_ladder
Restucture for ladder
- Loading branch information
Showing
52 changed files
with
175 additions
and
12,075 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
4,561 changes: 0 additions & 4,561 deletions
4,561
...msAunt/data/HarstemsAunt_0.1_vsRace.Zerg_at_2024-12-02 16:21:22.478829_Result.Victory.csv
This file was deleted.
Oops, something went wrong.
3,602 changes: 0 additions & 3,602 deletions
3,602
...msAunt/data/HarstemsAunt_0.1_vsRace.Zerg_at_2024-12-02 17:38:03.460830_Result.Victory.csv
This file was deleted.
Oops, something went wrong.
3,876 changes: 0 additions & 3,876 deletions
3,876
...msAunt/data/HarstemsAunt_0.1_vsRace.Zerg_at_2024-12-02 17:49:35.870425_Result.Victory.csv
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# pylint: disable=W0212 | ||
import argparse | ||
import asyncio | ||
|
||
import aiohttp | ||
from loguru import logger | ||
|
||
import sc2 | ||
from sc2.client import Client | ||
from sc2.protocol import ConnectionAlreadyClosed | ||
|
||
|
||
# Run ladder game | ||
# This lets python-sc2 connect to a LadderManager game: https://github.com/Cryptyc/Sc2LadderServer | ||
# Based on: https://github.com/Dentosal/python-sc2/blob/master/examples/run_external.py | ||
def run_ladder_game(bot): | ||
# Load command line arguments | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--GamePort", type=int, nargs="?", help="Game port") | ||
parser.add_argument("--StartPort", type=int, nargs="?", help="Start port") | ||
parser.add_argument("--LadderServer", type=str, nargs="?", help="Ladder server") | ||
parser.add_argument("--ComputerOpponent", type=str, nargs="?", help="Computer opponent") | ||
parser.add_argument("--ComputerRace", type=str, nargs="?", help="Computer race") | ||
parser.add_argument("--ComputerDifficulty", type=str, nargs="?", help="Computer difficulty") | ||
parser.add_argument("--OpponentId", type=str, nargs="?", help="Opponent ID") | ||
parser.add_argument("--RealTime", action="store_true", help="Real time flag") | ||
args, _unknown = parser.parse_known_args() | ||
|
||
if args.LadderServer is None: | ||
host = "127.0.0.1" | ||
else: | ||
host = args.LadderServer | ||
|
||
host_port = args.GamePort | ||
lan_port = args.StartPort | ||
|
||
# Add opponent_id to the bot class (accessed through self.opponent_id) | ||
bot.ai.opponent_id = args.OpponentId | ||
|
||
realtime = args.RealTime | ||
|
||
# Port config | ||
if lan_port is None: | ||
portconfig = None | ||
else: | ||
ports = [lan_port + p for p in range(1, 6)] | ||
|
||
portconfig = sc2.portconfig.Portconfig() | ||
portconfig.server = [ports[1], ports[2]] | ||
portconfig.players = [[ports[3], ports[4]]] | ||
|
||
# Join ladder game | ||
g = join_ladder_game(host=host, port=host_port, players=[bot], realtime=realtime, portconfig=portconfig) | ||
|
||
# Run it | ||
result = asyncio.get_event_loop().run_until_complete(g) | ||
return result, args.OpponentId | ||
|
||
|
||
# Modified version of sc2.main._join_game to allow custom host and port, and to not spawn an additional sc2process (thanks to alkurbatov for fix) | ||
async def join_ladder_game(host, port, players, realtime, portconfig, save_replay_as=None, game_time_limit=None): | ||
ws_url = f"ws://{host}:{port}/sc2api" | ||
ws_connection = await aiohttp.ClientSession().ws_connect(ws_url, timeout=120) | ||
client = Client(ws_connection) | ||
try: | ||
result = await sc2.main._play_game(players[0], client, realtime, portconfig, game_time_limit) | ||
if save_replay_as is not None: | ||
await client.save_replay(save_replay_as) | ||
# await client.leave() | ||
# await client.quit() | ||
except ConnectionAlreadyClosed: | ||
logger.error("Connection was closed before the game ended") | ||
return None | ||
finally: | ||
ws_connection.close() | ||
|
||
return result |
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+1.36 KB
.../__pycache__/build_supply.cpython-312.pyc → .../__pycache__/build_supply.cpython-312.pyc
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+2.72 KB
..._pycache__/infrastructure.cpython-312.pyc → ..._pycache__/infrastructure.cpython-312.pyc
Binary file not shown.
Binary file renamed
BIN
+2.25 KB
...macro/__pycache__/upgrade.cpython-312.pyc → macro/__pycache__/upgrade.cpython-312.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
from sc2.bot_ai import BotAI | ||
from sc2.ids.unit_typeid import UnitTypeId | ||
from actions.build_army import \ | ||
build_gateway_units, build_stargate_units, build_robo_units | ||
build_gateway_units, build_stargate_units | ||
|
||
async def build_army(bot:BotAI) -> None: | ||
if len(bot.units(UnitTypeId.STALKER)) > 20: | ||
await build_gateway_units(bot, UnitTypeId.ZEALOT) | ||
await build_gateway_units(bot, UnitTypeId.STALKER) | ||
await build_stargate_units(bot, UnitTypeId.PHOENIX) | ||
await build_gateway_units(bot, UnitTypeId.STALKER) | ||
await build_stargate_units(bot, UnitTypeId.PHOENIX) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Harstems Aunt | ||
|
||
### What is Harstems Aunt ? | ||
|
||
Harstems Aunt is a StarCraft AI written for the AI Ladder on https://aiarena.net/. It is still under active development at the moment it is building Stalkers, Zealots and Phoenixes. | ||
|
||
### How to run locally: | ||
|
||
Download StarCraft 2 and the Maps from https://aiarena.net/wiki/maps/. | ||
|
||
Then run: | ||
```zsh | ||
pip install -e . | ||
``` | ||
inside the Bot directory after cloning the repository. | ||
|
||
### Next Steps | ||
|
||
Fixing the positioning of Buildings and improvements to the unit control. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
from random import choice | ||
from HarstemsAunt.main import HarstemsAunt | ||
from HarstemsAunt.common import MAP_LIST | ||
|
||
import sys | ||
|
||
from __init__ import run_ladder_game | ||
|
||
from sc2 import maps | ||
from sc2.data import Difficulty, Race | ||
from sc2.main import run_game | ||
from sc2.player import Bot, Computer | ||
|
||
bot = Bot(Race.Protoss, HarstemsAunt()) | ||
|
||
# Start game | ||
if __name__ == "__main__": | ||
if "--LadderServer" in sys.argv: | ||
# Ladder game started by LadderManager | ||
print("Starting ladder game...") | ||
result, opponentid = run_ladder_game(bot) | ||
print(result, " against opponent ", opponentid) | ||
else: | ||
# Local game | ||
print("Starting local game...") | ||
run_game(maps.get(choice(MAP_LIST)), [bot, Computer(Race.Protoss, Difficulty.CheatInsane)], realtime=False, sc2_version="5.0.10") |
Empty file.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.