feat: implement real auto-solve that builds correct patches for all 96 levels
Replace the bypass auto-solve (which just set passed: true on all checks) with a legitimate solver that loads actual module configurations and connections via deserialize(), then validates through handleCheck(). Each solution defines the exact modules, parameters, and wiring needed to pass all 3-star checks for every level across all 12 worlds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import { playTarget, stopTarget, isTargetPlaying } from './targetAudio.js';
|
|||||||
import LevelComplete from './LevelComplete.jsx';
|
import LevelComplete from './LevelComplete.jsx';
|
||||||
import { completeLevel, saveLevelPatch, getLevelPatch, markHintUsed, wasHintUsed } from './gameState.js';
|
import { completeLevel, saveLevelPatch, getLevelPatch, markHintUsed, wasHintUsed } from './gameState.js';
|
||||||
import { playLevelComplete, playFail, playHint, playEngineStart, playEngineStop, playNav } from '../engine/uiSounds.js';
|
import { playLevelComplete, playFail, playHint, playEngineStart, playEngineStop, playNav } from '../engine/uiSounds.js';
|
||||||
|
import { SOLUTIONS } from './autoSolver.js';
|
||||||
|
|
||||||
export default function PuzzleView({ level, levelIndex, worldLevels, onBack, onNextLevel, adminMode }) {
|
export default function PuzzleView({ level, levelIndex, worldLevels, onBack, onNextLevel, adminMode }) {
|
||||||
const [, forceUpdate] = useState(0);
|
const [, forceUpdate] = useState(0);
|
||||||
@@ -285,15 +286,20 @@ export default function PuzzleView({ level, levelIndex, worldLevels, onBack, onN
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Admin auto-solve — gives 3 stars instantly
|
// Admin auto-solve — loads the actual solution modules/connections and validates naturally
|
||||||
const handleAutoSolve = () => {
|
const handleAutoSolve = () => {
|
||||||
const checks = level.checks.map(check => ({
|
const solution = SOLUTIONS[level.id];
|
||||||
...check,
|
if (!solution) {
|
||||||
passed: true,
|
console.warn(`No auto-solve solution for level ${level.id}`);
|
||||||
}));
|
return;
|
||||||
completeLevel(level.id, 3);
|
}
|
||||||
setResult({ stars: 3, checks, hintPenalty: false });
|
// Load the solution patch into the engine state
|
||||||
playLevelComplete();
|
deserialize(solution);
|
||||||
|
emit();
|
||||||
|
// Now run the normal check logic against the loaded patch
|
||||||
|
setTimeout(() => {
|
||||||
|
handleCheck();
|
||||||
|
}, 50);
|
||||||
};
|
};
|
||||||
|
|
||||||
const isLastLevel = levelIndex >= worldLevels.length - 1;
|
const isLastLevel = levelIndex >= worldLevels.length - 1;
|
||||||
|
|||||||
1913
src/game/autoSolver.js
Normal file
1913
src/game/autoSolver.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user