Logo Search packages:      
Sourcecode: vdr-plugin-sudoku version File versions  Download package

Sudoku::Generator Class Reference

#include <generator.h>

Inheritance diagram for Sudoku::Generator:

BackTrack::Algorithm BackTrack::Solution

List of all members.


Detailed Description

Implementation of a backtracking algorithm to generate Sudoku puzzles

To generate Sudoku puzzles two nested backtracking algorithms are used. First a random Sudoku solution is searched. Then the algorithm tries to remove some numbers so that only the requested number of givens remains. Each puzzle is checked with the nested solver algorithm if there is only one solution.

Example:

 Puzzle puzzle;
 Generator generator(puzzle, 36);
 generator.find_next_solution();
 bool found = generator.solution_is_valid();

Definition at line 39 of file generator.h.


Public Member Functions

void find_next_solution ()
 Generator (Puzzle &puzzle, unsigned int givens_count, bool symmetric=true, unsigned int max_iter=0)
virtual bool is_last_at (unsigned int level) const
virtual bool is_last_level (int level) const
virtual bool is_valid_at (int level) const
void reset ()
virtual void reset_at (unsigned int level)
virtual void set_first_at (unsigned int level)
virtual void set_next_at (unsigned int level)
bool solution_is_valid ()

Private Attributes

bool free_center
unsigned int free_count
unsigned int free_list [SDIM]
unsigned int pos_count
Pos pos_list [SDIM]
Puzzlepuzzle
Puzzle sudoku
bool symmetric

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index