Skip to content
Open
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
18 changes: 15 additions & 3 deletions src/components/board/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Chess } from "chess.js";
import { getSquareRenderer } from "./squareRenderer";
import { CurrentPosition } from "@/types/eval";
import EvaluationBar from "./evaluationBar";
import { CLASSIFICATION_COLORS } from "@/constants";
import { CLASSIFICATION_COLORS, ENGINE_BEST_MOVE_COLOR } from "@/constants";
import { Player } from "@/types/game";
import PlayerHeader from "./playerHeader";
import { boardHueAtom, pieceSetAtom } from "./states";
Expand Down Expand Up @@ -208,9 +208,21 @@ export default function Board({
);

const customArrows: Arrow[] = useMemo(() => {
const bestCurrentMove = position?.eval?.bestMove;
const bestMove = position?.lastEval?.bestMove;
const moveClassification = position?.eval?.moveClassification;

const result = [];

if (bestCurrentMove && showBestMoveArrow) {
const bestCurrentMoveArrow = [
bestCurrentMove.slice(0, 2),
bestCurrentMove.slice(2, 4),
tinycolor(ENGINE_BEST_MOVE_COLOR).spin(-boardHue).toHexString(),
] as Arrow;
result.push(bestCurrentMoveArrow);
}

if (
bestMove &&
showBestMoveArrow &&
Expand All @@ -227,10 +239,10 @@ export default function Board({
.toHexString(),
] as Arrow;

return [bestMoveArrow];
result.push(bestMoveArrow);
}

return [];
return result;
}, [position, showBestMoveArrow, boardHue]);

const SquareRenderer: CustomSquareRenderer = useMemo(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const CLASSIFICATION_COLORS: Record<MoveClassification, string> = {
[MoveClassification.Blunder]: "#df5353",
};

export const ENGINE_BEST_MOVE_COLOR = "#cccccc";

export const DEFAULT_ENGINE: EngineName = EngineName.Stockfish17Lite;
export const STRONGEST_ENGINE: EngineName = EngineName.Stockfish17;

Expand Down