Skip to content

Commit 46cdfad

Browse files
committed
Recursive backtracking somewhat working
1 parent e67b341 commit 46cdfad

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎src/components/Algorithms/Maze/Generation/RecursiveBacktrackCreation.js‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {directions} from '../Directions';
22
import {_FindCellVisitState, _FindCellTypeState, _FindCell, _BoardReset, _GetNeighbors, _SetWalls, _GetNeighborsCell, _BoardResetWalled} from '../Tools';
33
import exit from 'exit';
4-
import {PATH_TYPE, DEFAULT_TYPE, FLOOR_TYPE, WALL_TYPE, START_TYPE, GOAL_TYPE} from '../../../../Utility/Colors';
5-
import {PriorityQueue} from '../../../../Utility/PriorityQueue.js';
4+
import {PATH_TYPE, DEFAULT_TYPE, FLOOR_TYPE, WALL_TYPE, START_TYPE, GOAL_TYPE} from '../../../../Utility/Colors';
5+
import {PriorityQueue} from '../../../../Utility/PriorityQueue.js';
66

77

88

@@ -19,15 +19,16 @@ export function RecursiveBacktrackCreation(board, start, end) {
1919
console.log('End: ' + endCell.id + ' (' + endCell.x + ' | ' + endCell.y + ')');
2020

2121
startCell.visited = true;
22-
carvePath(board, startCell, false);
22+
carvePath(board, startCell);
2323

2424
// _SetWalls(board);
2525

2626

2727
}
2828

2929

30-
function carvePath(board, cell, found) {
30+
function carvePath(board, cell) {
31+
let found = false;
3132
const neighbors = _GetNeighborsCell(board, cell);
3233
if (neighbors.length === 0) {
3334
console.log('No neighbors found for cell: ' + cell.id + ' (' + cell.x + ' | ' + cell.y + ')');
@@ -43,7 +44,7 @@ function carvePath(board, cell, found) {
4344
}
4445
neighbor.visited = true;
4546
neighbor.type = FLOOR_TYPE;
46-
found = carvePath(board, neighbor, found);
47+
found = carvePath(board, neighbor);
4748
if (found) {
4849
return found;
4950
}

0 commit comments

Comments
 (0)