Skip to content

Commit

Permalink
Merge pull request #201 from AresSC2/feat/placements
Browse files Browse the repository at this point in the history
feat: building placements set per enemy race
  • Loading branch information
raspersc2 authored Dec 22, 2024
2 parents 18534e4 + f7bc0d6 commit ad981f7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
9 changes: 8 additions & 1 deletion docs/tutorials/custom_building_placements.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ into this file like below.
Protoss:
AbyssalReef:
VsZergNatWall:
AvailableVsRaces: ["Zerg", "Random"]
UpperSpawn:
FirstPylon: [[64., 105.]]
Pylons: [[63., 112.]]
Expand All @@ -32,6 +33,7 @@ Protoss:
GateKeeper: [[137.25, 38.6]]
Acropolis:
VsZergNatWall:
AvailableVsRaces: ["Zerg", "Random"]
UpperSpawn:
FirstPylon: [ [ 35., 109. ] ]
Pylons: [ [ 32., 109. ] ]
Expand All @@ -42,10 +44,11 @@ Protoss:
FirstPylon: [ [ 141., 63. ] ]
Pylons: [ [ 144., 63. ] ]
ThreeByThrees: [ [ 137.5, 66.5 ], [ 141.5, 66.5 ], [ 144.5, 66.5 ] ]
StaticDefences: [ [ 137., 64. ] ]
StaticDefences: [ [ 137., 63. ] ]
GateKeeper: [ [ 139.3, 67.4 ] ]
Automaton:
VsZergNatWall:
AvailableVsRaces: ["Zerg", "Random"]
UpperSpawn:
FirstPylon: [ [ 141., 139. ] ]
Pylons: [ [ 140., 142. ] ]
Expand All @@ -60,6 +63,7 @@ Protoss:
GateKeeper: [ [ 47.15, 45.3 ] ]
Ephemeron:
VsZergNatWall:
AvailableVsRaces: ["Zerg", "Random"]
UpperSpawn:
FirstPylon: [ [ 37., 112. ] ]
Pylons: [ [ 37., 109. ] ]
Expand All @@ -74,6 +78,7 @@ Protoss:
GateKeeper: [ [ 119.7, 47.4 ] ]
Interloper:
VsZergNatWall:
AvailableVsRaces: ["Zerg", "Random"]
UpperSpawn:
FirstPylon: [ [ 31., 112. ] ]
Pylons: [ [ 31., 109. ] ]
Expand All @@ -88,6 +93,7 @@ Protoss:
GateKeeper: [ [ 115.78, 55.75 ] ]
Thunderbird:
VsZergNatWall:
AvailableVsRaces: ["Zerg", "Random"]
UpperSpawn:
FirstPylon: [ [ 46., 106. ] ]
Pylons: [ [ 46., 103. ] ]
Expand All @@ -101,6 +107,7 @@ Protoss:
StaticDefences: [ [ 144., 48. ] ]
GateKeeper: [ [ 138.64, 48.49 ] ]


```

The values shown above are the default settings in ares, so there's no need to
Expand Down
8 changes: 7 additions & 1 deletion src/ares/building_placements.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Protoss:
AbyssalReef:
VsZergNatWall:
AvailableVsRaces: ["Zerg", "Random"]
UpperSpawn:
FirstPylon: [[64., 105.]]
Pylons: [[63., 112.]]
Expand All @@ -15,6 +16,7 @@ Protoss:
GateKeeper: [[137.25, 38.6]]
Acropolis:
VsZergNatWall:
AvailableVsRaces: ["Zerg", "Random"]
UpperSpawn:
FirstPylon: [ [ 35., 109. ] ]
Pylons: [ [ 32., 109. ] ]
Expand All @@ -25,10 +27,11 @@ Protoss:
FirstPylon: [ [ 141., 63. ] ]
Pylons: [ [ 144., 63. ] ]
ThreeByThrees: [ [ 137.5, 66.5 ], [ 141.5, 66.5 ], [ 144.5, 66.5 ] ]
StaticDefences: [ [ 137., 64. ] ]
StaticDefences: [ [ 137., 63. ] ]
GateKeeper: [ [ 139.3, 67.4 ] ]
Automaton:
VsZergNatWall:
AvailableVsRaces: ["Zerg", "Random"]
UpperSpawn:
FirstPylon: [ [ 141., 139. ] ]
Pylons: [ [ 140., 142. ] ]
Expand All @@ -43,6 +46,7 @@ Protoss:
GateKeeper: [ [ 47.15, 45.3 ] ]
Ephemeron:
VsZergNatWall:
AvailableVsRaces: ["Zerg", "Random"]
UpperSpawn:
FirstPylon: [ [ 37., 112. ] ]
Pylons: [ [ 37., 109. ] ]
Expand All @@ -57,6 +61,7 @@ Protoss:
GateKeeper: [ [ 119.7, 47.4 ] ]
Interloper:
VsZergNatWall:
AvailableVsRaces: ["Zerg", "Random"]
UpperSpawn:
FirstPylon: [ [ 31., 112. ] ]
Pylons: [ [ 31., 109. ] ]
Expand All @@ -71,6 +76,7 @@ Protoss:
GateKeeper: [ [ 115.78, 55.75 ] ]
Thunderbird:
VsZergNatWall:
AvailableVsRaces: ["Zerg", "Random"]
UpperSpawn:
FirstPylon: [ [ 46., 106. ] ]
Pylons: [ [ 46., 103. ] ]
Expand Down
1 change: 1 addition & 0 deletions src/ares/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@


class BuildingPlacementOptions(str, Enum):
AVAILABLE_VS_RACES = "AvailableVsRaces"
LOWER_SPAWN = "LowerSpawn"
UPPER_SPAWN = "UpperSpawn"
VS_ZERG_NAT_WALL = "VsZergNatWall"
Expand Down
15 changes: 15 additions & 0 deletions src/ares/managers/placement_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,21 @@ def normalize_map_name(_map_name: str) -> str:
):
for building_type in placements:
if building_type == BuildingPlacementOptions.VS_ZERG_NAT_WALL:
if (
BuildingPlacementOptions.AVAILABLE_VS_RACES
in placements[building_type]
):
races: set[str] = {
race
for race in placements[building_type][
BuildingPlacementOptions.AVAILABLE_VS_RACES
]
}

if not any(
[race in self.ai.enemy_race.name for race in races]
):
continue

upper_spawn: bool = (
self.ai.start_location.y
Expand Down

0 comments on commit ad981f7

Please sign in to comment.