48 extern const int *specs[];
91 width(spec[0]), height(spec[1]),
92 x(*this, (width+1)*height, 0, 28) {
96 IntArgs board((width+1)*height);
97 for (
int i=0;
i<width;
i++)
98 for (
int j=0; j<height; j++)
99 board[j*(width+1)+
i] = spec[j*width+
i];
102 for (
int i=0;
i<height;
i++) {
103 board[
i*(width+1)+8] = -1;
104 rel(*
this,
x[
i*(width+1)+8]==28);
109 IntVarArgs p1(*
this, 28, 0, (width+1)*height-1);
110 IntVarArgs p2(*
this, 28, 0, (width+1)*height-1);
113 if (
opt.propagation() == PROP_ELEMENT) {
116 int possibleDiffsA[] = {1, width+1};
117 IntSet possibleDiffs(possibleDiffsA, 2);
119 for (
int i=0;
i<=6;
i++)
120 for (
int j=
i; j<=6; j++) {
127 IntVar diff(*
this, possibleDiffs);
128 abs(*
this,
expr(*
this, p1[dominoCount]-p2[dominoCount]),
133 rel(*
this, p1[dominoCount],
IRT_LE, p2[dominoCount]);
136 element(*
this, board, p1[dominoCount],
i);
137 element(*
this, board, p2[dominoCount], j);
141 element(*
this,
x, p1[dominoCount], dominoCount);
142 element(*
this,
x, p2[dominoCount], dominoCount);
148 for (
int i=0;
i<=6;
i++)
149 for (
int j=
i; j<=6; j++) {
155 for (
int pos = 0;
pos < (width+1)*height; ++
pos) {
156 if ((
pos+1) % (width+1) != 0) {
157 if (board[
pos] ==
i && board[
pos+1] == j)
159 if (board[
pos] == j && board[
pos+1] ==
i &&
i != j)
162 if (
pos/(width+1) < height-1) {
163 if (board[
pos] ==
i && board[
pos+width+1] == j)
165 if (board[
pos] == j && board[
pos+width+1] ==
i &&
i != j)
175 element(*
this,
x, p1[dominoCount], dominoCount);
176 element(*
this,
x, p2[dominoCount], dominoCount);
183 for (
int i=0;
i<28;
i++) {
194 for (
int h = 0; h < height; ++h) {
196 for (
int w = 0; w < width; ++w) {
197 int val =
x[h*(width+1)+w].
min();
198 char c = val < 10 ?
'0'+val :
'A' + (val-10);
207 Script(s), spec(s.spec), width(s.width), height(s.height) {
230 if (
opt.size() >= n_examples) {
231 std::cerr <<
"Error: size must be between 0 and "
232 << n_examples-1 << std::endl;
235 Script::run<Domino,DFS,SizeOptions>(
opt);
249 const int domino0[] =
263 const int domino1[] =
277 const int domino2[] =
291 const int domino3[] =
305 const int domino4[] =
319 const int domino5[] =
334 {domino0,domino1,domino2,domino3,domino4,domino5};
336 const unsigned n_examples =
sizeof(specs)/
sizeof(
int*);