Complete tactic recognition module with tests and real-time integration
- Add comprehensive test suite (20 tests) for tactic detection - Fix pawn detection threshold bug (200 -> 100 centipawns) - Add error handling to uciToSan for invalid moves - Integrate tactical data into Tutor component for real-time feedback - Pass missedTactics from ChessGame to Tutor via props - Update LLM prompt to explain missed tactical opportunities - Fix Jest configuration to handle react-markdown ESM issues - All 50 tests passing
This commit is contained in:
@@ -15,7 +15,7 @@ import { GameAnalysisModal } from "./GameAnalysisModal";
|
||||
import { GameOverModal, MoveHistoryItem } from "./GameOverModal";
|
||||
import { Brain, ArrowLeft } from "lucide-react";
|
||||
import { CapturedPieces } from "./CapturedPieces";
|
||||
import { detectMissedTactics, uciToSan } from "@/lib/tacticDetection";
|
||||
import { detectMissedTactics, uciToSan, DetectedTactic } from "@/lib/tacticDetection";
|
||||
|
||||
interface ChessGameProps {
|
||||
initialFen?: string;
|
||||
@@ -46,6 +46,9 @@ export default function ChessGame({ initialFen, initialPgn, initialPersonality,
|
||||
// Opening Data
|
||||
const [openingData, setOpeningData] = useState<OpeningMetadata | null>(null);
|
||||
|
||||
// Tactical Analysis Data
|
||||
const [latestMissedTactics, setLatestMissedTactics] = useState<DetectedTactic[] | null>(null);
|
||||
|
||||
const [userMove, setUserMove] = useState<Move | null>(null);
|
||||
const [computerMove, setComputerMove] = useState<Move | null>(null);
|
||||
const [isAnalyzing, setIsAnalyzing] = useState(false);
|
||||
@@ -342,6 +345,9 @@ export default function ChessGame({ initialFen, initialPgn, initialPersonality,
|
||||
cpLoss,
|
||||
});
|
||||
|
||||
// Store the latest tactics for the Tutor component
|
||||
setLatestMissedTactics(missedTactics);
|
||||
|
||||
const completeHistoryItem: MoveHistoryItem = {
|
||||
...partialHistoryItem,
|
||||
computerMove: compResult.result.san,
|
||||
@@ -585,6 +591,7 @@ export default function ChessGame({ initialFen, initialPgn, initialPersonality,
|
||||
evalP0={evalP0}
|
||||
evalP2={evalP2}
|
||||
openingData={openingData}
|
||||
missedTactics={latestMissedTactics}
|
||||
onAnalysisComplete={() => { }}
|
||||
apiKey={apiKey}
|
||||
personality={selectedPersonality}
|
||||
|
||||
Reference in New Issue
Block a user