Skip to content

Commit a38f866

Browse files
committed
Deploy React app to GitHub Pages
1 parent dd60ce5 commit a38f866

15 files changed

+991
-55
lines changed

debug.log

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[0405/214836.725:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
2+
[0405/215015.906:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
3+
[0405/215129.413:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
4+
[0405/215226.900:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
5+
[0405/215447.035:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
6+
[0405/215746.561:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
7+
[0405/215830.081:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
8+
[0405/221101.822:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
9+
[0405/221206.300:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
10+
[0405/221412.128:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
11+
[0405/221926.709:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
12+
[0405/222000.405:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
13+
[0405/222038.340:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03
14+
[0405/222132.614:WARNING:minidump_to_upload_parameters.cc(36)] duplicate key guid, discarding value e473a496-b48a-4690-8852-be51dd0c6c03

package-lock.json

+102
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"homepage": "https://nikolatechie.github.io/Pathfinding-Visualizer",
23
"name": "pathfinding-visualizer",
34
"version": "0.1.0",
45
"private": true,
@@ -11,6 +12,8 @@
1112
"react-scripts": "3.4.1"
1213
},
1314
"scripts": {
15+
"predeploy": "npm run build",
16+
"deploy": "gh-pages -d build",
1417
"start": "react-scripts start",
1518
"build": "react-scripts build",
1619
"test": "react-scripts test",
@@ -30,5 +33,8 @@
3033
"last 1 firefox version",
3134
"last 1 safari version"
3235
]
36+
},
37+
"devDependencies": {
38+
"gh-pages": "^2.2.0"
3339
}
3440
}

public/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
work correctly both with client-side routing and a non-root public URL.
2525
Learn how to configure a non-root public URL by running `npm run build`.
2626
-->
27-
<title>React App</title>
27+
<title>Pathfinding Visualizer</title>
2828
</head>
2929
<body>
3030
<noscript>You need to enable JavaScript to run this app.</noscript>

src/App.css

-38
Original file line numberDiff line numberDiff line change
@@ -1,38 +0,0 @@
1-
.App {
2-
text-align: center;
3-
}
4-
5-
.App-logo {
6-
height: 40vmin;
7-
pointer-events: none;
8-
}
9-
10-
@media (prefers-reduced-motion: no-preference) {
11-
.App-logo {
12-
animation: App-logo-spin infinite 20s linear;
13-
}
14-
}
15-
16-
.App-header {
17-
background-color: #282c34;
18-
min-height: 100vh;
19-
display: flex;
20-
flex-direction: column;
21-
align-items: center;
22-
justify-content: center;
23-
font-size: calc(10px + 2vmin);
24-
color: white;
25-
}
26-
27-
.App-link {
28-
color: #61dafb;
29-
}
30-
31-
@keyframes App-logo-spin {
32-
from {
33-
transform: rotate(0deg);
34-
}
35-
to {
36-
transform: rotate(360deg);
37-
}
38-
}

src/App.js

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
11
import React from 'react';
2-
import logo from './logo.svg';
2+
import PathfindingVisualizer from './PathfindingVisualizer/PathfindingVisualizer';
33
import './App.css';
44

55
function App() {
66
return (
77
<div className="App">
8-
<header className="App-header">
9-
<img src={logo} className="App-logo" alt="logo" />
10-
<p>
11-
Edit <code>src/App.js</code> and save to reload.
12-
</p>
13-
<a
14-
className="App-link"
15-
href="https://reactjs.org"
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
>
19-
Learn React
20-
</a>
21-
</header>
8+
<PathfindingVisualizer></PathfindingVisualizer>
229
</div>
2310
);
2411
}
2512

26-
export default App;
13+
export default App;

src/PathfindingAlgorithms/astar.js

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
function createCell() {
2+
return {
3+
parent_i: -1,
4+
parent_j: -1,
5+
f: 0.0,
6+
g: 0.0,
7+
h: 0.0,
8+
}
9+
}
10+
11+
function isValid(grid, row, col) {
12+
return (row >= 0 && row < grid.length && col >= 0 && col < grid[0].length && !grid[row][col].isWall);
13+
}
14+
15+
export function aStarSearch(grid, startRow, startCol, finRow, finCol, checkboxVal) {
16+
let cellDetails = [];
17+
let visitedNodesInOrder = [];
18+
19+
for (let i = 0; i < grid.length; ++i) {
20+
let cell = [];
21+
22+
for (let j = 0; j < grid[0].length; ++j)
23+
{
24+
let newCell = createCell();
25+
newCell.f = Number.MAX_VALUE;
26+
newCell.g = Number.MAX_VALUE;
27+
newCell.h = Number.MAX_VALUE;
28+
cell.push(newCell);
29+
}
30+
31+
cellDetails.push(cell);
32+
}
33+
34+
const i = startRow, j = startCol;
35+
cellDetails[i][j].f = 0.0;
36+
cellDetails[i][j].g = 0.0;
37+
cellDetails[i][j].h = 0.0;
38+
cellDetails[i][j].parent_i = i;
39+
cellDetails[i][j].parent_j = j;
40+
let openList = [];
41+
openList.push([0.0, i, j]);
42+
var dirx = [-1, 0, 0, 1];
43+
var diry = [0, -1, 1, 0];
44+
45+
if (checkboxVal) {
46+
dirx = [-1, 0, 0, 1, -1, -1, 1, 1];
47+
diry = [0, -1, 1, 0, -1, 1, -1, 1];
48+
}
49+
50+
while (openList.length) {
51+
let i = openList[0][1], j = openList[0][2];
52+
openList.shift();
53+
grid[i][j].isVisited = true;
54+
let gNew, hNew, fNew;
55+
let newLvl = [];
56+
57+
// check all possible directions and update the values
58+
for (let idx = 0; idx < dirx.length; ++idx) {
59+
let ii = i + dirx[idx];
60+
let jj = j + diry[idx];
61+
const withCheckbox = (idx < 4 || (idx > 3 && checkboxVal));
62+
63+
if (isValid(grid, ii, jj) && withCheckbox) {
64+
if (grid[ii][jj].isFinish) {
65+
cellDetails[ii][jj].parent_i = i;
66+
cellDetails[ii][jj].parent_j = j;
67+
grid[ii][jj].previousNode = grid[i][j];
68+
if (newLvl.length) visitedNodesInOrder.push(newLvl);
69+
return visitedNodesInOrder;
70+
}
71+
else if (!grid[ii][jj].isVisited) {
72+
gNew = cellDetails[i][j].g + 1.0;
73+
if (idx > 3 && withCheckbox) gNew += 0.4;
74+
hNew = calculateHValue(ii, jj, finRow, finCol);
75+
fNew = gNew + hNew;
76+
77+
if (cellDetails[ii][jj].f === Number.MAX_VALUE || cellDetails[ii][jj].f > fNew) {
78+
openList.push([fNew, ii, jj]);
79+
openList.sort((elemA, elemB) => elemA[0] - elemB[0]);
80+
newLvl.push([ii, jj]);
81+
cellDetails[ii][jj].f = fNew;
82+
cellDetails[ii][jj].g = gNew;
83+
cellDetails[ii][jj].h = hNew;
84+
cellDetails[ii][jj].parent_i = i;
85+
cellDetails[ii][jj].parent_j = j;
86+
grid[ii][jj].previousNode = grid[i][j];
87+
}
88+
}
89+
}
90+
}
91+
92+
visitedNodesInOrder.push(newLvl);
93+
}
94+
95+
return visitedNodesInOrder;
96+
}
97+
98+
// heuristic; approximate distance between current node and finish node
99+
function calculateHValue(i, j, finRow, finCol) {
100+
return Math.abs(finRow - i) + Math.abs(finCol - j);
101+
}

0 commit comments

Comments
 (0)