Skip to content

Commit

Permalink
ksajld
Browse files Browse the repository at this point in the history
  • Loading branch information
strakam committed Jan 18, 2025
1 parent 5fe83c6 commit b069c43
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions generals/core/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ def create_distance_mask(distances, max_distance):
g2 = None
for _ in range(max_attempts):
candidate_g2 = (self.rng.integers(grid_height), self.rng.integers(grid_width))
if distances_from_g1[candidate_g2] >= min_generals_distance and distances_from_g1[candidate_g2] != float("inf"):
if distances_from_g1[candidate_g2] >= min_generals_distance and distances_from_g1[candidate_g2] != float(
"inf"
):
g2 = candidate_g2
break

if g2 is None:
# If we couldn't place g2 after max attempts, start over with a new grid
return self.generate_generalsio_grid()
Expand All @@ -203,7 +205,6 @@ def create_distance_mask(distances, max_distance):
# Randomly select one position from the valid positions
idx = self.rng.integers(0, len(valid_positions[0]))
city_pos = (valid_positions[0][idx], valid_positions[1][idx])

# Generate city value (0 - 9 or 'x')
city_cost = self.rng.choice([str(i) for i in range(10)] + ["x"])
map[city_pos] = city_cost
Expand Down

0 comments on commit b069c43

Please sign in to comment.