Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ def algorithms(req: AlgorithmModel):
path = dfs(board, start)
return {
'path': path,
'valid': len(path) > 0
'valid': len(path) > 0 and path[-1] == end
}
135 changes: 68 additions & 67 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function Home() {
} = useBoard();
const tutorialModal = useTutorialModal();

const [algorithm, setAlgorithm] = useState("astar");
const [algorithm, setAlgorithm] = useState("bfs");
const [disabled, setDisabled] = useState(false);
const [path, setPath] = useState([]); // the path that we will animate

Expand Down Expand Up @@ -161,7 +161,7 @@ export default function Home() {

const prevNode = path[i - 1];
let direction = [0, 0];
nodeElement?.classList.add("animate-pulse");
// nodeElement?.classList.add("animate-pulse");
nodeElement?.classList.add(stack[1]);
if (i === path.length - 2) {
setDisabled(false);
Expand All @@ -187,79 +187,80 @@ export default function Home() {
}
}

if (direction[0] === 1 && direction[1] === 0) {
// move down
createRoot(nodeElement).render(
<MoveUp
size={15}
className="transform flex justify-center align-middle ease-in-out transition rotate-180 text-yellow-200 "
/>,
);
} else if (direction[0] === -1 && direction[1] === 0) {
//move up
// if (direction[0] === 1 && direction[1] === 0) {
// // move down
// createRoot(nodeElement).render(
// <MoveUp
// size={15}
// className="transform flex justify-center align-middle ease-in-out transition rotate-180 text-yellow-200 "
// />,
// );
// } else if (direction[0] === -1 && direction[1] === 0) {
// //move up

createRoot(nodeElement).render(
<MoveUp
size={15}
className="transform flex justify-center align-middle rotate-0 text-yellow-200"
/>,
);
} else if (direction[0] === 0 && direction[1] === 1) {
// move right
createRoot(nodeElement).render(
<MoveUp
size={15}
className="transform flex justify-center align-middle rotate-90 text-yellow-200"
/>,
);
} else if (direction[0] === 0 && direction[1] === -1) {
// move left
createRoot(nodeElement).render(
<MoveUp
size={15}
className="transform -rotate-90 text-yellow-200"
/>,
);
} else if (direction[0] === 1 && direction[1] === 1) {
//move down right
createRoot(nodeElement).render(
<MoveUp
size={15}
className="transform flex justify-center align-middle rotate-[135deg] text-yellow-200"
/>,
);
} else if (direction[0] === 1 && direction[1] === -1) {
//move down left
createRoot(nodeElement).render(
<MoveUp
size={15}
className="transform flex justify-center align-middle -rotate-[135deg] text-yellow-200"
/>,
);
} else if (direction[0] === -1 && direction[1] === 1) {
// move up right
createRoot(nodeElement).render(
<MoveUp
size={15}
className="transform flex justify-center align-middle rotate-45 text-yellow-200"
/>,
);
} else if (direction[0] === -1 && direction[1] === -1) {
// move up left
createRoot(nodeElement).render(
<MoveUp
size={15}
className="transform flex justify-center align-middle -rotate-45 text-yellow-200"
/>,
);
}
// createRoot(nodeElement).render(
// <MoveUp
// size={15}
// className="transform flex justify-center align-middle rotate-0 text-yellow-200"
// />,
// );
// } else if (direction[0] === 0 && direction[1] === 1) {
// // move right
// createRoot(nodeElement).render(
// <MoveUp
// size={15}
// className="transform flex justify-center align-middle rotate-90 text-yellow-200"
// />,
// );
// } else if (direction[0] === 0 && direction[1] === -1) {
// // move left
// createRoot(nodeElement).render(
// <MoveUp
// size={15}
// className="transform -rotate-90 text-yellow-200"
// />,
// );
// } else if (direction[0] === 1 && direction[1] === 1) {
// //move down right
// createRoot(nodeElement).render(
// <MoveUp
// size={15}
// className="transform flex justify-center align-middle rotate-[135deg] text-yellow-200"
// />,
// );
// } else if (direction[0] === 1 && direction[1] === -1) {
// //move down left
// createRoot(nodeElement).render(
// <MoveUp
// size={15}
// className="transform flex justify-center align-middle -rotate-[135deg] text-yellow-200"
// />,
// );
// } else if (direction[0] === -1 && direction[1] === 1) {
// // move up right
// createRoot(nodeElement).render(
// <MoveUp
// size={15}
// className="transform flex justify-center align-middle rotate-45 text-yellow-200"
// />,
// );
// } else if (direction[0] === -1 && direction[1] === -1) {
// // move up left
// createRoot(nodeElement).render(
// <MoveUp
// size={15}
// className="transform flex justify-center align-middle -rotate-45 text-yellow-200"
// />,
// );
// }
}
}, 20 * i);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [path]);

useEffect(() => {
generateRandomBoard(size[0], size[1])
tutorialModal.onOpen();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
"private": true,
"scripts": {
"fastapi-dev": "python3 -m uvicorn api.index:app --reload",
"fastapi-dev-windows": "python -m uvicorn api.index:app --reload --reload-dir api",
"next-dev": "next dev",
"dev": "concurrently \"pnpm run fastapi-dev\" \"pnpm run next-dev\"",
"dev-windows": "concurrently \"pnpm run fastapi-dev-windows\" \"pnpm run next-dev\"",
"build": "next build",
"start": "next start",
"lint": "next lint",
"postinstall": "pnpm run python-install",
"postinstall": "node -e \"require('child_process').execSync(process.platform === 'win32' ? 'pnpm run python-install-windows' : 'pnpm run python-install', {stdio:'inherit'})\"",
"python-install": "if [ -d 'venv' ]; then echo 'venv already exists'; else python3 -m venv venv && . venv/bin/activate; fi; pip3 install -r requirements.txt;",
"python-install-windows": "IF EXIST 'venv' (echo venv already exists) ELSE (python -m venv venv & . venv\\Scripts\\activate) & pip install -r requirements.txt",
"test-python": "pytest",
"test-ui": "cypress run -- --spec --record",
"cypress:open": "cypress open",
Expand Down
Loading
Loading