43 extern const char *
specs[];
71 const BoolVar pos(
int h,
int w)
const {
79 for (
int ix =
std::max(0,
x-1); ix<=
x+1 && ix<size; ix++)
80 for (
int iy =
std::max(0,
y-1); iy<=
y+1 && iy<size; iy++)
85 for (
int ix =
std::max(0,
x-1); ix<=
x+1 && ix<size; ix++)
86 for (
int iy =
std::max(0,
y-1); iy<=
y+1 && iy<size; iy++)
87 if (ix !=
x || iy !=
y)
98 b(*this,size*size,0,1) {
102 for (
int h=0; h<size; h++)
103 for (
int w=0; w<size; w++) {
118 for (
int h = 0; h < size; ++h) {
120 for (
int w = 0; w < size; ++w) {
124 else if (pos(h,w).val() == 1)
136 Script(s), spec(s.spec), size(s.size) {
137 b.update(*
this, s.b);
157 std::cerr <<
"Error: size must be between 0 and "
161 Script::run<MineSweeper,DFS,SizeOptions>(
opt);
282 int l = std::strlen(s);
283 int res =
static_cast<int>(
std::sqrt(
static_cast<float>(
l)));
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;
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
int n
Number of negative literals for node type.
Node * x
Pointer to corresponding Boolean expression node.
const unsigned int n_examples
The number of examples.
const int * specs[]
Board specifications.
Passing Boolean variables.
Boolean integer variables.
Parametric base-class for scripts.
Matrix-interface for arrays.
Options for scripts with additional size parameter
int main(int argc, char *argv[])
Main-function.
int spec_size(const char *s)
Compute the size of a specification.
const char * specs[]
The specifications.
int mineField(const char *s, int n, int i, int j)
Return value at position (i,j) in the example s of size n.
MineSweeper(MineSweeper &s)
Constructor for cloning s.
virtual Space * copy(void)
Copy space during cloning.
MineSweeper(const SizeOptions &opt)
Actual model.
virtual void print(std::ostream &os) const
Print solution.
void parse(int argc, char *argv[])
Parse commandline arguments.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
void branch(Home home, const IntVarArgs &x, const BoolVarArgs &y, IntBoolVarBranch vars, IntValBranch vals)
Branch function for integer and Boolean variables.
const FloatNum max
Largest allowed float value.
Gecode toplevel namespace
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel ipl=IPL_DEF)
Post propagator for .
BoolVarBranch BOOL_VAR_NONE(void)
Select first unassigned variable.
void sqrt(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
BoolValBranch BOOL_VAL_MAX(void)
Select largest value.
Post propagator for SetVar SetOpType SetVar y
Gecode::FloatVal c(-8, 8)
Gecode::IntArgs i({1, 2, 3, 4})