Skip to content

Commit 2f08fcd

Browse files
authored
Merge pull request #175 from raspersc2/fix/terrain-height-check-for-expansion-locations
2 parents 6247cd4 + f6f007a commit 2f08fcd

7 files changed

Lines changed: 6 additions & 0 deletions

File tree

sc2/bot_ai_internal.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,19 @@ def _find_expansion_locations(self):
185185
]
186186
# Loop the merging process as long as we change something
187187
merged_group = True
188+
height_grid: PixelMap = self.game_info.terrain_height
188189
while merged_group:
189190
merged_group = False
190191
# Check every combination of two groups
191192
for group_a, group_b in itertools.combinations(resource_groups, 2):
192193
# Check if any pair of resource of these groups is closer than threshold together
194+
# And that they are on the same terrain level
193195
if any(
194196
resource_a.distance_to(resource_b) <= resource_spread_threshold
197+
# check if terrain height measurement at resources is within 10 units
198+
# this is since some older maps have inconsistent terrain height
199+
# tiles at certain expansion locations
200+
and abs(height_grid[resource_a.position.rounded] - height_grid[resource_b.position.rounded]) <= 10
195201
for resource_a, resource_b in itertools.product(group_a, group_b)
196202
):
197203
# Remove the single groups and add the merged group

test/pickle_data/AltitudeAIE.xz

55.6 KB
Binary file not shown.
55 KB
Binary file not shown.

test/pickle_data/BabylonAIE.xz

55 KB
Binary file not shown.

test/pickle_data/GoldenauraAIE.xz

55.3 KB
Binary file not shown.
54.6 KB
Binary file not shown.

test/pickle_data/RoyalBloodAIE.xz

55.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)