Please help me by refering the Algorithm Name or if you have any good source code to solve the problem
To understand the problem,
Here's some input in JSON Format Correspond with Their Initial Map Picture
{"wallX":[0,2],"wallY":[0,2],"startX":0,"startY":1,"maxX":3,"maxY":3}
{"wallX":[],"wallY":[],"startX":1,"startY":4,"maxX":6,"maxY":6}
The Rules
- 99 represent the wall. X&Y of wall[index] is represent by wallX[index] and wallY[index].
- 01 represent the starting point of the Snake. X&Y of 01 is represent by startX and startY
- maxX represent the column of the 2D array while maxY represent the row of the 2d array. Both maxX and maxY <= 9
- On The initial 2-D Array / Map, any tile which is not 01 or 99 will be Tile 00.
- Snake can only Move to 00
- Snake move 4 ways[left,top,right,bottom]
The input of the program is those JSON format.
The output of the program should be :
- 2-Dimension Array consist of 99 and/or (01 to 0X) with no 00 Tiles left which represent the map is solved
- Initial 2-D Array which represent there is no more possible move left but there is at least 1 of 00
Here's Some other Input Correspond with Their output's 2D Array picture
{"wallX":[0,0,1,2,3,4,5],"wallY":[0,4,5,1,1,1,4],"startX":0,"startY":3,"maxX":6,"maxY":8}
{"wallX":[0,1],"wallY":[0,1],"startX":0,"startY":1,"maxX":2,"maxY":2}
{"wallX":[0,2],"wallY":[0,2],"startX":1,"startY":1,"maxX":3,"maxY":3}
I have made my own source code to solve this problem, but i want to find the algorithm so i can study more on how to actually deal with this/related algorithm/problem.
I tried to search on google, with keyword such as "Fill" but most result showing me [Flood-Fill-Algorithm]. Most Flood Fill that i read, can't be applied here since The Snake or [LastNumber] have to be Adjacent to [LastNumber+1].
I also tried to find about Pathing, but it seems PathFinding works if there is Start and Destination, but this problem doesn't seem have any clear Destination.
Please correct me if im wrong about these ^
Thank you in advance for your help