Skip to content

Commit

Permalink
[update] prevent Uniform search on size > 3
Browse files Browse the repository at this point in the history
  • Loading branch information
aallali committed Apr 23, 2023
1 parent 10d0d5d commit ea8320c
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions n-puzzle-ui/src/puzzle/SolvingOptions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ function AlgoOptions({ solvingOptions, updateSolvingOptions }) {
type="checkbox"
checked={solvingOptions.greedy}
onChange={(e) =>
updateSolvingOptions((prev) => ({
...prev,
greedy: e.target.checked,
}))
updateSolvingOptions((prev) => {
return {
...prev,
greedy: e.target.checked,
};
})
}
/>
<label htmlFor="greedy">Greedy</label>
Expand All @@ -91,10 +93,17 @@ function AlgoOptions({ solvingOptions, updateSolvingOptions }) {
type="checkbox"
checked={solvingOptions.uniform}
onChange={(e) =>
updateSolvingOptions((prev) => ({
...prev,
uniform: e.target.checked,
}))
updateSolvingOptions((prev) => {
if (solvingOptions.size == 3)
return {
...prev,
uniform: e.target.checked,
};
alert(
"Sorry, you can't use UNIFORM search with puzzle's size bigger than 3, it will take forever to solve."
);
return prev;
})
}
/>
<label htmlFor="uniform">Uniform</label>
Expand Down

0 comments on commit ea8320c

Please sign in to comment.