块的左边一块开始搜索checkPathRi
dex01i
dex130pathi
dex0这一块的右边一块开始搜索如果其中一个方向开始的遍历路径成功连接到i
dex1的话返回成功,则两块就成功连通staticboolea
checkPathRi
ti
dex0i
ti
dex1i
tdi
ttStackI
tegerpath(第一次搜索的块,目标块,方向,转向次数,保存路径的栈pathpushi
dex0将首块的索引先存入栈ifi
dex0i
dex1第一次搜索的块与目标块的索引相同,代表连通,返回成功。retur
trueiftilesi
dex00如果搜索到的块不空白块,意味着碰到了未消除的块,然后将入栈的路径弹出,并返回失败。pathpopretur
falseswitchd选择转向的方向case0向上ifcheckPathRi
dex014i
dex10tpath调用自身方法,如果成功,继续搜索路径(下一个空白块)。不成功,跳出if语句,开始转向。retur
truetift2如果失败,将存入路径弹出,返回失败pathpopretur
falseifcheckPathRi
dex01i
dex12tpath向左转向,成功返回True,不成功执行下个ifretur
trueifcheckPathRi
dex01i
dex13tpath向右转向,成功返回true,不成功,则代第一次向上的路径没有路可到达目标块i
dex1。失败!retur
truebreakcase1第一次向上搜索路径不成功,向下
7
f《JavaWEB》课程设计
ifcheckPathRi
dex014i
dex11tpathretur
truetift2pathpopretur
falseifcheckPathRi
dex01i
dex12tpathretur
trueifcheckPathRi
dex01i
dex13tpathretur
truebreakcase2第一次向上、下搜索路径不成功,向左ifcheckPathRi
dex01i
dex12tpathretur
truetift2pathpopretur
falseifcheckPathRi
dex014i
dex10tpathretur
trueifcheckPathRi
dex014i
dex11tpathretur
truebreakcase3第一次向上、下、左搜索路径不成功,向右ifcheckPathRi
dex01i
dex13tpathretur
truetift2pathpopretur
falseretur
trueifcheckPathRi
dex014i
dex11tpathretur
truebreakpathpop
ifcheckPathRi
dex014i
dex10tpath
retur
false
主函数中的方法及框架设计
publicstaticvoidmai
Stri
gargsi
itFrameframe
ewFrame