Skip to content

Commit 92ed272

Browse files
committed
Merge branch 'main' of github.com:https-sam/algorithm-visualizer
styling changes
2 parents e921095 + 4b33d65 commit 92ed272

File tree

9 files changed

+39
-333
lines changed

9 files changed

+39
-333
lines changed

src/App.css

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,28 @@
22
@tailwind components;
33
@tailwind utilities;
44

5-
65
html, body, * {
7-
margin: 0;
8-
padding: 0;
9-
box-sizing: border-box;
6+
margin: 0;
7+
padding: 0;
8+
box-sizing: border-box;
109
}
1110

1211
body {
13-
margin: 0;
14-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
15-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
16-
sans-serif;
17-
-webkit-font-smoothing: antialiased;
12+
margin: 0;
13+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
14+
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
15+
sans-serif;
16+
-webkit-font-smoothing: antialiased;
1817
-moz-osx-font-smoothing: grayscale;
1918
}
2019

2120
.App {
22-
width: 100%;
21+
width: 100%;
2322
height: 100%;
2423
}
2524

2625
.App-logo {
27-
height: 40vmin;
26+
height: 40vmin;
2827
}
2928

3029
@media (prefers-reduced-motion: no-preference) {

src/components/Algorithms/Maze/useMaze.js

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +0,0 @@
1-
import Move from './Move';
2-
import {Board} from './Board';
3-
4-
5-
6-
/**
7-
*
8-
*/
9-
class MiniMax {
10-
constructor(params) {
11-
this.objectRepresentation = params.objectRepresentation;
12-
13-
}
14-
15-
16-
getObjectRepresentation() {
17-
return this.objectRepresentation.type;
18-
}
19-
20-
21-
calculate(params) {
22-
23-
}
24-
25-
26-
calculateMax(params) {
27-
28-
}
29-
30-
31-
calculateMin(params) {
32-
33-
}
34-
35-
36-
minimax_Max(grid) {
37-
if (grid.isTerminal() || grid.isFull()) {
38-
return 0;
39-
}
40-
41-
var board = new Board(grid);
42-
var leaves = new Move[10];
43-
44-
return this.calculateMax(leaves);
45-
}
46-
47-
48-
minimax_Min(grid) {
49-
if (grid.isTerminal() || grid.isFull()) {
50-
return 0;
51-
}
52-
53-
var board = new Board(grid);
54-
let leaves: Move[] = new Move[10];
55-
56-
//
57-
for (var iter = 0; iter < leaves.length; iter++) {
58-
if (leaves[iter] != null) {
59-
leaves[iter].addValue((this.minimax_Min(leaves[iter].getBoard())));
60-
}
61-
}
62-
63-
let bestMove: Move = null;
64-
for (var i = 0; i < leaves.length; i++) {
65-
if (bestMove == null) {
66-
// bestMove = moves[i];
67-
continue;
68-
}
69-
else {
70-
if (leaves[i] != null && bestMove.compareTo(leaves[i]) > 0) {
71-
bestMove = leaves[i];
72-
}
73-
}
74-
}
75-
//
76-
77-
return this.calculateMin(leaves);
78-
}
79-
80-
}

src/components/BoardCanvas/Board.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Cell from './Cells';
55
import {useImperativeHandle, useRef, forwardRef} from 'react';
66
import {TrackballControls} from 'three/examples/jsm/controls/TrackballControls';
77
import OrbitControls from './OrbitControls';
8-
// import create from 'zustand';
98

109

1110
export const Board = ({board, layoutType, selectedPoint, onSelectPoint, mazeType}, ref) => {

src/components/BoardCanvas/Cells.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as React from 'react';
44
import {useEffect, useRef, useMemo} from 'react';
55
import * as THREE from 'three';
66
import {a} from 'react-spring/three';
7-
import {useAnimationHook, useGeneratedMazeHook} from './layouts';
7+
import {useAnimationHook, useGeneratedMazeHook} from './Layouts';
88

99

1010

src/components/BoardCanvas/GridState.js

Lines changed: 0 additions & 94 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {_FindCell} from '../Algorithms/Maze/Generation/Tools';
1818
*/
1919
export const useLayoutHook = ({board, layoutType, mazeType}) => {
2020
useEffect(() => {
21-
// if (mazeType === "none") {
21+
if (mazeType === "none") {
2222
switch (layoutType) {
2323
case 'circular':
2424
circularLayout(board);
@@ -28,7 +28,7 @@ export const useLayoutHook = ({board, layoutType, mazeType}) => {
2828
standardLayout(board);
2929
}
3030
}
31-
// }
31+
}
3232
// GridState.setGrid(layoutType);
3333
}, [board, layoutType]);
3434

src/components/BoardCanvas/OrbitControls.js

Lines changed: 3 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ const OrbitControls = ({selectedPoint, onSelectedPoint}, ref) => {
5757
* Function to reset the camera to the default position.
5858
*/
5959
resetCamera: () => {
60-
camera.position.set(0, -10, 50); // reset position
61-
camera.lookAt(0, 0, 0); // reset rotation
62-
this.setTarget(null); // reset target
60+
camera.position.set(0, -10, 50); // reset position
61+
camera.lookAt(0, 0, 0); // reset rotation
62+
this.setTarget(null); // reset target
6363
},
6464

6565

@@ -112,108 +112,3 @@ const OrbitControls = ({selectedPoint, onSelectedPoint}, ref) => {
112112
export default forwardRef(OrbitControls);
113113

114114

115-
116-
117-
/*
118-
const usePointColorsHook = ({board, selectedPoint}) => {
119-
const numPoints = board.length;
120-
const colorAttrib = useRef();
121-
const colorArray = useMemo(() => new Float32Array(numPoints * 3), [
122-
numPoints,
123-
]);
124-
useEffect((prev) => {
125-
for (let i = 0; i < board.length; ++i) {
126-
if (board[i].type === WALL_TYPE) {
127-
tempCOLOR.set(
128-
selectedPoint === board[i] ? WALL_COLOR : FLOOR_COLOR,
129-
);
130-
}
131-
else if (board[i].type === PATH_TYPE) {
132-
tempCOLOR.set(
133-
selectedPoint === board[i] ? PATH_COLOR : FLOOR_COLOR,
134-
);
135-
}
136-
else if (board[i].type === GOAL_TYPE) {
137-
tempCOLOR.set(
138-
selectedPoint === board[i] ? GOAL_COLOR : FLOOR_COLOR,
139-
);
140-
}
141-
else if (board[i].type === START_TYPE) {
142-
tempCOLOR.set(
143-
selectedPoint === board[i] ? START_COLOR : FLOOR_COLOR,
144-
);
145-
}
146-
else if (board[i].type === TEST_TYPE) {
147-
tempCOLOR.set(
148-
selectedPoint === board[i] ? TEST_COLOR : FLOOR_COLOR,
149-
);
150-
}
151-
else if (board[i].type === FLOOR_TYPE) {
152-
tempCOLOR.set(
153-
selectedPoint === board[i] ? FLOOR_COLOR : FLOOR_COLOR,
154-
);
155-
tempCOLOR.set(FLOOR_COLOR);
156-
}
157-
else if (board[i].type === null) {
158-
tempCOLOR.set(FLOOR_COLOR);
159-
}
160-
else {
161-
tempCOLOR.set(FLOOR_COLOR);
162-
}
163-
tempCOLOR.toArray(colorArray, i * 3);
164-
}
165-
colorAttrib.current.needsUpdate = true;
166-
}, [board, selectedPoint, colorArray]);
167-
168-
return {colorAttrib, colorArray};
169-
};
170-
171-
const _mouseClickHook = ({board, selectedPoint, onSelectPoint}) => {
172-
const onMouseDownHandler = useRef([0, 0]); // Record and maintain the handler for the mouse down event
173-
const onMouseUpHandler = useRef([0, 0]); // Record and maintain the handler for the mouse up event
174-
const onMouseMoveHandler = useRef([0, 0]); // Record and maintain the handler for the mouse move event
175-
176-
// Pointer Click Down Position
177-
const setDownPointerCoord = event => {
178-
onMouseDownHandler.current[0] = event.clientX; // Mouseclick x coordinate
179-
onMouseDownHandler.current[1] = event.clientY; // Mouseclick y coordinate
180-
};
181-
182-
//
183-
//If the mouse has clicked on a point, if that point is occupied by an
184-
//interactable object, gather its reference.
185-
//
186-
const getClickTarget = event => {
187-
const {instanceId, clientX, clientY} = event;
188-
const travelDistance = Math.sqrt(
189-
Math.pow(onMouseDownHandler.current[0] - clientX, 2)
190-
+
191-
Math.pow(onMouseDownHandler.current[1] - clientY, 2),
192-
);
193-
194-
// Prevents repeat calls to click handler unless drag selection is initiated.
195-
if (travelDistance > 50) {
196-
if (!useDrag) {
197-
}
198-
}
199-
200-
const point = board[instanceId];
201-
console.log('Point clicked: ', point);
202-
// toggle the point
203-
if (point === selectedPoint) {
204-
onSelectPoint(null);
205-
}
206-
else {
207-
onSelectPoint(point);
208-
}
209-
};
210-
211-
// const onMouseMove = (e) => {
212-
// const dx = e.clientX - originalPosition.clientX
213-
// const dy = e.clientY - originalPosition.clientY
214-
// onMouseMoveHandler.current(e, { dx, dy })
215-
// }
216-
217-
return {setDownPointerCoord, getClickTarget};
218-
};
219-
*/

0 commit comments

Comments
 (0)