1. Homepage
  2. Programming
  3. CSCI-GA 3033-009 Rigorous Software Development - Programming Project 1 - Perfect Minesweeper Solver

CSCI-GA 3033-009 Rigorous Software Development - Programming Project 1 - Perfect Minesweeper Solver

Engage in a Conversation
CSCI-GA 3033Rigorous Software DevelopmentMinesweeper SolverJava

Rigorous Software Development - Spring 2012 Thomas Wies CourseNana.COM

Programming Project 1 - Minesweeper Solver CourseNana.COM

  CourseNana.COM

Please submit your solution via email to the instructor with CC to ly603@nyu.edu. The CourseNana.COM

deadline for the project is May 18. CourseNana.COM


CourseNana.COM

CourseNana.COM

The goal of this project is to implement a minesweeper game together with a perfect minesweeper solver. The game is played on a two-dimensional grid of cells that may contain mines. The player wins the game if all cells containing mines have been marked. To obtain information about which cells may contain mines, the player can reveal cells. If a cell with a mine is revealed, the player loses. If the revealed cell does not contain a mine, it shows the number of neighboring cells that contain mines. This information can be used to deduce which of the unrevealed cells contains a mine and which does not. CourseNana.COM

A perfect minesweeper solver plays the minesweeper game without guessing which cells can be safely revealed, unless the current board con guration does not allow to deduce whether some unrevealed cell contains a mine or not. In particular, a perfect solver can be used to decide whether a given board con guration can be solved without guessing. Solving minesweeper games is closely related to the Minesweeper Consistency Problem, which asks whether, given a board con guration, there exists an assignment of mines to unrevealed CourseNana.COM

cells that is consistent with the con guration. For more information about this problem see Richard Kaye's Minesweeper Page1. CourseNana.COM

  CourseNana.COM

Part 1 Alloy Model of Minesweeper Game and Solver CourseNana.COM

  CourseNana.COM

In the first part of this project you will develop an Alloy Model of a minesweeper game and solver. CourseNana.COM

  CourseNana.COM

(a) Develop an Alloy model of minesweeper board configurations for abstract minesweeper games. In an abstract minesweeper game the board is an undirected graph with nodes representing cells and edges indicating which cells are neighbors. Other than that, abstract minesweeper games are played exactly like normal minesweeper games. Think about what properties you want the field encoding the neighbor relation to hold and add appropriate facts to your model. Simulate some board configurations. CourseNana.COM

  CourseNana.COM

(b) Think about invariants of board configurations that can occur while playing a minesweeper game and add appropriate predicates to your model. For instance, during a minesweeper game, marked cells are never revealed. Another important property is that the number of marked cells never exceeds the number of mines on the board. There are more such invariants that you want to specify. Simulate some board configurations both satisfying and violating your specified invariants. CourseNana.COM

  CourseNana.COM

(c) Specify the operations on board con gurations that you need for playing the game. These are: (1) mark a cell on the board, (2) unmark a cell on the board, and (3) reveal a cell on the board. You will also need to write a function that computes, for a cell, the number of neighboring cells that contain a mine. Make sure that revealing a cell is propagated, i.e., if a cell with no neighboring mines is revealed then all neighboring cells are also revealed. CourseNana.COM

  CourseNana.COM

(d) Write assertions checking whether your operations preserve all the invariants of board configurations that you have speci ed. If some invariant is violated by an operation, add an appropriate precondition to the operation. CourseNana.COM

  CourseNana.COM

(e) Write a predicate that holds true for board configurations that are safe, i.e. do not contain a revealed mine. Write another predicate that holds true for configurations that are won, i.e., on which all unrevealed mines are marked. Use these predicates and your operations on minesweeper boards to simulate some minesweeper plays, both winning and losing. CourseNana.COM

  CourseNana.COM

(f) Write a predicate that holds true for consistent board con guration according to the Minesweeper Consistency Problem. Simulate some consistent and inconsistent boards. CourseNana.COM

Use your consistency predicate to write a perfect minesweeper solver and use your solver to solve some minesweeper boards. Make sure that your solver does not cheat by directly accessing the fields that encode which cells contain mines. You can do this by declaring these fields private and putting your consistency predicate and the solver into a separate module. CourseNana.COM

  CourseNana.COM

Part 2 Minesweeper Game and Solver in Java CourseNana.COM

  CourseNana.COM

In Part 2 of the project you will implement the minesweeper game and solver in Java. We will restrict ourselves to the classic mine sweeper game played on a two-dimensional grid. CourseNana.COM

(a) Implement the actual minesweeper game with the board and all board operations such as revealing cells, marking cells, and determining the number of neighboring mines of revealed cells. The board and its operations should be encapsulated in a class that provides all the functionality for a client (such as the solver) to play the game. Make sure that your class does not expose information to clients that should not be directly accessible by a player of mine sweeper, such as which unrevealed cells actually contain mines. Also it should not be possible for a client to undo a reveal operation. The board class is allowed to expose the total number of hidden mines, though. CourseNana.COM

  CourseNana.COM

(b) Implement a simple parser for board con gurations and add code to create instances of your board class from the parsed input  les. The input  le format is a text file with one line for each row of the board and each line consisting of a (white) space separated list of entries, one entry for each cell in the row. Each entry is one of the characters 'H', 'M', and 'R  where 'H' speci es that the cell is not revealed and does not contain a mine, 'M' speci es that the cell is not revealed and contains a mine, and 'R' speci es that the cell is revealed and does not contain a mine. Figure 1 shows two examples of boards encoded in the input format. CourseNana.COM

  CourseNana.COM

(c) Transfer the invariants on board con gurations, as well as the pre- and post-conditions 0of the board operations that you discovered in Phase 1 from Alloy to JML. Add these CourseNana.COM

  CourseNana.COM

H H M M CourseNana.COM

H H M H CourseNana.COM

H H H H CourseNana.COM

H H M M H H CourseNana.COM

H R R R R H CourseNana.COM

M R R R R M CourseNana.COM

M R R R R M CourseNana.COM

H R R R R H CourseNana.COM

H H M M H H CourseNana.COM

  CourseNana.COM

  CourseNana.COM

Figure 1: Two boards encoded in the input  le format. The left-hand side shows CourseNana.COM

the encoding of a board consisting of three rows and four columns in which all cells are hidden. The right-hand side shows the encoding of a board with six rows and six columns in which some of the cells are already revealed. CourseNana.COM

speci fications to your board class and test them using runtime assertion checking. You CourseNana.COM

may use JMLUnit for generating unit tests, but this is not mandatory. CourseNana.COM

(d) Implement a perfect minesweeper solver as a client of your board class. The solver should CourseNana.COM

print all the solving steps to standard out. If the cell in the i-th column and j-th row CourseNana.COM

is revealed, it should print reveal i j. Similarly, if the cell in the i-th column and CourseNana.COM

j-th row is marked, it should print mark i j. Note that rows and columns should be indexed starting from 0. If a solving step was guessed, then this should also be recorded, by printing guess reveal i j, respectively, guess mark i j. The  nal outcomeof the game should be recorded by printing either game lost or game won. A possibleoutput of your solver generated for solving the board on the left-hand side of Figure 1is: CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
CSCI-GA 3033代写,Rigorous Software Development代写,Minesweeper Solver代写,Java代写,CSCI-GA 3033代编,Rigorous Software Development代编,Minesweeper Solver代编,Java代编,CSCI-GA 3033代考,Rigorous Software Development代考,Minesweeper Solver代考,Java代考,CSCI-GA 3033help,Rigorous Software Developmenthelp,Minesweeper Solverhelp,Javahelp,CSCI-GA 3033作业代写,Rigorous Software Development作业代写,Minesweeper Solver作业代写,Java作业代写,CSCI-GA 3033编程代写,Rigorous Software Development编程代写,Minesweeper Solver编程代写,Java编程代写,CSCI-GA 3033programming help,Rigorous Software Developmentprogramming help,Minesweeper Solverprogramming help,Javaprogramming help,CSCI-GA 3033assignment help,Rigorous Software Developmentassignment help,Minesweeper Solverassignment help,Javaassignment help,CSCI-GA 3033solution,Rigorous Software Developmentsolution,Minesweeper Solversolution,Javasolution,