O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Próximos SlideShares
Tic tac toe
Tic tac toe
Carregando em…3
×

Confira estes a seguir

1 de 4 Anúncio
Anúncio

Mais Conteúdo rRelacionado

Anúncio
Anúncio

Mais recentes (20)

P1

  1. 1. Project 4: Sodoku Solver Deadline: 11:30am, October 19th Read this document carefully and completely before you attempt to solve programming project 4. Description: It is a popular logic-based number placement game. The aim of the puzzle is to enter a numerical digit from 1 through 9 in each cell of a 99 grid made up of 33 sub grids (called boxes). The game starts with various digits given in some cells (the givens). When finished, each row, column, and 3x3 regions must contain all 9 digits with no repetition. Completing the game requires patience and logical ability. Here is an interesting site if you would like to try and play the game http://www.dkmsoftware.com/sudoku/ http://www.sudoku.com/ There are 3 simple rules you must follow when playing Sudoku. Fill in the grid so that 1) every row 2) every column 3) ever 3x3 box contains the digits 1 through 9. • row: This is a row that is 9 cells wide. A filed row must have one of each digit. That means that each digit appears only once in the row. There are 9 rows in the grid, and the same applies to each of them. • column: This is a column, 9 cells tall. A filled column consists of having one of each digit just like the row. This means each digit will appear only once in the column. There are 9 columns in a typical Sudoku grid, and the same applies to each of them. • box: This is a box containing 9 cells in a 3x3 layout. A filled box consists of having one of each digit just like the rows and columns. This means that each digit appears only once is in the box. There are 9 boxes in a typical Sudoku grid, and the same applies to each of them.
  2. 2. You will notice that the maroon colored digits are the “givens” and the gray shaded digits are the possible digits that can be added to the row, column or grid to satisfy the 3 rules above. Unsolved Solved Implementation: • bool Solve (): o You will implement a solve() function to solve your Sudoku grid. Your solve function should a recursive function, meaning that this function will call itself continuously until the game has been solved. Each recursive function will try different values applying each of the 3 rules and return a bool back to itself. If a FALSE is returned then the puzzle cannot be solved, and if a TRUE is returned the puzzle is solved. When your solve function has completed solving the game, your program will save the contents of solved or unsolved Suduko board. • Save (): o The save function will print the contents of solved Suduko board to the screen followed by solved. If the game cannot be solved then your program should print out what it had completed up until the point it determined the game is unsolvable followed by unsolved. • ostream operator o You will want to overload an ostream’s operator so that you can display a user defined object. Here is an example of overloading, http://gethelp.devx.com/techtips/cpp_pro/10min/10min0400.asp • You will also need to implement and default constructor, a copy constructor, a destructor and an assignment operator for your objects.
  3. 3. Your projects directory structure: • The same as described in project 3. You must comment your code using Doxygen. We will read you code using Doxygen generated documentation. • Running make should produce the prj_4 executable under the bin directory. Running ‘doxygen’ with the included Doxyfile should produce documentation under your doc/html directory • Your project should be up to date on the svn server for checkout when completed Getting Started: • svn checkout https://svn.cs.fsu.edu/repos/teamXY/prj_4 o Will be available shortly after midterm • Familiarizing yourself with the game and its rules at one of the websites listed above. • Read in input from file and populate your data structure to hold the values. o Consider using a 2D array and for each element in the array have a vector. Once you understand the rules, you will see that for every blank spot in the Sudoku board you will have a possible of 1-9 candidates to try. And whether those candidates work or not will depend upon the three Sudoku rules. So your vector will contain initially values 1 – 9 and as your populate your board you will update those values in the candidate vector for each cell in your Sudoku board. • Your solve function will be a recursive function that will call itself and try new values for each spot in the Sudoku board until all of the 3 rules are satisfied. o Consider perhaps making copies of your Sudoku objects and updating the candidate vectors of the board to reflect the new number that you have chosen.
  4. 4. Input and Output Format: Input: • Your program should take in input file containing the rows of initial information to populate your sudoku game to be solved. • usr@linrprog4:~/prj_4/bin/ prj_4 sudoku_input1 o Your input file should be in the following format. ********* 8**3*5**2 **6***9** *4*5*6*8* 7*1***4*9 ***9*1*** 97**6**35 **3***1** **4*2*7** Output: • Your program should output either the solved or the unsolved sudoku. o +---+---+---+ |425|697|318| |897|315|642| |136|482|957| +---+---+---+ |349|576|281| |751|238|469| |268|941|573| +---+---+---+ |972|164|835| |683|759|124| |514|823|769| +---+---+---+ Puzzles: 1, Solved 1, Unsolved: 0

×