Skip to content

Commit f323c1e

Browse files
author
Shawn Toubeau
authored
Merge pull request #83 from path2finding/bug/various-fixes
Size change and endpoint movement bugs
2 parents a29608e + 3814667 commit f323c1e

File tree

4 files changed

+10
-19
lines changed

4 files changed

+10
-19
lines changed

src/components/Maze/Maze.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.Maze {
2-
height: 90vh !important;
2+
height: calc(100vh - 119px) !important;
33
// Tempt style for debugging
44
}

src/components/Maze/Maze.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,11 @@ const Maze: React.FC<Props> = (props) => {
312312
dfsStack,
313313
} = props.maze;
314314

315-
// console.log(selectedAlgo);
316315
if (selectedAlgo === "BFS") {
317316
let queue = bfsQueue;
318317
// This gets run once at the start
319318
if (isPlaying && queue.length === 0) {
320-
console.log("Init BFS");
319+
// console.log("Init BFS");
321320
const start = getStart(mazeInfo);
322321

323322
if (start) {
@@ -327,7 +326,7 @@ const Maze: React.FC<Props> = (props) => {
327326

328327
setTimeout(function () {
329328
if (queue.length > 0 && isPlaying) {
330-
console.log("Going through BFS", queue);
329+
// console.log("Going through BFS", queue);
331330

332331
// Removes any queued spaces that were previously visited
333332
while (mazeInfo[queue[0].y][queue[0].x].visited) {
@@ -362,7 +361,7 @@ const Maze: React.FC<Props> = (props) => {
362361
let stack = dfsStack;
363362
// This gets run once at the start
364363
if (isPlaying && stack.length === 0) {
365-
console.log("Init DFS");
364+
// console.log("Init DFS");
366365
const start = getStart(mazeInfo);
367366

368367
if (start) {
@@ -405,7 +404,7 @@ const Maze: React.FC<Props> = (props) => {
405404

406405
// Run at the beginning
407406
if (isPlaying && openSet.length === 0) {
408-
console.log("Init Astar");
407+
// console.log("Init Astar");
409408
const start = getStart(mazeInfo);
410409

411410
if (start) {
@@ -415,15 +414,14 @@ const Maze: React.FC<Props> = (props) => {
415414

416415
setTimeout(function () {
417416
if (isPlaying && openSet.length > 0) {
418-
console.log("Running Astar");
417+
// console.log("Running Astar");
419418
let newMazeInfo = mazeInfo;
420419
let current = getLowestFScore(openSet, mazeInfo);
421420
const end = getEnd(mazeInfo) as Coord;
422421

423422
// Check if finished
424423
if (includesCoord(closedSet, end)) {
425424
// Find the Path
426-
console.log("DONE");
427425
handlePauseVisualization();
428426
// openSet = [];
429427
return;
@@ -466,15 +464,13 @@ const Maze: React.FC<Props> = (props) => {
466464
neighborSpace.h = heuristic(neighbor, end);
467465
}
468466
neighborSpace.f = neighborSpace.g + neighborSpace.h;
469-
console.log("Setting parent of ", neighbor, current);
470467
neighborSpace.parent = current;
471468
}
472469
});
473470

474471
progressAstar(openSet, closedSet, newMazeInfo, end);
475472
}
476473
} else {
477-
console.log("NO SOLUTION");
478474
if (isPlaying) handlePauseVisualization();
479475
return;
480476
}
@@ -485,7 +481,7 @@ const Maze: React.FC<Props> = (props) => {
485481

486482
// Run at the beginning
487483
if (isPlaying && openSet.length === 0) {
488-
console.log("Init Djikstras");
484+
// console.log("Init Djikstras");
489485
const start = getStart(mazeInfo);
490486

491487
if (start) {
@@ -495,15 +491,14 @@ const Maze: React.FC<Props> = (props) => {
495491

496492
setTimeout(function () {
497493
if (isPlaying && openSet.length > 0) {
498-
console.log("Running Djikstras");
494+
// console.log("Running Djikstras");
499495
let newMazeInfo = mazeInfo;
500496
let current = getLowestFScore(openSet, mazeInfo);
501497
const end = getEnd(mazeInfo) as Coord;
502498

503499
// Check if finished
504500
if (includesCoord(closedSet, end)) {
505501
// Find the Path
506-
console.log("DONE");
507502
handlePauseVisualization();
508503
// openSet = [];
509504
return;
@@ -547,15 +542,13 @@ const Maze: React.FC<Props> = (props) => {
547542
neighborSpace.h = heuristic_djikstras(neighbor, end);
548543
}
549544
neighborSpace.f = neighborSpace.g + neighborSpace.h;
550-
console.log("Setting parent of ", neighbor, current);
551545
neighborSpace.parent = current;
552546
}
553547
});
554548

555549
progressAstar(openSet, closedSet, newMazeInfo, end);
556550
}
557551
} else {
558-
console.log("NO SOLUTION");
559552
if (isPlaying) handlePauseVisualization();
560553
return;
561554
}

src/components/Menu/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class MenuBar extends React.Component<MenuProps, _MenuState> {
257257
disabled={isPlaying}
258258
>
259259
<Icon
260-
name={canMoveStart ? "circle" : "circle outline"}
260+
name={canMoveEnd ? "circle" : "circle outline"}
261261
style={{ marginRight: "0.5rem" }}
262262
/>
263263
<span>Move End Point</span>

src/models/maze/initialState.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ export const generateMaze = (
88
clear?: boolean
99
): MazeInfo => {
1010
let maze: MazeInfo = {};
11-
if(x > 20) x = 20;
12-
if(y > 20) y = 20;
1311

1412
for (let i = 0; i < x; i++) {
1513
maze[i] = [];
@@ -55,5 +53,5 @@ export const initialState: Maze = {
5553
bfsQueue: [],
5654
astarOpenSet: [],
5755
astarClosedSet: [],
58-
dfsStack: []
56+
dfsStack: [],
5957
};

0 commit comments

Comments
 (0)