3.2.7 获取未走过的方向的“下一个点”
如果某些方向的“下一个点”已经走过且是“断路”,此时要取另外方向的“下一个点”进行判断。实现该功能的函数是getNext,该函数的参数是“当前站立点”,返回值是未走过的方向的“下一个点”。
MStackElem getNext(MStackElem cur) {
MStackElem next;
next.x = next.y = next.val = -1;
if (getEast(cur).val != 0 && unPass(path, getEast(cur))) {
next = getEast(cur);
}
else if (getSouth(cur).val != 0 && unPass(path, getSouth(cur))) {
next = getSouth(cur);
}
else if (getWest(cur).val != 0 && unPass(path, getWest(cur))) {
next = getWest(cur);
}
else if (getNorth(cur).val != 0 && unPass(path, getNorth(cur))) {
next = getN