From aa9721319eea55933d6db7263c989f3b738f448d Mon Sep 17 00:00:00 2001 From: kraktus Date: Fri, 8 Nov 2024 08:53:45 +0100 Subject: [PATCH] Puzzle report: only report if the move is in the solution There was a catch where players would continue analysing the puzzle in the mainline, and reaching moves where there would be multiple good solutions --- ui/puzzle/src/report.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/puzzle/src/report.ts b/ui/puzzle/src/report.ts index 7fa5b87ea5e8..56ce2b64846c 100644 --- a/ui/puzzle/src/report.ts +++ b/ui/puzzle/src/report.ts @@ -36,7 +36,7 @@ export default class Report { // more resilient than checking the turn directly, if eventually puzzles get generated from 'from position' games const nodeTurn = node.fen.includes(' w ') ? 'white' : 'black'; if ( - node.ply >= ctrl.initialNode.ply && + nextMoveInSolution(node) && nodeTurn == ctrl.pov && ctrl.mainline.some((n: Tree.Node) => n.id == node.id) ) { @@ -99,3 +99,10 @@ export default class Report { }); }; } + +// since we check the nodes of the opposite side, to know if we're +// in the solution we need to check the following move +const nextMoveInSolution = (before: Tree.Node) => { + const node = before.children[0]; + return node && (node.puzzle === 'good' || node.puzzle === 'win'); +};