Go to the documentation of this file.
43 extern const char *specs[];
44 extern const unsigned int n_examples;
45 int spec_size(
const char *s);
46 int mineField(
const char *s,
int n,
int i,
int j);
87 if (ix !=
x || iy !=
y)
97 size(spec_size(spec)),
102 for (
int h=0; h<
size; h++)
103 for (
int w=0; w<
size; w++) {
104 int v = mineField(spec,
size, h, w);
118 for (
int h = 0; h <
size; ++h) {
120 for (
int w = 0; w <
size; ++w) {
121 int v = mineField(spec,
size, h, w);
124 else if (
pos(h,w).val() == 1)
137 b.update(*
this, s.b);
156 if (
opt.size() >= n_examples) {
157 std::cerr <<
"Error: size must be between 0 and "
158 << n_examples-1 << std::endl;
161 Script::run<MineSweeper,DFS,SizeOptions>(
opt);
179 const char* specs[] = {
278 const unsigned int n_examples =
sizeof(specs)/
sizeof(
char*);
282 int l = std::strlen(s);
283 int res =
static_cast<int>(
std::sqrt(
static_cast<float>(
l)));
289 assert(spec_size(s) ==
n);
290 assert(
i >= 0 &&
i <
n);
291 assert(j >= 0 && j <
n);
293 if (!std::isalnum(
c))
298 c =
static_cast<char>(std::toupper(
c));
300 int res = (
c -
'A') + 10;
301 if (res >
n)
return 0;
Post propagator for SetVar x
Post propagator for SetVar SetOpType SetVar y
virtual void print(std::ostream &os) const
Print solution.
unsigned int size(I &i)
Size of all ranges of range iterator i.
virtual Space * copy(void)
Copy space during cloning.
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.
int spec_size(const char *s)
Compute the size of a specification.
Gecode toplevel namespace
Passing Boolean variables.
Parametric base-class for scripts.
void sqrt(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Boolean integer variables.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
BoolValBranch BOOL_VAL_MAX(void)
Select largest value.
Matrix-interface for arrays.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel)
Post propagator for .
MineSweeper(const SizeOptions &opt)
Actual model.
MineSweeper(MineSweeper &s)
Constructor for cloning s.
int mineField(const char *s, int n, int i, int j)
Return value at position (i,j) in the example s of size n.
Gecode::FloatVal c(-8, 8)
int n
Number of negative literals for node type.
Gecode::IntArgs i({1, 2, 3, 4})
bool pos(const View &x)
Test whether x is postive.
BoolVarBranch BOOL_VAR_NONE(void)
Select first unassigned variable.
const FloatNum max
Largest allowed float value.
Options for scripts with additional size parameter