이런 스타일 문제를 처음풀어봐서 조금 허접하지만 ^^;;
퍼즐 성공여부만 풀어봤어요
this.map = [[0, 1, 0, 0, 0],[0, 0, 0, 1, 0],[1, 1, 1, 0, 0],[0, 0, 0, 0, 1],[1, 1, 1, 0, 0]];
//this.map = [[0, 0, 0, 0],[1, 0, 1, 1],[1, 1, 0, 1],[0, 0, 0, 0]];
//this.map = [[0, 0, 1],[1, 0, 1],[1, 0, 0]];
this.Button00_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo)
{
var rtn = this.fnCheckGoal(3, 0, 0, 0, 0);
};
this.fnCheckGoal = function(n, x_prev, y_prev, x, y)
{
var rtn1 = rtn2 = rtn3 = rtn4 = 0;
if(x==(n-1)&&y==(n-1))
{
if(this.map[x][y]==0)return 1;
else return 0;
}else
{
if(x+1!=n&&!(x_prev==x+1&&y_prev==y)&&this.map[x+1][y]==0)
{
rtn1 = this.fnCheckGoal(n, x, y, x+1, y);
}
if(x-1!=-1&&!(x_prev==x-1&&y_prev==y)&&this.map[x-1][y]==0)
{
rtn2 = this.fnCheckGoal(n, x, y, x-1, y);
}
if(y-1!=-1&&!(x_prev==x&&y_prev==y-1)&&this.map[x][y-1]==0)
{
rtn3 = this.fnCheckGoal(n, x, y, x, y-1);
}
if((y+1!=n)&&!(x_prev==x&&y_prev==y+1)&&this.map[x][y+1]==0)
{
rtn4 = this.fnCheckGoal(n, x, y, x, y+1);
}
}
if(rtn1 + rtn2 + rtn3 + rtn4 > 0)return 1
else return 0;
}