Validate Termination Position
validate_termination_position.RdChecks if a position is valid for termination (has at least one black neighbor or is the initial center pixel). Used in async mode to prevent isolated pixels when workers operate on stale grid snapshots.
Details
A termination position is valid if:
The position itself is already black (touching black), OR
The position has at least one black neighbor
This prevents the creation of isolated black pixels in async mode where workers may have stale grid snapshots.
Examples
grid <- initialize_grid(10)
#> INFO [2026-02-03 16:36:10] Initializing grid of size 10x10
# Center (5,5) is black, so (5,6) has a black neighbor
validate_termination_position(c(5, 6), grid, "4-hood") # TRUE
#> [1] TRUE
# Position (1,1) is far from center - no black neighbors
validate_termination_position(c(1, 1), grid, "4-hood") # FALSE
#> [1] FALSE