imagine a 2d map with 6 regions R1-R6. Each region should be colored in with 1 of 4 colors, but no adjacent regions can be the same color.
here is my code:
% #1 initial facts
next(red,green).
next(red,blue).
next(red,yellow).
next(green,red).
next(green,blue).
next(green,yellow).
next(blue,green).
next(blue,yellow).
next(blue,red).
next(yellow,red).
next(yellow,blue).
next(yellow,green).
% #1 actual program
color(R1,R2,R3,R4,R5,R6).
color(R1,R2,R3,R4,R5,R6):-
% region adjacency relations
next(R1,R2),
next(R1,R3),
next(R1,R4),
next(R2,R4),
next(R2,R5),
next(R3,R4),
next(R3,R6),
next(R4,R5),
next(R4,R6).
Expected output:
R1= red, R2= blue, R3= blue, R4= green, R5= red, R6= red
My Output:
true
what am I doing wrong? Is this even wrong? Even if my code is successfully finding the right color configuration, how do I get it to print out its findings?
color/6
. You get the solution you expect (as one among many different solutions) if you simply remove that first clause.