## Difficulty rating

Puzzles appearing elsewhere are often rated using terms like "easy", "medium", "hard", "fiendish", but SourGumdropK provides a numerical difficulty value. In this section I explain how SourGumdropK calculates its difficulty ratings and how users can tailor the program to closer approximate their own ideas on the subject. Note that as a byproduct, the flexibility of the SourGumdropK scheme provides a further way of obtaining hint information: users can get counts of the number of times each algorithm needs to be applied to complete the puzzle and can even select which algorithms are included in this process.

### Solving strategies

Before describing the rating scheme is is necessary to outline various strategies a program might use when applying its range of algorithms. The overall puzzle difficulty must depend on the number of times each algorithm is applied in finding its solution, and this number depends on the order in which the algorithms are selected for use. The order depends on the strategy used.

There are two features common to all the strategies used by SourGumdropK:

1. Simple filter exhaustively is performed automatically as part of each algorithm.

2. Every search for the potential application of each algorithm finds ALL possibilities. An instance which removes the most candidates is remembered ready for use.

### Simplest first

The algorithms are arranged into order according to their complexity and then the following procedure is used. Start with the simplest algorithm and keep applying it until it has no effect; then apply the next most complicated algorithm, if it has no effect try the next algorithm. As soon as an algorithm has an effect, apply it once and then go back to the simplest. Continue until the puzzle is finished or no progress can be made (in which case, give up). This strategy is designed to approximate that which might be used by a human solver who always considers the whole of the puzzle. The Simplest First strategy works out the easiest steps to the solution: it will never use a complex algorithm when a simpler one will also remove a candidate.

Coupled with difficulty scores for each algorithm, strategy "Simplest First" is the basis of the puzzle difficulty rating system used by SourGumdropK. Note that difficulty scores for individual algorithms can be set to zero; if so they play no part in the difficulty rating for the puzzle.

### Most effective

At any stage try all algorithms and apply the one that removes the most candidates. This is the one of the strategies used when the user asks for a general hint using the "?" button in the Toolbar (the other, "Simplest hint", is described below). Most effective is also used to solve puzzles read from files or entered by the user. However, in these cases, if the built in algorithms are unable to solve the puzzle, SourGumdropK also employs a directed guessing and backtacking algorithm to ensure it always has a working solution for the puzzle. "Direction" is provided by guessing for the unsolved cell with the lowest information content - for this cell the number of guesses is least.

### Simplest hint

This algorithm finds a hint with the lowest non-zero algorithm score and is hence closely related to the "Simplest first" strategy. Algorithms are applied in score order until a hint is found. This hint is then displayed.

### Algorithm scores

A possible set of scores is shown in Table 1. I am happy to set the default scores used in the program to any consensus arrived at by users. However, SourGumdropK allows users to set their own algorithm scores and to use them to calculate puzzle scores.

```
Algorithm  Score
IC       2
UI       2
UC       2
H1       3
H2       4
H3       5
N2       2
N3       3
N4       4
PP       6
XW       7
CB       8
IN       9
BG       9

```

Table 1. A set of algorithm scores.

The score for a puzzle is calculated as follows. Let Di be the difficulty rating for algorithm i, and Ni be the number of times each algorithm (i) was applied in solving the puzzle (using the Simplest First strategy). The difficulty rating for the puzzle is then the sum of Ni x Di for all i.

### Show difficulty/Set scores

The File menu contains an option "Show difficulty/Set scores". This allows the scores for the individual algorithms to be set by the user. When the option is selected the window shown in Figure 1. appears. At the top is a row of algorithm labels; below this a row showing the number of times each algorithm needs applying to finish solving the current puzzle; below this a row of buttons showing the current scores for each algorithm. At the bottom the current puzzle "Total" score is given plus a "Recalculate" button and an "OK" button. By clicking on the algorithm score buttons the user can change their values. Clicking on "Recalculate" will show the score using the current set of algorithm scores. For these calculations the Simplest First strategy is used.

Figure 1. A screendump of the SourGumdropK difficulty rating window showing the algorithm scores and their usage.

Note that any algorithm given a score of 0 will not be used to calculate the puzzle difficulty. This means that users can experiment with seeing which alternative routes there are for solving the puzzle. Figure 2. shows data for the same puzzle as that in Figure 1. But here we see the effect of zeroing the scores for the algorithms until only the hardest ones are used. If any more were zeroed the puzzle would not be solved.

Figure 2. A screendump of the SourGumdrop difficulty rating window showing the algorithm scores and their usage. Here the scores have been progressively zeroed until the minimal hardest set of operations remains.

Note also that it is the current state of the puzzle that is given a score and algorithm usage counts. This means that at any stage the user can employ this option to see what is still required.

If the puzzle cannot be solved using the current set of algorithms with non-zero score SourGumdropK will display the total score as "***". This can arise in two ways: if the user has set the scores for too many algorithms to zero, or if the user has entered a puzzle from a file or the Puzzle entry window and it is too hard for SourGumdropK's current algorithms. Note that in the latter case SourGumdropK can still solve the puzzle as is explained in the "Most effective" section but the guessing algorithm described is not used by the difficulty rating function.