I don't think that the logic there quite works. Certain results could be ignored (conditional on what has been generated) to make everything divisible by 3.
By not run forever, do you mean that we must be able to fix a time at which the algorithm will certainly have terminated by? If you mean that it just has to end at some point then
What shape is the moat? Does it have to be a straight line? Can it vary in width?
If it can be any shape, just choose a moat in the shape of a very pointy arrow and cross over at the point using 1 board.