Skip to content

Commit 2b17a9e

Browse files
committed
Probability Framework
1 parent c4a2bd0 commit 2b17a9e

15 files changed

Lines changed: 499 additions & 194 deletions

File tree

‎src/App.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import './App.css';
2-
import React from 'react';
3-
import Display from './components/BoardCanvas/Display';
4-
import AppRouter from './AppRouter';
2+
import React from 'react';
3+
import MazeDisplay from './components/Algorithms/Maze/MazeDisplay';
4+
import AppRouter from './AppRouter';
55
import Navigation from './components/Page/partial/Navbar/Navigation';
66

77

‎src/AppRouter.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import {
77
import SplashScreen from './components/Page/Splash/SplashScreen';
88
import MainSortingCanvas from './components/Canvas/MainSortingCanvas';
99
import AboutScreen from './components/Page/About/AboutScreen';
10-
import ContactScreen from './components/Page/Contact/ContactScreen';
11-
import Display from './components/BoardCanvas/Display';
10+
import ContactScreen from './components/Page/Contact/ContactScreen';
11+
import MazeDisplay from './components/Algorithms/Maze/MazeDisplay';
12+
import DiceDisplay from './components/Algorithms/Propability/DiceDisplay';
1213

1314

1415

@@ -23,7 +24,9 @@ function AppRouter() {
2324
<Route exact path = "/dashboard"
2425
element = {<MainSortingCanvas/>}/>
2526
<Route exact path = "/dashboard-two"
26-
element = {<Display/>}/>
27+
element = {<MazeDisplay/>}/><
28+
Route exact path = "/dashboard-three"
29+
element = {<DiceDisplay/>}/>
2730
<Route path = "/about"
2831
element = {<AboutScreen/>}/>
2932
<Route path = "/contact"

‎src/components/Algorithms/Display.js‎

Lines changed: 0 additions & 132 deletions
This file was deleted.

‎src/components/Algorithms/Greedy/Greedy.js‎

Whitespace-only changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as React from 'react';
22
// import {useFrame /*useFrame*/} from '@react-three/fiber';
33
import {Canvas} from 'react-three-fiber';
4-
import Controls from './OrbitControls';
4+
import Controls from '../OrbitControls';
55
import {useImperativeHandle, useRef, forwardRef} from 'react';
66
import {TrackballControls} from 'three/examples/jsm/controls/TrackballControls';
7-
import OrbitControls from './OrbitControls';
7+
import OrbitControls from '../OrbitControls';
88
import Cells from './Cells';
99

1010

src/components/BoardCanvas/LayoutsFunctions.js renamed to src/components/Algorithms/Maze/CellFunctions.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import * as React f
22
import {useEffect, useRef, useState, useMemo} from 'react';
33
import {useSpring} from 'react-spring';
44
import board from './Board';
5-
import {_BoardReset} from '../Algorithms/Maze/Tools';
6-
import {PATH_TYPE, DEFAULT_TYPE, FLOOR_TYPE, WALL_TYPE, START_TYPE, GOAL_TYPE} from '../../Utility/Colors';
7-
import {BinaryTreeCreation} from '../Algorithms/Maze/Generation/BinaryTreeCreation';
8-
import {RecursiveBacktrackCreation} from '../Algorithms/Maze/Generation/RecursiveBacktrackCreation';
9-
import {GrowingTreeCreation} from '../Algorithms/Maze/Generation/GrowingTreeCreation';
10-
import {BfsCreation} from '../Algorithms/Maze/Generation/BfsCreation';
11-
import {RecursiveBacktrackSolution} from '../Algorithms/Maze/Solving/RecursiveBacktrackSolution';
12-
import {BfsSolution} from '../Algorithms/Maze/Solving/BfsSolution';
5+
import {_BoardReset} from './Tools';
6+
import {PATH_TYPE, DEFAULT_TYPE, FLOOR_TYPE, WALL_TYPE, START_TYPE, GOAL_TYPE} from '../../../Utility/Colors';
7+
import {BinaryTreeCreation} from './Generation/BinaryTreeCreation';
8+
import {RecursiveBacktrackCreation} from './Generation/RecursiveBacktrackCreation';
9+
import {GrowingTreeCreation} from './Generation/GrowingTreeCreation';
10+
import {BfsCreation} from './Generation/BfsCreation';
11+
import {RecursiveBacktrackSolution} from './Solving/RecursiveBacktrackSolution';
12+
import {BfsSolution} from './Solving/BfsSolution';
1313

1414

1515

@@ -76,16 +76,14 @@ export function useSolver({board, solving, algorithm, onFrame}) {
7676
const [solved, setSolved] = useState(false);
7777
const prevSelection = useRef(algorithm);
7878
const animation = useSpring({
79-
solvingProgress: 1,
80-
from : {solvingProgress: 0},
81-
reset : algorithm !== prevSelection.current,
82-
onFrame : ({animationProgress}) => {
83-
// interpolate based on progress
84-
// drawPathing(board, solvingProgress);
85-
// callback to indicate data has updated
86-
// onFrame({ solvingProgress });
87-
},
88-
});
79+
solvingProgress: 1,
80+
from : {solvingProgress: 0},
81+
reset : algorithm !== prevSelection.current,
82+
onFrame : ({solvingProgress}) => {
83+
onFrame(solvingProgress);
84+
},
85+
},
86+
);
8987
prevSelection.current = algorithm;
9088

9189
return animation;
@@ -151,7 +149,7 @@ export function standardLayout(board) {
151149

152150
node.x = col;/* .05; */
153151
node.y = row;/* .05; */
154-
node.z = 0;
152+
node.z = 0;
155153
}
156154
}
157155

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import * as React from 'react';
22
import {useEffect, useRef, useMemo, useState, createContext} from 'react';
3-
import {a} from '@react-spring/three';
4-
import {useGenerateMazeHook, useSolver, useLayoutHook} from './LayoutsFunctions';
5-
import {directions} from '../Algorithms/Maze/Directions';
6-
import {_FindCell} from '../Algorithms/Maze/Tools';
7-
import board from './Board';
8-
import {BinaryTreeCreation} from '../Algorithms/Maze/Generation/BinaryTreeCreation';
3+
import {a} from '@react-spring/three';
4+
import {useGenerateMazeHook, useSolver, useLayoutHook} from './CellFunctions';
5+
import {directions} from './Directions';
6+
import {_FindCell} from './Tools';
7+
import board from './Board';
8+
import {BinaryTreeCreation} from './Generation/BinaryTreeCreation';
99
import {
1010
FLOOR_TYPE, FLOOR_COLOR, WALL_TYPE, WALL_COLOR,
1111
getColor, GOAL_TYPE, START_TYPE, SELECTED_COLOR,
1212
BURN_COLOR, PATH_TYPE, PATH_COLOR,
13-
} from '../../Utility/Colors';
14-
import * as THREE from 'three';
13+
} from '../../../Utility/Colors';
14+
import * as THREE from 'three';
1515

1616

1717

@@ -154,6 +154,7 @@ const Cells = ({board, layoutType, solving, algorithm, mazeType, selectedPoint,
154154
onSelectPoint,
155155
});
156156

157+
157158
/*
158159
* useColorsHook() is a hook that calls the useColorsHook() function.
159160
* Generating a color array according to the listed type of each cell.
@@ -169,7 +170,6 @@ const Cells = ({board, layoutType, solving, algorithm, mazeType, selectedPoint,
169170

170171

171172

172-
173173
return (
174174
<group>
175175
<instancedMesh

src/components/BoardCanvas/Display.js renamed to src/components/Algorithms/Maze/MazeDisplay.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, {useState, useRef, useEffect} from 'react';
22
import Board from './Board';
3-
import Navigation from '../Page/partial/Navbar/Navigation';
4-
import './display.css';
3+
import Navigation from '../../Page/partial/Navbar/Navigation';
4+
import './mazeDisplay.css';
55
// import {useBinaryTreeCreation} from '../Algorithms/Maze/Generation/BinaryTreeCreation';
6-
import {Strategy} from '../Strategy/Strategy';
6+
import {Strategy} from '../../Strategy/Strategy';
77

88
/*
99
@@ -19,7 +19,7 @@ import {Strategy} from '../Strategy/Strategy';
1919
const board = new Array(3844).fill(0).map(
2020
(i, id: number, type: string = '_default_', currentType: string = '_default_', targetType: string = '_default_', visited: boolean = false, x: number, y: number) => ({x, y, id, type, visited, currentType, targetType}));
2121

22-
export default function Display() {
22+
export default function MazeDisplay() {
2323
const [layoutType, setLayout] = useState('standard');
2424
const [mazeType, setMazeType] = useState('none');
2525
const [algorithm, setAlgorithm] = useState('none');
File renamed without changes.

src/components/BoardCanvas/OrbitControls.js renamed to src/components/Algorithms/OrbitControls.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,29 @@ const OrbitControls = ({board, selectedPoint, onSelectedPoint}, ref) => {
6363
controls.current.up0.z
6464
);
6565
},
66-
// resetCamera: () => {
67-
// camera.position.set(0, -10, 50); // reset position
68-
// camera.lookAt(0, 0, 0); // reset rotation
69-
// this.setTarget(null); // reset target
70-
// },
7166

7267

7368
/*
74-
* Function to zoom in the camera to the selected point.
69+
*
7570
*/
76-
setTargetZoomIn: (target) => {
77-
if (target) {
78-
camera.position.set(target.position.x, target.position.y, target.position.z);
79-
camera.lookAt(target.position);
80-
console.log(target.position);
81-
}
71+
withTargetZoomOut: () => {
72+
camera.position.set(this.target.position.x, this.target.position.y, this.target.position.z);
73+
camera.lookAt(target.current.position);
74+
camera.position.set(this.target.position.x, this.target.position.y, this.target.position.z);
75+
camera.lookAt(target.current.position);
8276
},
77+
78+
79+
80+
/*
81+
* Function to zoom in the camera to the selected point.
82+
*/
83+
withTargetZoomIn: () => {
84+
camera.position.set(this.target.position.x, this.target.position.y, this.target.position.z);
85+
camera.lookAt(target.current.position);
86+
camera.position.set(this.target.position.x, this.target.position.y, this.target.position.z);
87+
camera.lookAt(target.current.position);
88+
}
8389
}));
8490

8591

0 commit comments

Comments
 (0)