Generating a foil from Self-Avoiding Walk in 5x5 matrix

73 Views Asked by At

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/

Original Matrix with proposed changes

Result - Foil with 2 block changes that keep the path continuous and without dead ends

// Adding this code just because SO makes me do it to post a JSFiddle

0

There are 0 best solutions below