BACKGROUND OF THE INVENTION
1. Field of the Invention
This application relates to methods and computer software for creating games, such as creating puzzles.
2. Description of the Related Art
Number place puzzles are readily available in the market place although little or no information if available regarding how the puzzles were created. Software that assists with solving number place puzzles is also available although software that actually solves the puzzles is not widely distributed if available. Of course, software that can solve number place puzzles would be most valuable in creating number place puzzles.
The absence of software to create number place puzzles indicates a need for public disclosure of a suitable method and software for making number place puzzles to promote development of useful arts.
SUMMARY OF THE INVENTION
A method and computer software are provided for making number place puzzles. Numbers and unknowns are represented by variables that are assigned values such as by a plurality of nested loops. Instructions within each loop limit access to embedded loops until all assigned values form a valid solution. When some of the variables are pre-assigned all known values from a number place puzzle having only one solution, the output of the software would be the solution of the puzzle. However, when the variables are pre-assigned values while creating a number place puzzle, the software output will be all valid solutions, if any. Multiple solutions provide information that assists in modifying the pre-assigned values to obtain a single solution.
BRIEF DESCRIPTION OF THE DRAWINGS
So that the manner in which the above-recited features of the present invention can be understood in detail, a more particular description of the invention, briefly summarized above, may be had by reference to embodiments, some of which are illustrated in the appended drawings. It is to be noted, however, that the appended drawings illustrate only typical embodiments of this invention and are therefore not to be considered limiting of its scope, for the invention may admit to other equally effective embodiments.
FIG. 1 shows a sample of pre-assigned values used to illustrate the method and software of an embodiment of the present invention.
FIG. 2 shows a flow diagram of a computer program embodiment having nested loops for use in a method embodiment of the present invention.
FIG. 3 shows lines of a computer program that correspond to portions of the flow diagram in FIG. 2.
FIG. 4 shows additional lines of the computer program of FIG. 3.
FIG. 5 shows the results of running the computer program of FIGS. 3 and 4.
FIG. 6 shows two separate number place puzzles created from the results shown in FIG. 5.
To facilitate understanding, identical reference numerals have been used, where possible, to designate identical elements that are common to the figures. It is contemplated that elements disclosed in one embodiment may be beneficially utilized on other embodiments without specific recitation.
DETAILED DESCRIPTION
FIG. 1 shows a number place puzzle having a 9×9 array of boxes typically used in classic Sudoku™ puzzles. The array forms 9 rows of 9 boxes labeled A through F and 9 columns of 9 boxes labeled 1 through 9. Pre-assigned values have been selected to illustrate making a number place puzzle. The values can be pre-assigned in any manner as long as the rules of the number place puzzle are obeyed, e.g. each row, column, and nonet (3×3 array) has no duplicate numbers for a classic Sudoku™ puzzle. The values can be pre-assigned before the program is executed as shown in the following Figures. Alternatively, the program can assist in selecting variables using graphics and dropdown windows.
Each box in the example puzzle of FIG. 1 is readily identified by the row and column, e.g. box A1 is preset at 1. For use in the following description, each nonet in FIG. 1 is labeled in the top center boxes N1, N2, N3, N4, N5, N6, N7, N8, and N9. The selection of pre-assigned values in FIG. 1 was assisted by the computer program listing (NP.txt) filed with this application although selection can be done manually.
FIG. 2 shows a diagram of a computer program for making number place puzzles according to an embodiment of the present invention. The source code for one such program written in BASIC is shown in the computer program listed. The BASIC program was written using JUSTBASIC 1.01 which is freeware available at www.justbasic.com. The attached BASIC program is not free for use in making number place programs if one or more claims below are granted. The computer program can be written in any program language and for any number place puzzle.
The embodiment shown in FIG. 2 uses eighty-one (81) nested loops to assign each of the eighty-one (81) variables in the 9×9 number place puzzle of FIG. 1 as described in more detail for FIG. 4. Pre-assigned values are entered 21 and are processed by limiting selection of each variable to the corresponding pre-assigned value as described in more detail for FIG. 3. After a value is selected for each variable, such as selection of a value for A122, the value is compared 23 to relevant pre-assigned values and relevant values previously assigned to the variables by the nested loops. The value is not compared to variables that are to be assigned in any loops that are embedded in the loop that assigned the value because the embedded variables are not yet assigned a value for comparison. However, comparison of the value to embedded variables will occur when each embedded variable is subsequently assigned a value.
When the selected value for a variable is the same as a compared value, embedded loops are bypassed 24 for selection of another value for the same variable. If the selected value if different from all compared values, the value of the next variable is selected, such as selection of A225. The selection of successive variables continues as long as each new value satisfies the comparisons. When no value satisfies the comparisons for a variable, processing returns to selection of the prior variable, e.g. selection of A2 exits 26 to selection of another value for A1.
When all selected variables satisfy the comparisons, the variables are printed 27. Thus, the comparison instructions within each loop limit access to successive loops that would print the variables. The computer program ends 28 after the possible combinations of the variables have been tested, such that all possible solutions are printed absent limitation on the number of printed solutions. When the computer program listing (NP.txt) is executed with JUSTBASIC 1.01, up to 50 solutions (when NPMAX=50) are printed to a window and can be saved in a file or printed.
FIG. 3 shows lines from the computer program listing which illustrate entry of pre-assigned values 31, limitation of variables from A1 to F9 to any preset value 32, and selection of variables from A1 to F633 using For/Next statements. In the computer program listing, selection of variables begins with N1 of FIG. 1 and progresses through N6, N8, N2, N4, N9, N3, N7, and N5. The order of the nonets for selection of values was chosen to assist in writing the program by having a sequence wherein selected values in Nonet 1 in FIG. 2 (N1) were not comparable to values in Nonet 2 (N6) or Nonet 3 (N8) and selected values in Nonet 4 (N2) were not comparable to values in Nonet 5 (N4) or Nonet 6 (N9). The same result would be achieved by similar sequences such as the reverse sequence N5, N7, N3, N9, N4, N2, N8, N6, and N1.
After successful selection of all variables without duplicates, the computer program listing prints a header 34 that keeps count of the solutions and prints all variables 35. When a variable such as A1 of F6 is a duplicate to a pre-assigned value or a previously selected value, processing jumps to a label positioned before the corresponding Next statement 36. After all combinations are processed, the final commands print “End” 37 to show that processing is completed unless the program terminated by setting NPMAX to a number less than the number of solutions.
FIG. 4 shows additional lines from the computer program listing to illustrate how comparison of variables is completed for N1 and N4 in FIG. 1. For each variable, the selected value is compared to pre-assigned values and previously selected values in the same row 41, pre-assigned values and previously selected values in the same column 42, and then pre-assigned values and previously selected values for remaining boxes in the same nonet 43. As shown in FIG. 4, subsequent comparisons 45, 45, 46 include more previously selected values and fewer pre-assigned values than the prior comparisons because the previously selected values would be identical to any pre-assigned value for the same variable.
When multiple solutions are obtained, further pre-assignment of values may be assisted by comparing the multiple solutions. For example, the pre-assigned values shown in FIG. 1 have the four solutions shown in FIG. 5 (which shows the result of executing the computer program listing NP.txt filed with this application). Comparing the solutions, only Solution 1 has a value of 2 at A651 and a value of 6 at I452, thus pre-assignment of both values would result in a single solution for the corresponding puzzle 61 shown in FIG. 6. Similarly pre-assignment of both A653 and I454 in Solution 2 would result in a single solution. Assignment of I7 in Solution 1 or assignment of I7 in Solution 4 would also result in unique solutions although less symmetrical.
Puzzles having a single solution can be modified to be more symmetrical as shown in FIG. 6. The puzzle 61 created in the description above was modified by removing the pre-assigned values for F4 and D6. Execution of the computer program listing (NP.txt) after modification resulted in 26 solutions and only the first solution resulted in the value 8 for E5. Thus, a more symmetrical puzzle 62 was obtained by pre-assigning the value 8 to E5. Whenever no solution remains, removal of one pre-assigned value can also result in a single solution or a different set of multiple solutions that can be examined for a single solution.
While the foregoing is directed to embodiments of the invention, other and further embodiments of the invention may be devised without departing from the basic scope thereof.