Results 1 to 5 of 5

Thread: Sudoku creator

  1. #1
    bob 6 is offline Java Rookie
    Join Date
    Aug 2012
    Posts
    20
    Rep Power
    0

    Question Sudoku creator

    So I want to program Sudoku, but before I got to the programming, I realized that I didn't know how to make the original board. Sure, I could make my program start with a full board and hide some numbers, but I wouldn't know if it was solvable or not anymore. Is there a simple way to make a solvable beginning?

    Thanks in advance!

  2. #2
    Jodokus's Avatar
    Jodokus is offline Senior Member
    Join Date
    Jan 2011
    Location
    Amsterdam, the Netherlands
    Posts
    230
    Rep Power
    4

    Default Re: Sudoku creator

    That must be easy, though I confess I didn't try.
    There are only four kinds of configuration for a board: illegal, solved (=legal and full), with one solution and with many solutions. I guess that you are interested in the kind with one solution and a minimal number of numbers already filled in.
    To recognize illegal and full must be trivial. To find one solution you use the algorithm of JosAH's blog on this forum:
    http://www.java-forums.org/blogs/josah/75-sudoku.html, and if you use more iterations until you find another solution it is in the many solutions category and so again you are not interested.
    So just write a genetic algorithm and reward one-solution solutions with a minimal filled-in-number-count and presto!
    No bug ever had to calculate its fitnessfunction.

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Sudoku creator

    Is there a simple way to make a solvable beginning?
    I think I read somewhere that this is an NP-Hard problem, so, I don't think so.

    When I implemented one years back, I started with solved puzzles and then removed some random set of values. I had to test after each removal though, to ensure I didn't make the puzzle unsolvable. It was very iterative and guess & check, but computers are fast and great at this kind of thing. Puzzle generation still only took milliseconds.

  4. #4
    bob 6 is offline Java Rookie
    Join Date
    Aug 2012
    Posts
    20
    Rep Power
    0

    Default Re: Sudoku creator

    Thanks for the answers! It seems like you either solve it using the given formula or use guess and check. I won't use the formula until I fully understand it(I just skimmed through it) and guess and check isn't really my style. I think I'll first make an AI for Tic-Tac-Toe, and come back to this tomorrow with a fresh mind. Again, thanks for the quick answers.

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,513
    Blog Entries
    7
    Rep Power
    20

    Default Re: Sudoku creator

    Quote Originally Posted by bob 6 View Post
    Thanks for the answers! It seems like you either solve it using the given formula or use guess and check. I won't use the formula until I fully understand it(I just skimmed through it) and guess and check isn't really my style. I think I'll first make an AI for Tic-Tac-Toe, and come back to this tomorrow with a fresh mind. Again, thanks for the quick answers.
    What formula?

    kind regards,

    Jos

    ps. did you read my blog artice? All it does is use back tracking.
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Sudoku checker
    By kennemercollege in forum New To Java
    Replies: 3
    Last Post: 04-27-2011, 12:41 PM
  2. Traversing through a sudoku grid.
    By Lil_Aziz1 in forum New To Java
    Replies: 2
    Last Post: 05-30-2010, 06:05 PM
  3. Error from sudoku class
    By hongi in forum New To Java
    Replies: 4
    Last Post: 05-08-2010, 02:08 PM
  4. Sudoku randomizer help
    By mochibon in forum New To Java
    Replies: 0
    Last Post: 04-07-2010, 03:05 AM
  5. SUDOKU game problem
    By bumblyb33 in forum AWT / Swing
    Replies: 2
    Last Post: 05-05-2009, 11:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •