52 extern const int *specs[];
95 width(spec[0]), height(spec[1]),
96 x(*this, (width+1)*height, 0, 28) {
100 IntArgs board((width+1)*height);
101 for (
int i=0;
i<width;
i++)
102 for (
int j=0; j<height; j++)
103 board[j*(width+1)+
i] = spec[j*width+
i];
106 for (
int i=0;
i<height;
i++) {
107 board[
i*(width+1)+8] = -1;
108 rel(*
this,
x[
i*(width+1)+8]==28);
113 IntVarArgs p1(*
this, 28, 0, (width+1)*height-1);
114 IntVarArgs p2(*
this, 28, 0, (width+1)*height-1);
117 if (
opt.propagation() == PROP_ELEMENT) {
120 int possibleDiffsA[] = {1, width+1};
121 IntSet possibleDiffs(possibleDiffsA, 2);
123 for (
int i=0;
i<=6;
i++)
124 for (
int j=
i; j<=6; j++) {
131 IntVar diff(*
this, possibleDiffs);
132 abs(*
this,
expr(*
this, p1[dominoCount]-p2[dominoCount]),
137 rel(*
this, p1[dominoCount],
IRT_LE, p2[dominoCount]);
140 element(*
this, board, p1[dominoCount],
i);
141 element(*
this, board, p2[dominoCount], j);
145 element(*
this,
x, p1[dominoCount], dominoCount);
146 element(*
this,
x, p2[dominoCount], dominoCount);
152 for (
int i=0;
i<=6;
i++)
153 for (
int j=
i; j<=6; j++) {
159 for (
int pos = 0;
pos < (width+1)*height; ++
pos) {
160 if ((
pos+1) % (width+1) != 0) {
161 if (board[
pos] ==
i && board[
pos+1] == j)
163 if (board[
pos] == j && board[
pos+1] ==
i &&
i != j)
166 if (
pos/(width+1) < height-1) {
167 if (board[
pos] ==
i && board[
pos+width+1] == j)
169 if (board[
pos] == j && board[
pos+width+1] ==
i &&
i != j)
174 piece[0] = p1[dominoCount];
175 piece[1] = p2[dominoCount];
181 element(*
this,
x, p1[dominoCount], dominoCount);
182 element(*
this,
x, p2[dominoCount], dominoCount);
189 for (
int i=0;
i<28;
i++) {
200 for (
int h = 0; h < height; ++h) {
202 for (
int w = 0; w < width; ++w) {
203 int val =
x[h*(width+1)+w].
min();
204 char c = val < 10 ?
'0'+val :
'A' + (val-10);
213 Script(share,s), spec(s.spec), width(s.width), height(s.height) {
219 return new Domino(share,*
this);
236 if (
opt.size() >= n_examples) {
237 std::cerr <<
"Error: size must be between 0 and "
238 << n_examples-1 << std::endl;
241 Script::run<Domino,DFS,SizeOptions>(
opt);
255 const int domino0[] =
269 const int domino1[] =
283 const int domino2[] =
297 const int domino3[] =
311 const int domino4[] =
325 const int domino5[] =
340 {domino0,domino1,domino2,domino3,domino4,domino5};
342 const unsigned n_examples =
sizeof(specs)/
sizeof(
int*);