Skip to content

Commit c4a2bd0

Browse files
committed
Recursive backtracking working
1 parent 7cd46dc commit c4a2bd0

3 files changed

Lines changed: 10 additions & 23 deletions

File tree

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

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {directions} from '../Directions';
2-
import {_FindCellVisitState, _FindCellTypeState, _FindCell, _BoardReset, _GetNeighbors, _SetWalls} from '../Tools';
3-
import exit from 'exit';
1+
import {directions} from '../Directions';
2+
import {_FindCellVisitState, _FindCellTypeState, _FindCell, _BoardReset, _GetNeighbors, _SetWalls, _VisitReset} from '../Tools';
3+
import exit from 'exit';
44
import {PATH_TYPE, DEFAULT_TYPE, FLOOR_TYPE, WALL_TYPE, START_TYPE, GOAL_TYPE} from '../../../../Utility/Colors';
55

66

@@ -32,21 +32,8 @@ export function BinaryTreeCreation(board, start, end) {
3232
let xcord = node.x + directions[direction].x;
3333
let ycord = node.y + directions[direction].y;
3434
const cell = _FindCell(board, xcord, ycord);
35-
// console.log(cell);
36-
// exit();
37-
if (cell) {
38-
// exit();
39-
40-
// const testNeighbor = _GetNeighbors(board, -6, -6);
41-
// if (testNeighbor) {
42-
// testNeighbor.forEach(neighbor => {
43-
// // console.log('Neighbor: ', neighbor);
44-
// neighbor.type = PATH_TYPE;
45-
// });
46-
// }
47-
// return;
48-
4935

36+
if (cell) {
5037
if (!cell.visited && cell.type !== START_TYPE && cell.type !== GOAL_TYPE) {
5138
// console.log(cell);
5239
cell.visited = true;
@@ -56,7 +43,6 @@ export function BinaryTreeCreation(board, start, end) {
5643
}
5744

5845
_SetWalls(board);
59-
60-
46+
_VisitReset(board);
6147
}
6248

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export function GrowingTreeCreation(board, start, end) {
4242
for (let i = 0; i < neighbors.length; i++) {
4343
const neighbor = neighbors[i];
4444
if (visited.has(neighbor) === false) {
45-
// neighbor.type = FLOOR_TYPE;
4645
queue.enqueue(neighbor);
4746
}
4847
}

‎src/components/BoardCanvas/OrbitControls.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const OrbitControls = ({board, selectedPoint, onSelectedPoint}, ref) => {
1818

1919
// Set up the camera on mount.
2020
useEffect(() => {
21-
camera.position.set(0, -10, 50); // Initial camera position
21+
// camera.position.set(0, -10, 50); // Initial camera position
22+
camera.position.set(0, 0, 50);
2223
camera.lookAt(0, -10, 50);
2324
}, [camera]);
2425

@@ -52,8 +53,9 @@ const OrbitControls = ({board, selectedPoint, onSelectedPoint}, ref) => {
5253
resetCamera: () => {
5354
// reset look-at (target) and camera position
5455
controls.current.target.set(0, 0, 0);
55-
camera.position.set(0, 0, 80);
56-
56+
// camera.position.set(0, 0, 80);
57+
camera.position.set(0, 0, 50);
58+
camera.lookAt(0, -10, 50);
5759
// needed for trackball controls, reset the up vector
5860
camera.up.set(
5961
controls.current.up0.x,

0 commit comments

Comments
 (0)