The answer lies in the random number generation and what the tests are doing.
1. Random number generation: if you so the following:
set.seed(10)
a1 <- rnorm(10)
b <- sample(1)
a2 <- rnorm(10)
# Second
set.seed(10)
b1 <- rnorm(10)
b2 <- rnorm(10)
# what is this, TRUE or FALSE?
all.equal(a2, b2)
-- it's FALSE because we drew a single random draw with the "sample", so the two sequences are out of sync, so , a2 is not b2.
2. The tests: The only ones you showed were ones that were very much dependent on the random number sequence... specifically, numRetries is a column that indicates how many times an active pixel "tries" to spread to another pixel, but fails because of things like there being no neighbouring cell that is available to spread to. This would happen randomly sometimes, so the exact sequence or random numbers matters for "numRetries".
Setting persistProb is causing a new generation of random draws that didn't exist before, so any test that is dependent on the random number generator will fail.
In this case, assuming that there is no breakage in the behaviour, the solution is to change the test criteria so that it passes, given the new code pieces.
Another solution is to avoid the random number generator in the code:
if (persistProb > 0) {
the stuff to do
}
if you add a single random number generation to a sequence