solve str8ts with prolog (puzzle like sudoku)

35 views
Skip to first unread message

Jörg

unread,
Feb 16, 2015, 3:13:54 PM2/16/15
to swi-p...@googlegroups.com
Hi, i want to solve str8ts with prolog.

problem is: first i set the constraints for all rows(fiels which are black and undefined are excluded first)

                 constraint 1: all_different(rowN)
                 constraint 2: rows ins 1..9

now i split every row into lists of white boxes --> and check if the group is gapless. if there is a variable undefined -> the variable is filled.

there is the problem. i only want so set the constraint, that the group has to be gapless... 

after i set the constraints for all rows and columns, i want to use labeling from clpfd libary. 

but i dont know how to set the constraint, that a group is gapless without set variables for the row/column.

I added my .pl 

this is a example puzzle:  
puzzle([[9,1],[6,0],[8,0],[1,0],[_,0],[_,0],[_,0],[4,0],[_,0],[_,0],[_,0],[_,1],[_,1],[4,0],[_,0],[_,0],[7,1],[_,1],[5,0],[_,1],[_,1],[_,0],[3,0],[_,0],[_,1],[_,1],[_,0],[_,0],[_,1],[_,0],[_,0],[_,0],[4,0],[6,1],[_,0],[_,0],[_,1],[_,0],[_,0],[_,0],[_,1],[_,0],[_,0],[_,0],[_,1],[3,0],[_,0],[_,1],[_,0],[5,0],[8,0],[_,0],[_,1],[_,0],[_,0],[_,1],[_,1],[_,0],[_,0],[_,0],[_,1],[5,1],[_,0],[_,1],[_,1],[5,0],[_,0],[_,0],[_,1],[4,1],[1,0],[_,0],[_,0],[7,0],[_,0],[_,0],[_,0],[_,0],[_,0],[_,0],[1,1]]).

any one can give me a tip?
straights.pl
Reply all
Reply to author
Forward
0 new messages