44 using namespace Gecode;
52 extern const int *specs[];
93 : spec(specs[opt.
size()]),
94 width(spec[0]), height(spec[1]),
95 x(*this, (width+1)*height, 0, 28) {
99 IntArgs board((width+1)*height);
100 for (
int i=0;
i<width;
i++)
101 for (
int j=0; j<height; j++)
102 board[j*(width+1)+
i] = spec[j*width+
i];
105 for (
int i=0;
i<height;
i++) {
106 board[
i*(width+1)+8] = -1;
107 rel(*
this,
x[
i*(width+1)+8]==28);
119 int possibleDiffsA[] = {1, width+1};
120 IntSet possibleDiffs(possibleDiffsA, 2);
122 for (
int i=0;
i<=6;
i++)
123 for (
int j=
i; j<=6; j++) {
130 IntVar diff(*
this, possibleDiffs);
131 abs(*
this,
expr(*
this, p1[dominoCount]-p2[dominoCount]),
136 rel(*
this, p1[dominoCount],
IRT_LE, p2[dominoCount]);
139 element(*
this, board, p1[dominoCount],
i);
140 element(*
this, board, p2[dominoCount], j);
144 element(*
this,
x, p1[dominoCount], dominoCount);
145 element(*
this,
x, p2[dominoCount], dominoCount);
151 for (
int i=0;
i<=6;
i++)
152 for (
int j=
i; j<=6; j++) {
158 for (
int pos = 0;
pos < (width+1)*height; ++
pos) {
159 if ((
pos+1) % (width+1) != 0) {
160 if (board[
pos] ==
i && board[
pos+1] == j)
162 if (board[
pos] == j && board[
pos+1] ==
i &&
i != j)
165 if (
pos/(width+1) < height-1) {
166 if (board[
pos] ==
i && board[
pos+width+1] == j)
168 if (board[
pos] == j && board[
pos+width+1] ==
i &&
i != j)
173 piece[0] = p1[dominoCount];
174 piece[1] = p2[dominoCount];
180 element(*
this,
x, p1[dominoCount], dominoCount);
181 element(*
this,
x, p2[dominoCount], dominoCount);
188 for (
int i=0;
i<28;
i++) {
199 for (
int h = 0; h < height; ++h) {
201 for (
int w = 0; w < width; ++w) {
202 int val =
x[h*(width+1)+w].
min();
203 char c = val < 10 ?
'0'+val :
'A' + (val-10);
212 Script(share,s), spec(s.spec), width(s.width), height(s.height) {
213 x.update(*
this, share, s.x);
218 return new Domino(share,*
this);
234 opt.
parse(argc,argv);
235 if (opt.
size() >= n_examples) {
236 std::cerr <<
"Error: size must be between 0 and "
237 << n_examples-1 << std::endl;
240 Script::run<Domino,DFS,SizeOptions>(
opt);
254 const int domino0[] =
268 const int domino1[] =
282 const int domino2[] =
296 const int domino3[] =
310 const int domino4[] =
324 const int domino5[] =
339 {domino0,domino1,domino2,domino3,domino4,domino5};
341 const unsigned n_examples =
sizeof(specs)/
sizeof(
int*);