ExamplesJaCoP
Class MineSweeper

java.lang.Object
  extended by ExamplesJaCoP.Example
      extended by ExamplesJaCoP.MineSweeper

public class MineSweeper
extends Example

It models and solves Minesweeper problem.

Author:
Hakan Kjellerstrand (hakank@bonetmail.com) and Radoslaw Szymanek This is a port of Hakan's MiniZinc model http://www.hakank.org/minizinc/minesweeper.mzn which is commented in the (swedish) blog post "Fler constraint programming-modeller i MiniZinc, t.ex. Minesweeper och Game of Life" http://www.hakank.org/webblogg/archives/001231.html See also The first 10 examples are from gecode/examples/minesweeper.cc http://www.gecode.org/gecode-doc-latest/minesweeper_8cc-source.html http://www.janko.at/Raetsel/Minesweeper/index.htm http://en.wikipedia.org/wiki/Minesweeper_(computer_game) Ian Stewart on Minesweeper: http://www.claymath.org/Popular_Lectures/Minesweeper/ Richard Kaye's Minesweeper Pages: http://web.mat.bham.ac.uk/R.W.Kaye/minesw/minesw.htm Some Minesweeper Configurations: http://web.mat.bham.ac.uk/R.W.Kaye/minesw/minesw.pdf

Field Summary
static java.lang.String[] problem_kaye_splitter
          One of the possible MineSweeper problems.
static java.lang.String[] problem1
          One of the possible MineSweeper problems.
static java.lang.String[] problem10
          One of the possible MineSweeper problems.
static java.lang.String[] problem2
          One of the possible MineSweeper problems.
static java.lang.String[] problem3
          One of the possible MineSweeper problems.
static java.lang.String[] problem4
          One of the possible MineSweeper problems.
static java.lang.String[] problem5
          One of the possible MineSweeper problems.
static java.lang.String[] problem6
          One of the possible MineSweeper problems.
static java.lang.String[] problem7
          One of the possible MineSweeper problems.
static java.lang.String[] problem8
          One of the possible MineSweeper problems.
static java.lang.String[] problem9
          One of the possible MineSweeper problems.
static java.lang.String[][] problems
          The collection of MineSweeper problems.
static java.lang.String[] problemTest
          One of the possible MineSweeper problems.
static int X
          It represents the unknown value in the problem matrix.
 
Fields inherited from class ExamplesJaCoP.Example
cost, search, store, vars
 
Constructor Summary
MineSweeper()
           
 
Method Summary
static void main(java.lang.String[] args)
          It executes the program to solve any MineSweeper problem.
 void model()
          It specifies a standard way of modeling the problem.
static int[][] readFile(java.lang.String file)
          Reads a minesweeper file.
static int[][] readFromArray(java.lang.String[] description)
          It transforms string representation of the problem into an array of ints representation.
 void searchSpecific(boolean recordSolutions)
          It executes special search with solution printing to present the solutions.
 
Methods inherited from class ExamplesJaCoP.Example
creditSearch, getSearch, getSearchVariables, getStore, printMatrix, search, searchAllAtOnce, searchAllOptimal, searchLDS, searchMasterSlave, searchMaxRegretOptimal, searchMiddle, searchMostConstrainedStatic, searchOptimal, searchSmallestDomain, searchSmallestMedian, searchSmallestMiddle, searchSmallestMin, searchWeightedDegree, searchWithMaxRegret, searchWithRestarts, shavingSearch
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X

public static int X
It represents the unknown value in the problem matrix.


problem1

public static java.lang.String[] problem1
One of the possible MineSweeper problems.


problem2

public static java.lang.String[] problem2
One of the possible MineSweeper problems.


problem3

public static java.lang.String[] problem3
One of the possible MineSweeper problems.


problem4

public static java.lang.String[] problem4
One of the possible MineSweeper problems.


problem5

public static java.lang.String[] problem5
One of the possible MineSweeper problems.


problem6

public static java.lang.String[] problem6
One of the possible MineSweeper problems.


problem7

public static java.lang.String[] problem7
One of the possible MineSweeper problems.


problem8

public static java.lang.String[] problem8
One of the possible MineSweeper problems.


problem9

public static java.lang.String[] problem9
One of the possible MineSweeper problems.


problem10

public static java.lang.String[] problem10
One of the possible MineSweeper problems.


problemTest

public static java.lang.String[] problemTest
One of the possible MineSweeper problems.


problem_kaye_splitter

public static java.lang.String[] problem_kaye_splitter
One of the possible MineSweeper problems.


problems

public static java.lang.String[][] problems
The collection of MineSweeper problems.

Constructor Detail

MineSweeper

public MineSweeper()
Method Detail

model

public void model()
Description copied from class: Example
It specifies a standard way of modeling the problem.

Specified by:
model in class Example

searchSpecific

public void searchSpecific(boolean recordSolutions)
It executes special search with solution printing to present the solutions.

Parameters:
recordSolutions - specifies if the solutions should be recorded.

readFromArray

public static int[][] readFromArray(java.lang.String[] description)
It transforms string representation of the problem into an array of ints representation.

Parameters:
description - array of strings representing the problem.
Returns:
two dimensional array of ints representing the problem.

readFile

public static int[][] readFile(java.lang.String file)
Reads a minesweeper file. File format: # a comment which is ignored % a comment which also is ignored number of rows number of columns < row number of neighbours lines... > 0..8 means number of neighbours, "." mean unknown (may be a mine) Example (from minesweeper0.txt) # Problem from Gecode/examples/minesweeper.cc problem 0 6 6 ..2.3. 2..... ..24.3 1.34.. .....3 .3.3..

Parameters:
file - it specifies the filename containing the problem description.
Returns:
the int array description of the problem.

main

public static void main(java.lang.String[] args)
It executes the program to solve any MineSweeper problem. It is possible to supply the filename containing the problem specification.

Parameters:
args - the filename containing the problem description.