There have a 9x9 cell board (2d-array) with different color balls. Player can move a ball from one cell to another cell. The ball can move with a path which is no ball on the cell between the current cell and destination cell.
I only think I have to use recurrence in implement this path checking. But I don't know how to achieve this function.
I had try to implement the function. But I know it will cause infinitely loop.
bool board::moveCheck(int x1, int y1, int x2, int y2)
{
if(x1==x2&&y1==y2)
return true;
else if(y1-1>=0)
board::moveCheck(x1,y1-1,x2,y2);
else if(y1+1<9)
board::moveCheck(x1,y1+1,x2,y2);
else if(x1-1>=0)
board::moveCheck(x1-1,y1+1,x2,y2);
else if(x1+1<9)
board::moveCheck(x1+1,y1+1,x2,y2);
else
return false;
}