sudokuTool -- Ada version using GLFW3 and OpenAL

sud		for sudoku
sudx		for sudoku-X

Linux Build: AdaCore2016 on mint
Windows Build: 64-bit GNU-Ada on Windows10

See more pics under ~MEDIA/Sudoku/

===================================================
undocumented keys: 
1) cap "C" forces goodXcycle search
	(skipping the badXcycle search)
	...to debug/test goodXcycle.
2) select+K => show KeyCell logic even if no =><=.

For extreme puzzles where KeyCell fails
(I've only seen 1):
	.) pick cell w/only 2 digits;
	.) delete one of them;
	.) use KeyCell or xCycle to ramify;
	.) if result is a success, then done.
	.) if result is a failure, with some
		empty cells, then pick the other digit.
	.) if result is still inconclusive...???
		(I have never seen this happen, yet)
	This method has worked on all the worst
	cases I've seen, so far.

===================================================

todo:

.) Still looking to discover non-guessing solution for: 
	puzzles/impossible/sInkala.txt

.) REJECTED: consider another method to type digits:
	simply type into selected cell...
	only 1 => single; >1 => candidates.
	This only works if auto-candidate mode
	can be turned off.

.) REJECTED: implement a 2-layered KeyCell for extreme 
	puzzles in case KeyCell fails. 
	i.e. choose 2 cells, then 1 candidate from each
	to test ramifications. [But pair-failure => ?]
	To do that, I would need KeyCell to automatically 
	remove the deletable digits, then keep retrying 
	another KeyCell until a solution or failure is 
	reached...REJECT due to complexity!
=================================================

15aug23
.) asudx: naked pairs/triples removables enabled!
.) naked pairs/triples/quads display now shows removables
	in cyan (asud.adb).

14aug23
.) refined draw to correctly display when showbrute=true.
.) s546 now solvable with KeyCell !!!
	Must have eliminated a previous error.
.) found & fixed integer-type error in kram that caused abort.
.) found & fixed restoration error AFTER using kram...
	fullsave does not actually saving current m9
	but only original m9. I must now RE-promote any singles.
.) added flush @ beginning of "findUnique" in order to
	autopromote, then flush any green single candidates. 
	This is what you would intuitively expect when you 
	press the u-key.

13aug23
.) slight change in draw that sometimes shows unpromoted 
	single candidates in green, which must be explicitly 
	promoted with a flush, unique or assert-digit.
	Note that promoting within findUnique caused errors.
	(never understood why).

12aug23
.) ensured every flush is followed by a test for soln.
.) changed label for Naked pairs/triples/quads to indicate
	that r/c/b (b=box) are shown in asud
	(box quads are still NOT shown in asudx)
.) removed automatic flush/unique during read file
	or restore of prior puzzle to reduce confusion.
.) added flush+findUnique after each digit assertion,
	and flush after edit of candidates in a selected cell...
	more like NYT.

5aug23
.) moved visual brute force solver to
	../visudoku/.

3aug23
.) see ~/visudoku/src/explain.adb
	for graphic representation of recursive brute
	force solver.

1aug23
.) updated help screen for ptq.
.) refined badcells, badsell.
.) refined solved message.

30jul23
.) Bad effort to change goodXcycle to always show output
	when "C"-key was pressed...reverted (hopefully).
	Affected: asud, asud-getkey*, asud-good*, etc.
	Ended up making logic too complex...
.) use cap-K-key after selection to trigger debug
	output even when no contradiction found. This is
	only to assist my personal understanding in cases
	where no contradictions occur.
.) added extra "flush" inside KeyCell...a definite
	improvement since I got a few steps further
	versus s546.txt !!!


####################################################
30jul23: uploaded v1.1.1 to S.F. + GitHub
####################################################

29jul23
.) change f-key to function like F-key
	...unless a cell is selected (like k-key). Done
.) update menu
.) created some new png images.

28jul23
.) fixed good xCycle output to console...
	only shows if deletables.

27jul23
.) adjusted kram message when singleton is the
	cause of a contradiction. This can only
	happen after guessing incorrectly.
.) added call to findUnique(ok) prior to KeyCell
	in getkey:key_k because deletions change
	the puzzle.
.) b-key: use alternate save file! (like k-key)
.) if cell is selected, k-key triggers single cell
	KeyCell search. This may allow finding simplest
	contradictory logic chain.


26jul23
.) now show deletables, if any, whenever a-key is ON.

25jul23
.) added aligned box digit triples to the
	aligned box digit doubles view...serves similar
	purpose.
.) add a-key/n-key to menus.
.) use a-key for Aligned Box Pairs (pointing-pairs)
.) Suppressed the old default of always showing 
	Aligned pointing-pairs in red...they can now be 
	toggled using a-key, or seen using DigDbls view.
.) Key-Cell view now saves state to special file,
	different from a user-save file. This preserves
	the user-saved states as expected.
.) Added console warning that user cannot save state
	during Key-Cell view.


####################################################
25jul23: uploaded v1.1.0 to S.F. + GitHub
####################################################

24jul23
.) fixed serious error in hiddenTriples.

23jul23
.) switched ON showing boxPairs/boxTriples...
	that were previously suppressed to reduce clutter.
.) now force an update on every draw so that deleting digits
	during pairs/triples/quads view acts as expected.


####################################################
22jul23: uploaded v1.0.9 to S.F. + GitHub
####################################################

21jul23
.) Note that each LP "chain" displays a tree of related digit-pairs, 
	some of which are hidden from the deletables shown.
	But, unlike Xcycles, these are not linear closed loops, 
	so do not need pruning.

20jul23
.) Fixed linked-pairs so that deletions work as expected.
	Set a flag "wasDeletion" whenever a candidate is
	removed while the showLP flag is on. Then used it
	to force a restart, and a new call of linkedPairs.

####################################################
19jul23: uploaded v1.0.8 to S.F. + GitHub
####################################################

16jul23
.) added terminal message " Solved !" when all singles.
.) removed all defunct *restore* files.

15jul23
.) Now automatically skip LP chains with no deletables.
.) added terminal messages for LinkedPairs to
	indicate digit sequence (if any deletables exist).

14jul23
.) Updated LinkedPairs colors to show all removables in cyan.
.) refined KeyCell terminal output.

13jul23
.) added orntex deleted digits in KeyCell.

12jul23
.) changed 1)LinkedPairs, 2)xCycle
	to use alternating Blu/Red (avoid Green). Done.
.) FIXED C-key logic both Xsud & sud;
.) FIXED C-key color/draw logic on Xsud.
.) added n-key toggle of NonAlignedBoxPairs...
	not yet sure it is helpful? Unpublished.


11jul23
.) eliminated unused function in asud-kram.adb


####################################################
11jul23: uploaded v1.0.7 to S.F. + GitHub
####################################################

11jul23
.) Now hilight removables for hidden pairs/triples/quads.
.) use C-key for exclusive goodxcycle
.) corrected action in badXcycle...
	1) restored ok2 per andrew stewart;
	2) now use xoncycle/xoffcycle as the "clean" criteria
		rather than xcycle, which gets corrupted by
		the recursion.
	3) also corrected "draw" code to reference
		xoncycle, xoffcycle rather than xcycle.

10jul23
.) remove K, just use k. Done.
.) put console comment when DigDbl has cyan digits. Done.
.) repaired output from goodXcycles. Recursion implies
	links on failed chains are subsequently redefined.
	Thus, correct sequence must be determined AFTER 
	concluding search.
.) found 2 goodXcycle tests that look fine:
	xC3, eg2
	but I have to disable badXcycle (getkey*) to force it.
.) note: I could seek goodXcycles 1st, then bad...
	but bad allows for more speedy elimination of candidates.
.) Now put message for DigDbls saying "found some removables".


9jul23
.)	I must better understand, first.
	Copied code attempts into src/9julHoldTry/.
	Understood. Working forward from the startcell
	I assume it is ON. But I can also trace backwards
	assuming it is OFF. Both ways, the sequence makes sense.
	But any non-cycle-cells that can see both colors of
	cycle-cells are deletable. For this I reinstated
	ok2 per expert advice...
	but note that is NOT the case for badxcycle,
	since I believe it is unecessary.
.) Done! got goodxcycle working Ok, and found that
	xC1.txt is a good example to exercise it.

8jul23
.) generalized xCycles to show consistent ones
	with Cyan deletables if any,
	as well as the contradictory ones.
	Only the first found with deletables is shown...

6jul23
.) now using Green for singletons.
	Note Orange is nice new unused color.
.) added drawnYet array to prevent blanks & overwrites
	given the complicated drawing logic.
.) pairs/triples/quads: replaced cyan with red
	Cyan is reserved for deletables.

5jul23
.) FTTB: commented out corner pencil marks.
.) mode title is now gray (not yellow).
.) Changed original (puzzle-file) singles to 
	darker black than other singles.
.) changed color schema: 
	.) LinkedPairs now alternate Red/Green
		(not magenta/green);
	.) Singletons are now BrightYellow and always shown;
	.) PointingPairs are now Magenta and always shown.

4jul23
.) Updated action (in ftn draw) versus singleton...
	if m9=0 then define m9=d then flush.
.) removed flag "showU" since singles are always displayed.
.) if showX(Xcycle) or showLP(linked-pairs), use Black
	for singles, otherwise use Green.

3jul23
.) added pencil marks in corners that always show aligned box doubles
	(boxPairs). Xsudoku also shows diagonally-aligned box doubles.
.) Big cleanup in digit placement code by using "i2st" function.

2jul23
.) micro-adjusted numeral-center so, if I want, I can add
	up to 4 black pencil-marks in the corners, while changing
	the central numbers to grey.
.) changed central digits to nice shade of grey so that
	added pencil-marks can be black.

1jul23
.) make Paradigm uniform: cyan => deletable
.) Xwing conformalized colors.
.) Ywing conformalized colors; hilited deletable Cell;
	deselected @ exit.
.) xCycle: if showX=T, then 1st digit is cyan(removable)

.) Reset flags to OFF when any key is pressed.
.) k or K: trace of singles now blue (not green).
.) Corrected search algos for naked Pairs/Triples/Quads
	to allow group digits to exist in non-group cells...
   see: Naked triple failed on ctc174 col2: 123-12-13 !!!
 


####################################################
01jul23: uploaded v1.0.6 to S.F. + GitHub
####################################################

30jun23
.) fixed serious error in asudx-getkey*.

29jun23
.) adjusted appearance (cell-outlines, etc).
.) made aligned box [pointing] pairs flag aligned removables
.) made rowpairs in same box flag other like digits in box
.) made colpairs in same box flag other like digits in box
.) asudx.digDblsBox: now adds DiagDbls to "aligned" if they
	are both in 1 box...in 5 boxes!



28jun23
.) xCycle: now set (pr,pc) @ exit for easy digit deletion.
.) reordered d-key to show boxDbls first.
.) Minimal-Std view now shows NonAligned box-pairs Blue.
.) Added singleton-emplace (assert) using <ctrl>+<num>
.) added mouse-click Deselect.


####################################################
28jun23: uploaded v1.0.5 to S.F. + GitHub
####################################################

27jun23
.) clarified xCycle display...
	.) first color is green,
	.) then colors alternate red, green
	.) last (conflicting) color is green.
	Much nicer.

26jun23
.) bifurcated rows, cols in digit-doubles display.
	Much nicer, much less confusing.
.) restored all pencil-marks for Digit-Doubles.
	That way you can easily see if any digit-deletions 
	are needed.


25jun23
.) replaced showRC with rcPairs.
.) removed clutter from digit-doubles views. Nice!
.) enabled "shoXwing" ( x-key ).
.) xCycle now uses c-key
.) Xwing now uses x-key.
.) Xwing now shows removable digits in red.

####################################################
22jun23: uploaded v1.0.4 to S.F. + GitHub
####################################################

19jun23
.) To reduce clutter, the K-key now writes console
	messages to a buffer instead, and only write to
	console if a contradiction arose.

16jun23
.) added K-key to search ALL cells in lexicographic
	order until a contradiction is found.
.) installed "flagsoff" ftn inside *getkey*
	to simplify code style.

####################################################
16jun23: uploaded v1.0.3 to S.F. + GitHub
####################################################

15jun23
.) k-key now handles ANY cell, no matter how
	many candidates it has. This allows solving
	s545.

14jun23
.) added ?-key to initiate help screen but did not publicize;
	this was only to test glfw (via asud-getkey*)...
	This is how GLFW recognizes it: "?" = upper_case("/")

####################################################
12jun23: uploaded v1.0.2 to S.F. + GitHub
####################################################

10jun23:
.) improved & minimized terminal output for KeyCell.

9jun23:
.) asud-kram: now terminates earlier...as soon as there is
	an empty cell detected...fewer details to trace on console.

8jun23:
.) remade [manual] showUnique so it turns unique vals green.
	Hooked to key-u. (new flag: "showU").
	Old ftn: use cap-U.
.) remade [manual[ flushCell so only chosen cell is flushed.
	Hooked to key-f.
	Old ftn: use cap-F.
.) tested...I believe I have not broken anything else.
	So far, only changed asud.adb, asud-getkey*.


5jun23:
.) no longer show red DigDbls-Box when not aligned.

4jun23:
.) modified KeyCell to allow cells with 2 or 3-entries.
	This allows solving extreme #504 from sudokuWiki.

####################################################
31may23: uploaded v1.0.1 to S.F. + GitHub
####################################################

29may23:
.) significantly improved clarity of console output
	for k-key results.

26may23:
.) added "DIG DBLs Box" to default display.
.) replaced "="-key with "d"-key 3/4way toggle.
.) added commentary when Xcycle is displayed
.) Added console comments to ID Ywing target.
.) green-singles now show in 3 modes:
	.) showRC
	.) boxPairs
	.) minimal


####################################################
25may23: uploaded v1.0.0 to S.F. + GitHub
####################################################

23may23:
.) Just now fixed serious error with flush.
	Saved to 23maySave/.
.) updated screenShots @ ./images/.

21may23:
.) removed defunct proc test4dbls & yel9 array!

20may23:
.) showK now shows duplicates in same house as 
	cyan (not green).

19may23:
.) the showK flag now displays the resulting singletons
	in green to help see why the blue cells are empty.
.) linkedPairs now shows helpful comments as
	console outputs to pinpoint removable digits.

18may23:
.) created my own guided Key-cell ramify strategy, 
	starting with selected cell w/only 2 digits as 
	candidates (for x1.txt).

	I don't see that this is any less-respectable
	than Ywing, linkedPairs or Xcycles. They all involve
	shotgunning for a starting supposition that leads 
	to a contradiction.

	Screen shows
	a) neither fails: nothing; 
	b) one fails: cell shows one red digit 
		+ blue-outlines of cells that would become empty.


17may23:
.) added Xcycle on (dig)
	...exactly what I need next for x1.txt
.) x1.txt was impossibly complex to solve; see solving_x1.txt.

15may23:
.) updated Ywing to only display when the target
	digit needs to be deleted. Once deleted,
	the y-key will look for a second, third, etc.
	If nothing displays then one more y-key toggles it off.

14may23:
.) added Diag search for linkedPairs on X.
	Needs testing...
	...reason to think it works (see x2.txt)
.) fixed logic error in linkedPairs incrementation.

13may23:
.) restored Green single-box-digits.
.) fixed brute force solver to restore state w/second b-key.
.) 

12may23:
.) after several fixes, I think I have LinkedPairs
	working ok. I solved sywing2.txt nicely.
	Use multiple l-key to see all distinct chains.

11may23:
.) added brute-force solvers
.) removed hiliteA because it has limited usefulness
	and it upsets my linked-pairs algo.
	Note that hiliteN shows aligned pairs within blocks.
.) added linked-pairs, l-key.

10may23:
.) asud seems effective versus hard9may, evil9may...
	after final code corrections.
.) corrected setNpairs (wrong init of hiliteNT rather than NP)
.) eliminated "srestore.txt" and "xrestore.txt".
	Now rely solely on either input filename 
	or frestore.txt (fxrestore.txt for X).
.) think I perfected Ywing logic, now.
	It works on sywing1 & sywing2...
	but note that I need special restore files to be
	able to immediately display the Ywings.

9may23:
.) no longer show naked triples in boxes because
	it reduces clutter, and is not helpful.
.) no longer show naked quads in boxes because it reduces
	clutter, and is seldom useful.
.) note that naked quads show double-pairs too but that's Ok.
.) also found that naked triples does NOT show pairs.
.) Due to the above change, I no longer think that
	naked quads shows triples too.
.) removed diagonal digit 3s because pairs allows
	easy candidate removals.
.) added toggle for red/green digits...
	?are green digits at all useful?
.) added toggle for DigitDoubles (row/col)...
	don't know yet whether this is useful.

8may23:
.) updated asudx to handle Quads too.
.) added Ywing finder.
	Verified correct function on 2 examples.

7may23:
.) updated asudx pretty well.
.) extended u-key (find Unique) to search blocks too.

6may23:
.) added tiny lettering to show view mode.
.) added pairs to X (shows naked & hidden).
.) updated X triples (shows hidden only).
.) added digit-based highlighting to display hidden
	quads, triples, pairs. (nonX only)
.) removed nakedQuads from quads-view (too confusing).

4may23:
.) added findQuads <q>-key in cyan color (nonX).
	Seems to show triples too?
.) extended findTriples to look for second triple
	in same row, col, block. Added to sudX too.
	Seems to show pairs too?
.) make d-key toggle diagonals (sudX).


3may23:
.) extended Triples to operate on 3x3 blocks.
.) updated Xsudoku to match.
.) extended pairs/triples to include diagonals (cyan)

2may23:
.) added t-key toggle for showing Triples in blue.

30apr23:
.) added GREEN highlight to non-aligned [non-red] digits that 
	appear ONLY twice within each of 9 3x3 blocks...
.) if digit is unique, make it larger + dark black!
.) toggle: omit all black digit candidates,
	for simplicity...allows human to better see patterns.
	see "minimal".
.) flush enhanced: flush every unique digit, not just one.
.) updated asudx too.


27apr23:
.) had to switch to shared glfw libs !

10may22:
.) gtex is utex genericized, so I may use a few 
	different text colors.
.)	I now use colored letters to highlight
	aligned pairs or triples of a digit per block:
	.) pick a 3x3 block;
	.) for each row of 3, see if there is a
		digit excluded by the other 6 cells.
		If so, print that digit in red.
	.) do same for each col of 3.
	.) seems to work nicely, and it helps to solve.

09may22:
.) improved asud, asudx to show cells, selected cell.
.) corrected flushDups.

12feb22:
.) removed unused snd4ada.

11feb22:
.) fixed ./src/ to include asudx-get*
.) removed unused zoomwheel.

21jan22:
.) created findUnique...row,col,block,diags.
.) created save-state dump using (s)-key.
	With it, one can just about, but not quite,
	restore a puzzle, excluding certain deletions
	made using more sophisticated criteria.

19jan22:
.) Created "flushDups" operation.
.) Created this tool to help to manually solve
	difficult Sudoku puzzles ("challenge").


18jan22:
.) Updated zoomwheel.adb to respect zmin, zmax.

12nov21:
.) tried using static libglfw3.a
	...seems fine
	(after adding -lX11 to script)


