Animals such as cockroaches depend on exploration of unknown environments, and their strategies may inspire robotic approaches. We have previously shown that cockroach behavior, with respect to shelters and the walls of an otherwise empty arena, can be captured with a stochastic state-based algorithm. We call this algorithm RAMBLER, randomized algorithm mimicking biased lone exploration in roaches. In this work, we verified and extended this model by adding a barrier in the previously used arena and conducted more cockroach experiments. In two arena configurations, our simulated model’s path length distribution was similar to the experimental distribution (mean experimental path length 3.4 and 3.2 m, mean simulated path length 3.9 and 3.3 m). By analyzing cockroach behavior before, along, and at the end of the barrier, we have generalized RAMBLER to address arbitrarily complex 2D mazes. For biology, this is an abstract behavioral model of a decision-making process in the cockroach brain. For robotics, this is a strategy that may improve exploration for goals, especially in unpredictable environments with non-convex obstacles. Generally, cockroach behavior seems to recommend variability in the absence of planning, and following paths defined by walls.