Class MineSweeper
- Version:
- 4.9
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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
It executes the program to solve any MineSweeper problem.void
model()
It specifies a standard way of modeling the problem.static final String[]
One of the possible MineSweeper problems.static final String[]
problem1()
One of the possible MineSweeper problems.static final String[]
One of the possible MineSweeper problems.static final String[]
problem2()
One of the possible MineSweeper problems.static final String[]
problem3()
One of the possible MineSweeper problems.static final String[]
problem4()
One of the possible MineSweeper problems.static final String[]
problem5()
One of the possible MineSweeper problems.static final String[]
problem6()
One of the possible MineSweeper problems.static final String[]
problem7()
One of the possible MineSweeper problems.static final String[]
problem8()
One of the possible MineSweeper problems.static final String[]
problem9()
One of the possible MineSweeper problems.static final String[][]
problems()
The collection of MineSweeper problems.static final String[]
One of the possible MineSweeper problems.static int[][]
Reads a minesweeper file.static int[][]
readFromArray
(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 org.jacop.examples.fd.ExampleFD
creditSearch, getSearch, getSearchVariables, getStore, printMatrix, search, searchAllAtOnce, searchAllOptimal, searchLDS, searchMasterSlave, searchMaxRegretOptimal, searchMiddle, searchMostConstrainedStatic, searchOptimal, searchSmallestDomain, searchSmallestMedian, searchSmallestMiddle, searchSmallestMin, searchWeightedDegree, searchWithMaxRegret, searchWithRestarts, shavingSearch
-
Field Details
-
Constructor Details
-
MineSweeper
public MineSweeper()
-
-
Method Details
-
model
public void model()Description copied from class:ExampleFD
It specifies a standard way of modeling the problem. -
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
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.
-
problem1
One of the possible MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
problem2
One of the possible MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
problem3
One of the possible MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
problem4
One of the possible MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
problem5
One of the possible MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
problem6
One of the possible MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
problem7
One of the possible MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
problem8
One of the possible MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
problem9
One of the possible MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
problem10
One of the possible MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
problemTest
One of the possible MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
problem_kaye_splitter
One of the possible MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
problems
The collection of MineSweeper problems.- Returns:
- description of the problem used by the function to create a constraint model.
-
readFile
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
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.
-