MCPcopy Create free account
hub / github.com/Gecode/gecode / Bishops

Method Bishops

examples/crowded-chess.cpp:68–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66 return (i >= 0 && i < n) && (j >= 0 && j < n);
67 }
68 Bishops(int size)
69 : n(size), k(*this,n*n,0,1) {
70 Matrix<BoolVarArray> kb(k, n, n);
71 for (int l = n; l--; ) {
72 const int il = (n-1) - l;
73 BoolVarArgs d1(l+1), d2(l+1), d3(l+1), d4(l+1);
74 for (int i = 0; i <= l; ++i) {
75 d1[i] = kb(i+il, i);
76 d2[i] = kb(i, i+il);
77 d3[i] = kb((n-1)-i-il, i);
78 d4[i] = kb((n-1)-i, i+il);
79 }
80
81 linear(*this, d1, IRT_LQ, 1);
82 linear(*this, d2, IRT_LQ, 1);
83 linear(*this, d3, IRT_LQ, 1);
84 linear(*this, d4, IRT_LQ, 1);
85 }
86
87 linear(*this, k, IRT_EQ, 2*n - 2);
88 // Forced bishop placement from crowded chess model
89 rel(*this, kb(n-1, 0), IRT_EQ, 1);
90 rel(*this, kb(n-1, n-1), IRT_EQ, 1);
91 branch(*this, k, BOOL_VAR_DEGREE_MAX(), BOOL_VAL_MAX());
92 }
93 Bishops(Bishops& s) : Space(s), n(s.n) {
94 k.update(*this, s.k);
95 }

Callers

nothing calls this directly

Calls 6

BOOL_VAR_DEGREE_MAXFunction · 0.85
BOOL_VAL_MAXFunction · 0.85
linearFunction · 0.50
relFunction · 0.50
branchFunction · 0.50
updateMethod · 0.45

Tested by

no test coverage detected