I make a program that solves the puzzle, and finds all possible movements on the board and puts all possible resulting boards in the object. Then he finds all possible steps for the resulting boards, etc. The object will look something like this:
{ "board": { "starts": [[0,0],[0,3]], "blocks": [[3,0],[3,3]], "ends": [[2,4]] }, "possibleMoves": [ { "board": { "starts": [[0,0],[2,3]], "blocks": [[3,0],[3,3]], "ends": [[2,4]] }, "possibleMoves":[ { "board": {}, "possibleMoves": [{}] } ] }, { "board": { "starts": [[0,3]], "blocks": [[3,0],[3,3]], "ends": [[2,4]] }, "possibleMoves":[{}] }] }
I can understand how to add possible moves from the top-level board, but I canβt understand how to sort through all the boards received at the second level and calculate their possible moves, and then scroll through all the boards of the third level, etc. How can I add possible movements and cross an object using a width search?