From 3ed74f8dae2bd8f359f0a5092e02b62f87b533eb Mon Sep 17 00:00:00 2001 From: Stepan Susorov <137768644+Ba6ySHark@users.noreply.github.com> Date: Sat, 23 Sep 2023 11:13:58 -0600 Subject: [PATCH] Patch 10.1 --- src/App.js | 12 +++++++++++- src/components/NavBar.js | 4 ++-- src/mazes/random.js | 15 +++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 src/mazes/random.js diff --git a/src/App.js b/src/App.js index 98114bf..7b8b541 100644 --- a/src/App.js +++ b/src/App.js @@ -1,15 +1,20 @@ import React from "react"; + import {createNode, PAVnode} from "./components/PAVnode.js"; import PAVcanvas from "./components/PAVcanvas.js"; import NavBar from "./components/NavBar.js"; + import dijkstraAlgorithm from "./algorithms/dijkstra.js"; import astarAlgorithm from "./algorithms/astar.js"; import bfsAlgorithm from "./algorithms/bfs.js"; import dfsAlgorithm from "./algorithms/dfs.js"; +import createRandomMaze from "./mazes/random.js"; + export default function App() { let [featured_algorithm, setFeaturedAlgorithm] = React.useState("Dijkstra"); let [animationSpeed, setAnimationSpeed] = React.useState(25); // in ms (fast by default) + let [mazeType, setMazeType] = React.useState("random"); // set to random by default const rows = (window.innerHeight / 20) / (1.5); const columns = ((window.screen.width - 150) / 20); @@ -144,7 +149,11 @@ export default function App() { function selectAlgorithm(value) { setFeaturedAlgorithm(value); console.log(featured_algorithm); - }; + } + + function selectMazeType(value) { + setMazeType(value); + } function selectAnimationSpeed(value) { if (value === "fast") { @@ -199,6 +208,7 @@ export default function App() {
visualizeSelectedAlgorithm()} diff --git a/src/components/NavBar.js b/src/components/NavBar.js index 79bbc60..57f8c26 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -25,8 +25,8 @@ export default function NavBar(props) {

Wall Patterns

    -
  • -
  • +
  • +
diff --git a/src/mazes/random.js b/src/mazes/random.js new file mode 100644 index 0000000..97fed87 --- /dev/null +++ b/src/mazes/random.js @@ -0,0 +1,15 @@ +export default function createRandomMaze(nodes) { + const newNodes = nodes.slice(); + for (let i=0; i