Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crafter/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ def _tint(self, canvas, color, amount):
return (1 - amount) * canvas + amount * color

def _noise(self, canvas, amount, stddev):
noise = self._world.random.uniform(32, 127, canvas.shape[:2])[..., None]
state = self._world.random.get_state()
random = np.random.RandomState()
random.set_state(state)
noise = random.uniform(32, 127, canvas.shape[:2])[..., None]
mask = amount * self._vignette(canvas.shape, stddev)[..., None]
return (1 - mask) * canvas + mask * noise

Expand Down
1 change: 1 addition & 0 deletions crafter/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def _balance_object(
xmin, xmax, ymin, ymax = chunk
random = self._world.random
creatures = [obj for obj in objs if isinstance(obj, cls)]
creatures.sort(key=(lambda x: tuple(x.pos)))
mask = self._world.mask(*chunk, material)
target_min, target_max = target_fn(len(creatures), mask.sum())
if len(creatures) < int(target_min) and random.uniform() < spawn_prob:
Expand Down