Sudoku game programs

Source: Internet
Author: User

About Sudoku:
Sudoku is an intelligent game. A 9*9 Board with nine rows and nine columns and nine 3*3 9 cells that do not match each other. Some grids have been filled with numbers from 1 to 9. Players are required to fill in numbers 1-9 in the remaining spaces so that each row, column, and each 3*3 9 cells exactly contain one number. The sudoku game ensures the existence and uniqueness of the results.
Example:

I downloaded some online Sudoku game programs, so I decided to develop one by myself.
Current game features:
I) randomly generate any number of games (theoretically 2 ^ 96 = 79228162514264337593543950336 different games)
Ii) The game is divided into four different levels (entry level, advanced level, expert level, backbone level)
Iii) provide a human-friendly prompt by simulating a manual solution to the sudoku problem, and almost all games can be solved simply with the prompt.
Iv) provides the try function (use shift to add the number key or the left mouse button)
V) You can customize the game. You can directly input the game or copy the game through the clipboard.
Vi) You can copy the computer simulated manual solution process to the clipboard (CTRL + U key) and use the manual reasoning method: unique number, implicit unique number, number pair, and implicit number pair, unique rectangle method, three-Chain number, implicit three-Chain number, four-Chain number, implicit four-Chain number, area cut-down method, rectangle method (X-WING, swordfish, jellyfish ), association deletion method (forcing chain), etc.

Vii) voice prompt function (m-key speech switch function)
Viii) Graphical playback of historical records
Ix) The Voice command function is added to the latest version 2.4.

Latest download link (932 K) (version 2.4.1 ):

1: unlimited Sudoku version 2.41 Installer (932 K, add voice command function)

2: http://download.csdn.net/source/273047 (available only for csdn Users)

Game Description:

1. Playing the game:
 

For example, in the number of candidates display mode, the computer automatically displays all the candidates in the unfilled lattice in the game. Among them, the black big number is the number set in advance for the game, the blue big number is the number filled by the player, and the black small number is the number of candidates for each grid. However, in the non-candidate number mode, the computer does not display the number of candidates.
You can play games with the mouse or keyboard. Click a candidate number (only used in the Candidate number display mode) or press the number key to select a number from 1 to 9. Right-click or press Ctrl and the number key at the same time to reduce or add the number of candidates (only used in the Candidate number display mode ). Press h or Ctrl + H to get the prompt.

Show some candidates: Only keyboard operations are supported. Press Ctrl + Shift + number key 1-9 to display only candidates 1-9. CTRL + Shift + 0 show all candidates. When displaying the number of candidates, you can also use the left and right keys to change the number of currently displayed candidates.

The game also provides the Undo and redo functions with no limit on the number of steps. At any time, you can use the menu item "Edit/cancel" or the hot key Ctrl + Z to cancel the previous operation. You can use Ctrl + Y to redo the canceled steps. Bulk cancel: Right-click a data set by the user. This cancels the data in the grid and all the steps after setting this number are canceled. Similarly, if you right-click a number of candidates that have been dimmed (deleted by inference) (only used in the Candidate number display mode), the implicit step of this number of candidates will be canceled, all subsequent steps are also canceled. After bulk cancellation, you can also select the menu item "redo" to re-use these canceled steps. If the operation is incorrect (for example, accidentally right-click a grid ), you can press SHIFT + Y to redo all canceled steps.
At any time, we can also use the SHIFT + z key to check whether there is an error in the previous game process. If there is an error, the computer will automatically cancel all the wrong steps.

In the candidate data display mode, you can press shift and select a number with the mouse to try to use the data. The computer will tag the selected data, for example, if the H7 and B2 cells are marked with T1 and t2respectively, the user first tried h6 = 4 and then b2 = 5. in the non-candidate number display mode, you can use the try function through SHIFT + number key.
In the event of a conflict in the game (failed attempts), you can press shift and right-click to select a tried grid (usually select the largest tag grid ), in this way, the computer considers this attempt to fail and will return to the status before the attempt and automatically remove the number of candidates for this error. You can also right-click the grid without holding down shift. In this case, you only use the normal batch Undo function to the status before using this attempt.

The copy and paste functions allow you to input and output the game. At any time, press Ctrl + C or use the menu item "Edit/copy" to copy the current game situation (all data filled with grids are copied) to the clipboard in text format; then the user can copy the situation to any place. If you want to copy the Starting Status of the game, press Ctrl + R to start the game, and then copy the game. If you want to restore the game to the starting status, use SHIFT + Y to return to the previous step. similarly, for a Sudoku game that exists in the form of text elsewhere, you can copy it to the clipboard first, switch to the game and press Ctrl + V or use the menu item "Edit/paste" to set the current game to this game. The computer tries its best to guess the format of the user input, but it cannot be guaranteed that the operation is always successful. For games that cannot be input by pasting, you can enter the game by using the menu item "file/manual input". After selecting this menu item, enter the predefined number with the mouse or keyboard in turn, after the input is complete, select the menu item "file/complete manual input" to end the game input. The computer will automatically determine whether the input is only a unique solution.

In the do not show candidate quantity mode, click any square with the left mouse button. the status bar displays all candidate numbers in this square.
Press the r key at any time to display the number of candidates in the row where the mouse is located.
Press the C key at any time to display the number of candidates in the column where the mouse is located
Press the B key at any time to display the cursor's cell list

History browsing
In the history browsing mode, you can use the left and right keys to browse previous Games. The computer guesses the strategies used by the players and displays them in the graphic mode. Press the home and end keys to go to the start and end statuses. Press ESC to exit the historical mode.

In the historical mode, press Ctrl + u to copy the user's answer process to the clipboard in text mode, instead of in the historical mode. Using Ctrl + u, the computer automatically generates a manual answer process, copy the clipboard as text.

4. The computer provides the methods used in the prompt:
Now we provide: unique number, implicit unique number, number pair, implicit number pair, unique rectangle method, three-Chain number, implicit three-Chain number, four-Chain number, and implicit four-Chain number, area cut-down method, rectangle method (X-WING, swordfish, jellyfish), join number cut-down method (forcing chain)

5. Division of game difficulty:
Entry level: games that can be solved by using a unique number, implicit unique number, And a number pair
Advanced: In addition to entry-level methods, you also need to use implicit number pairs, Region deletions, and three links.
Expert Level: the method provided in section 4 in addition to the join number cut-down method can be used to find the result, but it is not enough to use only the advanced method.
Hardcore: problems that can be solved only by using the association number cut-down method

6. game skills (and computer Tips)
I) unique number Method

If we find that there is only one available candidate number in a grid, this grid must be the number, which is the unique number method.
In the following example, there are only three unique candidates in the H5 lattice.

If the candidate number mode is not used, the prompt information is shown in figure


Ii) Implicit unique number Method

If we find that a certain column in a row or a candidate number in a certain palace appears only in a grid, this grid must be this number. This is the implicit unique number method, as shown in the following example, the number of candidates in the 3rd column is 4 only in the lattice I3. the software also provides a mode for displaying a single number of candidates. In a single number of candidates mode, it is easier for us to find the implicit unique number. For example, press Ctrl + Shift + 4 here, then the software will show only the number of candidates 4. In this mode, we can easily see that 4 in I3 is the implicit unique number.

If the candidate number mode is not used, the following message is displayed:

We can also use a single candidate number pattern for the implicit unique candidate number method (as well as the range cut-down method and various rectangular methods). For example, for this example
We can press Ctrl + Shift + 4 to display only the number of candidates 4. As shown in the following figure, 4 in I3 is the implicit unique number.

Iii) number pair Method

If we find that there are two grids in a certain column of a row or in a certain palace that only use two candidate numbers, then these two grids must be exactly the two numbers, then in this unit (row, in columns, or jiugong), the two candidates are not displayed in other grids. This is the number pair method. For example, in the first column, the number of candidates for B1 and G1 is 7 or 8; the number of candidates in D1 and H1, 7 or 8, can be deleted.

Iv) three-Chain number Method

If we find that only three candidate numbers are used for three grids in a column or in a row, these three grids must be exactly the three numbers, in this unit (row, column, or jiugong), the three candidate numbers will not appear in other cells. This is the three-Chain number method, as shown in the following example,
In the bottom middle of the ninth Palace, only the candidate numbers 2, 8, and 6 are used for the H4, H5, and I5 grids. Therefore, you can delete the 8 and 6 cells in G4, G6, and I6.

V) Four-Chain number Method

If we find that only four candidate numbers are used in four grids in a column or in a row, these four grids must be exactly the four numbers, then in this unit (row, in columns, or jiugong), the four candidates are not displayed in other grids. This is the four-Chain number method.
The four cells A5, B5, C4, and C5 in the middle of the ninth Palace only use numbers 1, 2, 3, and 4; so the other four cells A4, A6, B4, the numbers 1, 2, 3, and 4 that appear in C6 can be deleted.

Vi) Implicit number pair Method

If we find that two candidate numbers appear only in two grids in a certain column of a row or in a certain Palace, the two grids must be exactly the two numbers, the other candidate numbers in the two grids can be deleted, which is the implicit number pair method. For example, in Row A, only the lattice A7 and A8 use numbers 6 and 8; therefore, all other numbers 2, 5, and 9 in the two grids can be deleted.

Vii) Implicit three-Chain number Method

If we find that three candidate numbers appear only in three grids in a column or in a row, the three grids must be exactly the three numbers, the number of other candidates in the three cells can be deleted. This is the implicit three-Chain number method. For example, in the following example, only the numbers 1, 3, and 4 are used in the 8th columns, such as C8, F8, and G8; so other numbers 6, 7, and 8 that appear in the lattice F8 can be deleted.

Viii) Implicit four-Chain number Method

If we find that there are four candidates in a certain column in a certain row or in a certain Palace only appear in four grids, then these four grids must be exactly the four numbers, the number of other candidates in the four cells can be deleted. This is the implicit four-Chain number method. We can use the example in the four-Chain number to find that only the grids A4, A6, and, b4 and C6 use four numbers, 5, 6, 7, and 9. Therefore, the other numbers, 1, 2, and 4 can be deleted.

Ix) region deletion method

If we find that a candidate number is in the intersection of the same unit in a certain unit (row, column, and jiugong), then in another unit, the number of candidates that are not in the intersection must be deleted. In the example below, all the numbers 5 in Row D are in the ninth Palace in the middle of the left, so in this ninth Palace, the number of candidates not in Row D 5 (in E3) can be deleted. In this software, we can also use the single candidate number display mode to more easily Discover Opportunities for Region pruning.

X) rectangle method

If a candidate number appears in only one or two rows (columns), the two rows (columns) are not) the number of candidates can be deleted. In the following example, the number of candidates in Row C and row F is exactly two and appear in columns 1st and 8th; therefore, the candidate numbers 3 (A8, d1, d8, i1, i8) that are not in Row C and row F can be deleted from columns 1st and 8th. The rectangle method can also be found when a single candidate number is displayed.

Extend it to three or four rows to obtain the high-order rectangle method. In the following example, we can delete the blue candidate number 6.

In the following example, pink 4 can be deleted.

Xi) Unique rectangle method

The last unique rectangle method is added. This method utilizes the uniqueness feature of the result of the number independence: if there are four grids that constitute the vertex of the rectangle, only two digits are used, in addition, if the grids in the same row or column are in the same grid, the results of this situation will not be unique (exchange the numbers they use can also obtain legal Sudoku results ), it is definitely not a legal Sudoku situation. Through this conclusion, we can obtain two kinds of deletions:
For example, in A3, C3, A9, and C9, C3 cannot take the number of candidates 1 and 9 (otherwise the results are not unique), so C3 can only take the number of candidates 5

For example, there must be 3 in D2 and F2. Otherwise, D2, F2, D9, and F9 can only be numbers 1 and 9, and the result must not be unique.
From this, we can further conclude that H2 in the 2nd Column cannot take 3 (it can also be concluded that F3 cannot take 3 in the left middle lattice)

Xii) join number deletion method

The number of candidates to be deleted is determined by finding a string of strongly correlated data.
For example, there are only three candidates for G9 and D9 in column 9th. They are strongly correlated data, and D4 and i4. If there are only two candidates in a grid, we think the two candidates are strongly correlated.
In addition, data 3 is used in the same row between D9 and D4, which is weak Association. Two different candidate numbers in a grid can also be considered weak Association. In this way, a series of strong/weak associations can be used to replace weak associations ),
If we can get a contradiction chain. For example, we can use logical reasoning in the prompt to exclude G6 = 3 (in fact, we can also exclude i7 = 3 and i8 = 3)

The following is a more complex example where multiple candidate values are used:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.