Skip to content

Commit

Permalink
fix engine play moves
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoBSalgueiro committed Jan 21, 2024
1 parent e090fbc commit 19089bf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/boards/BoardGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
} from "@/atoms/atoms";
import { useAtom, useAtomValue } from "jotai";
import { match } from "ts-pattern";
import { parseUci } from "@/utils/chess";
import { getMainLine, parseUci } from "@/utils/chess";
import { EngineSettings, LocalEngine } from "@/utils/engines";
import { commands } from "@/bindings";
import { unwrap } from "@/utils/invoke";
Expand Down Expand Up @@ -236,6 +236,7 @@ function BoardGame() {
const mainLine = Array.from(treeIteratorMainLine(root));
const currentNode = getNodeAtPath(root, position);
const lastNode = mainLine[mainLine.length - 1].node;
const moves = getMainLine(root);

const [pos, error] = useMemo(() => {
return positionFromFen(lastNode.fen);
Expand All @@ -262,7 +263,7 @@ function BoardGame() {
commands
.getSingleBestMove(
player.settings.go,
{ ...player.settings.options, fen: lastNode.fen },
{ ...player.settings.options, fen: root.fen, moves: moves},
player.engine.path
)
.then((move) => {
Expand Down

0 comments on commit 19089bf

Please sign in to comment.