Execute Walker Step (Worker)
worker_step_walker.RdExecutes one step of a walker using cached grid state. This is the main work function executed by crew workers.
Usage
worker_step_walker(
walker,
grid_state,
worker_state,
neighborhood = "4-hood",
boundary = "terminate",
max_steps = 10000L
)Arguments
- walker
List. Walker object (from
create_walker()).- grid_state
List. Contains grid matrix and black_pixels set.
- worker_state
List. Worker state from
worker_init().- neighborhood
Character. "4-hood" or "8-hood" (default: "4-hood").
- boundary
Character. "terminate" or "wrap" (default: "terminate").
- max_steps
Integer. Maximum steps before forced termination (default: 10000).
Details
Performs one iteration of the random walk:
Check for grid updates (refresh cache)
Move walker one step using
step_walker()Check termination using cached black pixels
The worker uses its local cache of black pixels to check termination conditions. This avoids querying the main process on every step, significantly reducing synchronization overhead.
Cache staleness is acceptable because:
Random walks are stochastic (small delays don't affect statistical properties)
Updates are broadcast immediately when walkers terminate
Worker checks for updates before each step