D UAs expansion to produce valid bands 1+2
Finding first valid bands 1+2 for a band 3 assumed fully solved is the key concept of blue’s approach.
In the V6 process, valid bands 1+2 were searched using a matrix
Valid bands1 x valid bands 2, checking for each matrix position if all UAs were hit.
To do that, valid bands included redundant clues to have all possible valid solutions of “n” clues with n in the range 3-7.
Here the process has changed. Valid bands 1+2 are produced directly out of the UAs list, in several steps. Doing so, we can get solutions with less clues than the target, a special process will manage this case.
As in any such process, it’s important to use first the shortest UAs;
In the process, we can look for valid bands having <= 10 clues, 11 clues or 12 clues.
In the 17 clues search, pass 1 has 7 or more clues in band 3 <= 10 clues in bands 1+2
pass2 has 6 clues in band 3 and a maximum of 6 clues in bands and stacks.
In the 18 clues search,pass 1 has 7 or more clues in band 3 <= 11 clues in bands 1+2
pass2 has 6 clues in each band and each stack.
D.1 Minimum number of clues for 2 bands We know that the minimum number of clues for 2 bands is 7 with only 4 ED such sub puzzles
This has been discussed long ago (2014) in this thread.
http://forum.enjoysudoku.com/minimum-number-of-clues-per-band-stack-t32120-105.htmlWe have no 17 with 7 clues in 2 bands, but some examples of 18 clues.
The number of valid bands 1+2 with no extra clue grows sharply in the area 7_12 clues.
A specific function is written for each family of such valid bands 1+2, adding extra clues to a valid band 1+2 to scan the area from 0 added clue to the maximum searched.
Although the process is very similar for the same number of free clues, each case has it’s own function
8to 10 9 to 10;
7to 11; 8 to 11;9 to 11; 10 to 11;
7 to 12; 8 to 12;9 to 12;10 to 12;11 to 12
The first reason to have separate functions is the different constraint to apply in bands and stack number of clues .
The second one is a safety measure. Mixing all cases to save coding add risks to have bugs.
The third one is that likely, at the end, the code will be split in 2 programs, one for the 17 search, one for the 18 search. The same remark will be valid for the main expansion functions.
Below 7 clues, if the list of still available UAs is empty, it can not be a valid pattern. Although this should not come with a big initial list of UAs, one missing UA is searched and added to the list
D.2 Dead cells appearing during expansion In the article describing the proof that no 16 clue exists, this was well described.
Expanding UAs , we end with a set of cells hitting all UAs. Usually, several UAs contain more than one cell of the final set. If we have no filter, the expansion will produce many redundant sets.
Let’s take the first UA expanded. Any valid containing the first cell assigned will appear in the expansion of the first cell.
The same is true for the followings cells withing the same branch of expansion.
Such cells can be flagged as “dead”. The number of “dead cells” varies in a wide range. Let’s assume that the first 4 UAs are disjoints and of size 4. After 4 clues, the number of dead cells will be in the range 0-12 (assuming that the 4 cells of the set are non counted.
D.3 Remaining UAs status after n cells assigned Let’s assume that 6 UAs have been assigned.
All UAs hit by these 6 clues are discarded
All dead cells in the remaining UAs can be ignored.
Erasing dead cells changes the residual count of cells in each UA. An empty UA can show up; This means that we have a dead branch with no possible new valid.
More often, this changes completely the order of the “smallest UAs” and new subsets can be seen,
Killing hit UAs, reordering UAs by residual size, applying new subset, we can build a reduced table of UAs lowering the work for the following steps.
Doing such reduction for each cell would not be of high interest;
In the program, this is done after a step of 3/4 cells where the smallest 128 UAs play a key role.
D.4 n cells expansion with a given set of UAs The basic function in the expansion process will be to select n cells from a UA table.
N is 3 or 4 in the process, going from 0 to 6/7 clues, 6/9 if the final count is 12 (to be confirmed later).
This is done in similar functions, using a common table to store cell by cell data.
We can expect in most cases that the first (smallest) 128 UAs will be sufficient to expand 3/4 cells. These 28 UAs are followed through a vector updated in the process for each new cell.
Remaining UAs are checked later if the first table is fully hit applying the set of cells assigned.
Fresh UAs appearing in the process can be added to the table, but must not be in the first 128. If the total number of UAs is <128, the rest of the table for the first 128 is lost.
D.5 expansion of the last n cells If we are considering the 17 clues search pass 1, we have 2x3 cells assigned as described above. The last expansion step is for cells 7 to 10.
This will produce
Potential valid bands 1+2 of size 10, the final count,
Potential valid of smaller size (size seven can be ignored)
If the first 6 clues are made of cell hitting a small number of UAs, this can produce no valid. At the opposite, this can produce hundreds of valid.
The expansion is done in once. The potential valid are stored in tables, one per size below the final count and one for the final count.
Each of these tables has a common number of clues >= 6 (first steps here). If a table has one valid, the common number is equal to the size of the valid. Often, we will be somewhere in between;
A good depth (number of residual clues to assign) seems to be in the range 3/4. At the moment, the draft for the 12 clues expansion is not yet done, but as we expect to have many 12 despite the band/stack constraint 666/666, the planned expansion is to have 3x3 steps before the last on of depth 3 also.
Expansion of the last clueIn all UAs expansion functions, the last clue must hit all remaining UAS;
This is very easy to implement, so, in any place where it is possible, the last step will combine first all still valid UAs to find common cells. In most cases, we have no common cell.
With more than one clue to assign, we have no easy way to simplify the process.
Fresh UAs coming laterHere, the UAs set is locked. If fresh UAs for bands 1+2 are seen later, they must be stored n a special table to be reused for this chunk of valid.
D.6 Summary of the expansion phases We have the following structure:
- Code: Select all
Search of 17 clues
Pass1 (10) 3+3+4
Pass2 (11) 3+4+4
Search of 18 clues
Pass1 (11) 3+4+4
Pass2(12) 3+3+3+3 (project to implement)
D.7 Sorting and shrinking a UA table by size For UAs and later GUAs, we have similar tasks to cover
Deleting UAs hit by the known cells
Erasing dead cells from still valid UAs
Sorting such UAs by size
Erasing supersets.
As the sort operation is quite simple, the process uses vectors bit fields (one vector per size).
Bits are set to 1 in the relevant vector depending on the size of the UA, then UAs are taken by increasing size and sent to the final location.
In the final location, UAs are stored in blocs of 128 UAs, with bit field vector giving for each cell the UAs non hit.
As the first bloc has a specific treatment in the expansion process, the total number of UAs is forced to a minimum of 128 to push fresh UAs appearing later in another bloc.
D.8 After the last expansion step If we have reached the final count, we enter the phase 2 of the process, the GUAs filter. At this point, the final check of the validity is not done.
The only thing to do is to control that no fresh UA in bands 1+2 from a previous valid of the same chunk kills the potential validity.
For the “valid below the final count” the final check is done in the last expansion step. We must here try as band 1+2 the given , but also any band 1+2 pattern obtained adding clues “up to the final count” with clues taken in the free cells (no dead cell) and in line with the constraints of the pass (eg: no band over 6 clues in a 12 clues pass).
Again, to stay on the safe side, we have several functions very similar processing each case with the relevant constraints applied.