@@ -4,6 +4,7 @@ import '../styles/pathfinding.css';
44import { HiChevronDoubleRight } from "react-icons/hi2" ;
55import { HiOutlineFlag } from "react-icons/hi" ;
66import { Cell } from '../algorithms/utils/PathfindingUtils' ;
7+ import MazeGrid from '../components/MazeGrid.tsx' ;
78import { BreadthFirstSearch } from '../algorithms/pathfinding/BreadthFirstSearch.ts' ;
89import { Dijkstra } from '../algorithms/pathfinding/Dijkstra.ts' ;
910import { DepthFirstSearch } from '../algorithms/pathfinding/DepthFirstSearch.ts' ;
@@ -180,30 +181,12 @@ const PathfindingVisualiser: React.FC = () => {
180181
181182 return (
182183 < div >
183- < div onMouseUp = { handleMouseUp } >
184- { maze . map ( ( row , rowIndex ) => (
185- < div key = { rowIndex } className = "pathfinding-row" id = { 'row-' + rowIndex } >
186- { row . map ( ( cell , colIndex ) => (
187- < div
188- key = { colIndex }
189- onMouseDown = { ( ) => handleMouseDown ( rowIndex , colIndex ) }
190- onMouseEnter = { ( ) => handleMouseEnter ( rowIndex , colIndex ) }
191- style = { {
192- width : '25px' ,
193- height : '25px' ,
194- backgroundColor : cell . wall ? 'black' : ( cell . finalPath ? 'yellow' : ( cell . visited ? 'lightblue' : 'white' ) ) ,
195- border : '.5px solid lightblue' ,
196- display : 'flex' ,
197- alignItems : 'center' ,
198- justifyContent : 'center'
199- } } >
200- { cell . start ? < HiChevronDoubleRight style = { { color : 'black' , fontSize : '26px' } } /> : '' }
201- { cell . end ? < HiOutlineFlag style = { { color : 'black' , fontSize : '26px' } } /> : '' }
202- </ div >
203- ) ) }
204- </ div >
205- ) ) }
206- </ div >
184+ < MazeGrid
185+ maze = { maze }
186+ handleMouseDown = { handleMouseDown }
187+ handleMouseEnter = { handleMouseEnter }
188+ handleMouseUp = { handleMouseUp }
189+ />
207190 < button onClick = { ( ) => { triggerBFS ( ) ; } } style = { { backgroundColor : 'white' , color : 'black' } } > Run BFS Visualisation</ button >
208191 < button onClick = { ( ) => { triggerDFS ( ) ; } } style = { { backgroundColor : 'white' , color : 'black' } } > Run DFS Visualisation</ button >
209192 < button onClick = { ( ) => { triggerDijkstra ( ) ; } } style = { { backgroundColor : 'white' , color : 'black' } } > Run Djikstra Visualisation</ button >
0 commit comments