Skip to content

Commit

Permalink
The position we find to place items is not necessarily random
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesnyder committed Aug 15, 2023
1 parent b0d4a9f commit e524d66
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions dlgr/griduniverse/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ def spawn_item(self, position=None, item_id=None):
item_id = obj.get("item_id", 1)

if not position:
position = self._random_empty_position(item_id)
position = self._find_empty_position(item_id)

item_props = self.item_config[item_id]
new_item = Item(
Expand Down Expand Up @@ -894,7 +894,7 @@ def spawn_player(self, id=None, **kwargs):
"""Spawn a player."""
player = Player(
id=id,
position=self._random_empty_position(player=True),
position=self._find_empty_position(player=True),
num_possible_colors=self.num_colors,
motion_speed_limit=self.motion_speed_limit,
motion_cost=self.motion_cost,
Expand All @@ -912,9 +912,8 @@ def spawn_player(self, id=None, **kwargs):
self._start_if_ready()
return player

def _random_empty_position(self, item_id=None, player=False):
"""Select an empty cell at random, using the configured probability
distribution."""
def _find_empty_position(self, item_id=None, player=False):
"""Select an empty cell, using the configured probability distribution."""
rows = self.rows
columns = self.columns
empty_cell = False
Expand Down

0 comments on commit e524d66

Please sign in to comment.