I need to create an experiment that creates a foil, or a similar stimulus that has a constant change. In my case, I need to take the output from a Self-Avoiding Walk Algorithm 5x5 matrix and move two cells of this path in a way that does not "break" the walking path or create dead ends. In the image below, I would like to keep [0][0] unchanged as entering path, and then [1][0] would remain unchanged as it would break the path, [2][0] would remain unchanged to avoid making [3][0] a dead end, but then [3][0] could be moved to (2)(1) and (3)(2) could be changed to (4)(1)
Any pointers to how I could solve this problem?
Here is the JS Fiddle with generating this matrix: http://jsfiddle.net/eg86hkm7/1/
// Adding this code just because SO makes me do it to post a JSFiddle