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);
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);
155 opt.
parse(argc,argv);
156 if (opt.size() >= n_examples) {
157 std::cerr <<
"Error: size must be between 0 and "
158 << n_examples-1 << std::endl;
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;
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
int n
Number of negative literals for node type.
Passing Boolean variables.
Boolean integer variables.
Parametric base-class for scripts.
static void run(const Options &opt, Script *s=NULL)
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 branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
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 .
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.
BoolValBranch BOOL_VAL_MAX(void)
Select largest value.
Post propagator for SetVar SetOpType SetVar y
Post propagator for SetVar x