feat: add configurable removedCells option and comprehensive documentation
- Add removedCells to GameOptions for custom puzzle sizes - removedCells overrides difficulty default when provided - Maintain backward compatibility with all defaults - Complete IMPLEMENTATION.md with Iteration 16 and summary - Completely rewrite README.md with comprehensive documentation: - Complete API reference (GameOptions, GameManager, CursorManager, ScoreManager) - Game states and state machine flow - Full VIM controls reference (movement, editing, hints, game control) - Cell state rules and visual feedback - Detailed scoring formula with examples - Game-over conditions (time and hint limits) - Hint system priority and penalties - Configuration examples for different play styles - Platform hook integration guide - Mark implementation as COMPLETE and PRODUCTION READY
This commit is contained in:
@@ -14,14 +14,14 @@ export class SudokuGenerator {
|
||||
this.generate('medium');
|
||||
}
|
||||
|
||||
generate(difficulty: Difficulty = 'medium'): void {
|
||||
generate(difficulty: Difficulty = 'medium', customRemovedCells?: number): void {
|
||||
this.solution = this.generateSolvedBoard();
|
||||
|
||||
if (!this.validateFullBoard(this.solution)) {
|
||||
throw new Error('Generated invalid solved board');
|
||||
}
|
||||
|
||||
this.puzzle = this.makePuzzle(this.solution, difficulty);
|
||||
this.puzzle = this.makePuzzle(this.solution, difficulty, customRemovedCells);
|
||||
}
|
||||
|
||||
getSolution(): string {
|
||||
@@ -74,12 +74,12 @@ export class SudokuGenerator {
|
||||
return board.flat().join('');
|
||||
}
|
||||
|
||||
private makePuzzle(solution: string, difficulty: Difficulty): string {
|
||||
private makePuzzle(solution: string, difficulty: Difficulty, customRemovedCells?: number): string {
|
||||
if (solution.length !== 81 || !/^[1-9]+$/.test(solution)) {
|
||||
throw new Error('Invalid solved board: must be 81 digits 1–9');
|
||||
}
|
||||
|
||||
const removeCount = CELLS_TO_REMOVE[difficulty];
|
||||
const removeCount = customRemovedCells ?? CELLS_TO_REMOVE[difficulty];
|
||||
const board = solution.split('');
|
||||
|
||||
const indices = Array.from({ length: 81 }, (_, i) => i);
|
||||
|
||||
Reference in New Issue
Block a user