()
| 67 | }; |
| 68 | |
| 69 | const getRandomGrid = () => { |
| 70 | let grid = [ |
| 71 | [1, 2, 3, 4], |
| 72 | [5, 6, 7, 8], |
| 73 | [9, 10, 11, 12], |
| 74 | [13, 14, 15, 0], |
| 75 | ]; |
| 76 | |
| 77 | //Shuffle |
| 78 | let blankBox = new Box(3, 3); |
| 79 | for (let i = 0; i < 1000; i++) { |
| 80 | const randomNextdoorBox = blankBox.getRandomNextdoorBox(); |
| 81 | swapBoxes(grid, blankBox, randomNextdoorBox); |
| 82 | blankBox = randomNextdoorBox; |
| 83 | } |
| 84 | |
| 85 | if (isSolved(grid)) return getRandomGrid(); |
| 86 | return grid; |
| 87 | }; |
| 88 | |
| 89 | class State { |
| 90 | constructor(grid, move, time, status) { |
no test coverage detected