so pathArray[currentPosition][endingPosition]=nextDirection?
wouldnt a 3d array also work, where the first two r like urs and the last one is the cells it has to pass.

(i hope ur getting that im trying to get u to reveale a little bit before the article is done )