47 extern const char *specs[];
48 extern const unsigned int n_examples;
49 int spec_size(
const char *s);
50 int mineField(
const char *s,
int n,
int i,
int j);
91 if (ix !=
x || iy !=
y)
101 size(spec_size(spec)),
106 for (
int h=0; h<
size; h++)
107 for (
int w=0; w<
size; w++) {
108 int v = mineField(spec,
size, h, w);
122 for (
int h = 0; h <
size; ++h) {
124 for (
int w = 0; w <
size; ++w) {
125 int v = mineField(spec,
size, h, w);
128 else if (
pos(h,w).val() == 1)
141 b.update(*
this, share, s.b);
160 if (
opt.size() >= n_examples) {
161 std::cerr <<
"Error: size must be between 0 and " 162 << n_examples-1 << std::endl;
165 Script::run<MineSweeper,DFS,SizeOptions>(
opt);
183 const char* specs[] = {
282 const unsigned int n_examples =
sizeof(specs)/
sizeof(
char*);
286 int l = std::strlen(s);
287 int res = static_cast<int>(
std::sqrt(static_cast<float>(
l)));
293 assert(spec_size(s) ==
n);
294 assert(
i >= 0 &&
i <
n);
295 assert(j >= 0 && j <
n);
297 if (!std::isalnum(
c))
302 c = static_cast<char>(std::toupper(
c));
304 int res = (
c -
'A') + 10;
305 if (res >
n)
return 0;
Options for scripts with additional size parameter
BoolVarBranch BOOL_VAR_NONE(void)
Select first unassigned variable.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
int main(int argc, char *argv[])
Main-function.
const FloatNum max
Largest allowed float value.
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel)
Post propagator for .
bool pos(const View &x)
Test whether x is postive.
virtual void print(std::ostream &os) const
Print solution.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
Parametric base-class for scripts.
Gecode::FloatVal c(-8, 8)
Gecode::IntArgs i(4, 1, 2, 3, 4)
BoolValBranch BOOL_VAL_MAX(void)
Select largest value.
int n
Number of negative literals for node type.
void sqrt(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
unsigned int size(I &i)
Size of all ranges of range iterator i.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
MineSweeper(bool share, MineSweeper &s)
Constructor for cloning s.
int spec_size(const char *s)
Compute the size of a specification.
Passing Boolean variables.
Boolean integer variables.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
virtual Space * copy(bool share)
Copy space during cloning.
Post propagator for SetVar SetOpType SetVar y
int mineField(const char *s, int n, int i, int j)
Return value at position (i,j) in the example s of size n.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Post propagator for SetVar x
Matrix-interface for arrays.
Gecode toplevel namespace
MineSweeper(const SizeOptions &opt)
Actual model.