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

void Solver::set_first_at ( unsigned int  level  )  [virtual]

Set the element to the first sibling.

Implements BackTrack::Solution.

Definition at line 32 of file solver.cpp.

References Sudoku::Puzzle::next_free(), Sudoku::Puzzle::next_number(), Sudoku::Puzzle::numbers_count(), and Sudoku::Puzzle::set().

{
  assert(level < free_count);
  const Pos p = puzzle.next_free();
  assert (p <= Pos::last());

  free_list[level] = p;
  puzzle.set(p, 0);

  if (level == 0)
    random = random_init;

  unsigned int i, count = puzzle.numbers_count(p);
  if (count != 0)
  {
    puzzle.set(p, puzzle.next_number(p));

    if (random)
      for (count = rand(count), i = 0; i < count; ++i)
        puzzle.set(p, puzzle.next_number(p));
  }
  else
    puzzle.set(p, 1);
}


Generated by  Doxygen 1.6.0   Back to index