Skip to content

Commit ea418f9

Browse files
author
Shawn Toubeau
committed
resolved conflicts
2 parents fe70d6c + f323c1e commit ea418f9

31 files changed

+2562
-1162
lines changed

package-lock.json

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

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
"fs": "^0.0.1-security",
2121
"history": "^4.10.1",
2222
"lodash": "^4.17.15",
23+
"moment": "^2.24.0",
2324
"node-sass": "^4.13.1",
2425
"react": "^16.12.0",
2526
"react-dom": "^16.12.0",
2627
"react-markdown": "^4.3.1",
28+
"react-moment": "^0.9.7",
2729
"react-redux": "^7.1.3",
2830
"react-router": "^5.1.2",
2931
"react-router-dom": "^5.1.2",
@@ -64,6 +66,9 @@
6466
"transform": {
6567
"^.+\\.(ts|tsx)$": "ts-jest"
6668
},
69+
"transformIgnorePatterns": [
70+
"/node_modules/(?!three)"
71+
],
6772
"moduleNameMapper": {
6873
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/tests/setup/fileMock.js",
6974
"\\.(css|less)$": "<rootDir>/tests/setup/styleMock.js"

public/empty.png

22 KB
Loading

public/lava.png

4.26 KB
Loading

public/path.png

445 KB
Loading

public/startpoint.png

336 Bytes
Loading

public/visted.png

22.4 KB
Loading

src/actions/mazeActions/mazeActions.spec.ts

+1-35
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ import {
55
makeWall,
66
makeEmpty,
77
loadMaze,
8-
setPath,
9-
setVisited,
108
CHANGE_START,
119
CHANGE_END,
1210
MAKE_WALL,
1311
MAKE_EMPTY,
1412
LOAD_MAZE,
15-
SET_PATH,
16-
SET_VISITED,
1713
STOP_VISUALIZATION,
1814
handleStopVisualization,
1915
} from "./mazeActions";
@@ -95,44 +91,14 @@ describe("Maze Action Tests", () => {
9591
const expectedActions = [
9692
{
9793
type: LOAD_MAZE,
98-
payload: { mazeInfo: maze, clearMaze: generateMaze(5, 5, true) },
94+
payload: { mazeInfo: maze },
9995
},
10096
];
10197
reduxStore.dispatch(loadMaze(maze));
10298
expect(reduxStore.getActions()).toEqual(expectedActions);
10399
});
104100
});
105101

106-
describe("Set Path Test", () => {
107-
it("Should call SET_PATH action", () => {
108-
const coord = { x: 2, y: 2 };
109-
const expectedActions = [
110-
{
111-
type: SET_PATH,
112-
payload: coord,
113-
},
114-
];
115-
116-
reduxStore.dispatch(setPath(coord));
117-
expect(reduxStore.getActions()).toEqual(expectedActions);
118-
});
119-
});
120-
121-
describe("Set Visited Test", () => {
122-
it("Should call SET_VISITED action", () => {
123-
const coord = { x: 2, y: 2 };
124-
const expectedActions = [
125-
{
126-
type: SET_VISITED,
127-
payload: coord,
128-
},
129-
];
130-
131-
reduxStore.dispatch(setVisited(coord));
132-
expect(reduxStore.getActions()).toEqual(expectedActions);
133-
});
134-
});
135-
136102
describe("Stop Visualization Test", () => {
137103
it("Should dispatch correct action", () => {
138104
const expectedActions = [

src/actions/mazeActions/mazeActions.ts

+100-13
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@ import { AnyAction } from "redux";
22
import { Coord, MazeInfo, Maze } from "../../models/maze";
33
import { generateMaze } from "../../models/maze/initialState";
44
import { ButtonProps } from "semantic-ui-react";
5+
import { PAUSE_VISUALIZATION } from "../menuActions/menuActions";
56
export const CHANGE_START = "CHANGE_START";
67
export const CHANGE_END = "CHANGE_END";
78
export const MAKE_WALL = "MAKE_WALL";
89
export const MAKE_EMPTY = "MAKE_EMPTY";
10+
export const MAKE_VISITED = "MAKE_VISITED";
911
export const LOAD_MAZE = "LOAD_MAZE";
10-
export const SET_PATH = "SET_PATH";
11-
export const SET_VISITED = "SET_VISITED";
1212
export const STOP_VISUALIZATION = "STOP_VISUALIZATION";
13+
export const PROGRESS_BFS = "PROGRESS_BFS";
14+
export const UPDATE_GRID_SIZE = "UPDATE_GRID_SIZE";
15+
export const PROGRESS_DFS = "PROGRESS_DFS";
16+
export const PROGRESS_ASTAR = "PROGRESS_ASTAR";
17+
export const UPDATE_OPEN_SET = "UPDATE_OPEN_SET";
18+
export const UPDATE_CLOSED_SET = "UPDATE_CLOSED_SET";
19+
export const RANDOMIZE_WALLS = "RANDOMIZE_WALLS";
1320

1421
export const handleChangeStart = (newPos: Coord): AnyAction => {
1522
return {
@@ -39,33 +46,113 @@ export const makeEmpty = (coord: Coord): AnyAction => {
3946
};
4047
};
4148

42-
export const loadMaze = (maze: MazeInfo): AnyAction => {
49+
export const makeVisited = (coord: Coord): AnyAction => {
4350
return {
44-
type: LOAD_MAZE,
45-
payload: { mazeInfo: maze, clearMaze: generateMaze(5, 5, true) } as Maze,
51+
type: MAKE_VISITED,
52+
payload: coord,
4653
};
4754
};
4855

49-
export const setPath = (coord: Coord): AnyAction => {
56+
export const loadMaze = (mazeInfo: MazeInfo): AnyAction => {
5057
return {
51-
type: SET_PATH,
52-
payload: coord,
58+
type: LOAD_MAZE,
59+
payload: { mazeInfo: mazeInfo },
5360
};
5461
};
5562

56-
export const setVisited = (coord: Coord): AnyAction => {
63+
export const handlePauseVisualization = (
64+
_?: React.MouseEvent<HTMLButtonElement, MouseEvent>,
65+
data?: ButtonProps
66+
) => {
5767
return {
58-
type: SET_VISITED,
59-
payload: coord,
68+
type: PAUSE_VISUALIZATION,
69+
payload: null,
6070
};
6171
};
6272

6373
export const handleStopVisualization = (
64-
_: React.MouseEvent<HTMLButtonElement, MouseEvent>,
65-
data: ButtonProps
74+
_?: React.MouseEvent<HTMLButtonElement, MouseEvent>,
75+
data?: ButtonProps
6676
) => {
6777
return {
6878
type: STOP_VISUALIZATION,
6979
payload: null,
7080
};
7181
};
82+
83+
export const progressBFS = (
84+
queue: Coord[],
85+
coord: Coord,
86+
neighbors: Coord[] | Coord
87+
) => {
88+
return {
89+
type: PROGRESS_BFS,
90+
payload: {
91+
queue: queue,
92+
coord: coord,
93+
neighbors: neighbors,
94+
},
95+
};
96+
};
97+
98+
export const progressDFS = (
99+
stack: Coord[],
100+
coord: Coord,
101+
neighbors: Coord[] | Coord
102+
) => {
103+
return {
104+
type: PROGRESS_DFS,
105+
payload: {
106+
stack: stack,
107+
coord: coord,
108+
neighbors: neighbors,
109+
},
110+
};
111+
};
112+
113+
export const updateGridSize = (cols: number, rows: number) => {
114+
return {
115+
type: UPDATE_GRID_SIZE,
116+
payload: {
117+
cols: cols,
118+
rows: rows,
119+
},
120+
};
121+
};
122+
export const progressAstar = (
123+
openSet: Coord[],
124+
closedSet: Coord[],
125+
newMazeInfo: MazeInfo,
126+
end: Coord
127+
) => {
128+
return {
129+
type: PROGRESS_ASTAR,
130+
payload: {
131+
openSet,
132+
closedSet,
133+
newMazeInfo,
134+
end,
135+
},
136+
};
137+
};
138+
139+
export const handleUpdateOpenSet = (openSet: Coord[]) => {
140+
return {
141+
type: UPDATE_OPEN_SET,
142+
payload: openSet,
143+
};
144+
};
145+
146+
export const handleUpdateClosedSet = (closedSet: Coord[]) => {
147+
return {
148+
type: UPDATE_CLOSED_SET,
149+
payload: closedSet,
150+
};
151+
};
152+
153+
export const randomizeWalls = () => {
154+
return {
155+
type: RANDOMIZE_WALLS,
156+
payload: null,
157+
};
158+
};

src/actions/menuActions/menuActions.ts

+12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const TOGGLE_MOVE_START = "TOGGLE_MOVE_START";
99
export const TOGGLE_MOVE_END = "TOGGLE_MOVE_END";
1010
export const LOAD_MAZE = "LOAD_MAZE";
1111
export const SAVE_MAZE = "SAVE_MAZE";
12+
export const CHANGE_SPEED = "CHANGE_SPEED";
1213

1314
export const handleDropdownChange = (
1415
_: React.SyntheticEvent<HTMLElement, Event>,
@@ -20,10 +21,21 @@ export const handleDropdownChange = (
2021
};
2122
};
2223

24+
export const handleDropdownSpeed = (
25+
_: React.SyntheticEvent<HTMLElement, Event>,
26+
data: DropdownProps
27+
) => {
28+
return {
29+
type: CHANGE_SPEED,
30+
payload: data.value,
31+
};
32+
};
33+
2334
export const handleStartVisualization = (
2435
_: React.MouseEvent<HTMLButtonElement, MouseEvent>,
2536
data: ButtonProps
2637
) => {
38+
console.log('starting visualization');
2739
return {
2840
type: START_VISUALIZATION,
2941
payload: null,

src/components/Maze/Maze.scss

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.Maze {
2-
height: 90vh !important;
2+
height: calc(100vh - 119px) !important;
33
// Tempt style for debugging
4-
border: 1px solid orangered;
54
}

0 commit comments

Comments
 (0)