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

Method MineSweeper

examples/minesweeper.cpp:95–113  ·  view source on GitHub ↗

Actual model

Source from the content-addressed store, hash-verified

93public:
94 /// Actual model
95 MineSweeper(const SizeOptions& opt)
96 : Script(opt), spec(specs[opt.size()]),
97 size(spec_size(spec)),
98 b(*this,size*size,0,1) {
99 Matrix<BoolVarArray> m(b, size, size);
100
101 // Initialize matrix and post constraints
102 for (int h=0; h<size; h++)
103 for (int w=0; w<size; w++) {
104 int v = mineField(spec, size, h, w);
105 if (v != -1) {
106 rel(*this, m(w, h), IRT_EQ, 0);
107 linear(*this, fieldsAround(m, w, h), IRT_EQ, v);
108 }
109 }
110
111 // Install branching
112 branch(*this, b, BOOL_VAR_NONE(), BOOL_VAL_MAX());
113 }
114
115 /// Print solution
116 virtual void

Callers

nothing calls this directly

Calls 10

spec_sizeFunction · 0.85
mineFieldFunction · 0.85
mFunction · 0.85
BOOL_VAR_NONEFunction · 0.85
BOOL_VAL_MAXFunction · 0.85
relFunction · 0.50
linearFunction · 0.50
branchFunction · 0.50
sizeMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected