Jump to content

Sudoku Solution Calculator Gone MAD!


Decipher
 Share

Recommended Posts

remove the 0's (need empty strings for empty values)

you can add a new difficulty at the top of the script, and set that as the default...then in the GenerateRandomPuzzle(), add a new case for the difficulty:

#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $sDifficulty_Easy = "Easy"
Global $sDifficulty_Med = "Med"
Global $sDifficulty_Hard = "Hard"
Global $sDifficulty_Harder = "Harder"
Global $sDifficulty_Default = $sDifficulty_Harder

....

Func GenerateRandomPuzzle($aCallersArray)
_FileCreate($gsFILE_Puzzle)
$hFile = FileOpen($gsFILE_Puzzle, 2)
Switch $sDifficulty_Default
Case $sDifficulty_Easy, $sDifficulty_Med
FileWrite($hFile, "2,9,,,,,8,," & @CRLF & _
     "8,5,,4,,1,3,7," & @CRLF & _
     ",,,,3,,,," & @CRLF & _
     ",3,,,,2,,5,6" & @CRLF & _
     ",4,,3,9,7,,1," & @CRLF & _
     "1,2,,5,,,,3," & @CRLF & _
     ",,,,1,,,," & @CRLF & _
     ",6,4,9,,8,,2,3" & @CRLF & _
     ",,7,,,,,8,5")
Case $sDifficulty_Hard
FileWrite($hFile,",,,,,,,8,4" & @CRLF & _
",9,,,5,,,,7" & @CRLF & _
",,,,,9,1,," & @CRLF & _
",,9,5,,,,7," & @CRLF & _
",7,,3,,2,,6," & @CRLF & _
",6,,,,1,8,," & @CRLF & _
",,6,7,,,,," & @CRLF & _
"1,,,,3,,,4," & @CRLF & _
"3,2,,,,,,,")
Case $sDifficulty_Harder
FileWrite($hFile,",2,3,,9,,8,," & @CRLF & _
"6,,1,,3,8,,," & @CRLF & _
"5,,,4,,,,," & @CRLF & _
"3,,,,,,2,,4" & @CRLF & _
",,6,,,,3,," & @CRLF & _
"7,,8,,,,,,1" & @CRLF & _
",,,,,3,,,8" & @CRLF & _
",,,7,8,,9,,6" & @CRLF & _
",,2,,5,,1,4,")
EndSwitch
FileClose($hFile)
Local $aTemp[1]
_FileReadToArray($gsFILE_Puzzle, $aTemp)
_ArrayDelete($aTemp, 0)
For $y1D = 0 To UBound($aTemp) - 1
$aTemp2 = StringSplit($aTemp[$y1D], ",")
_ArrayDelete($aTemp2, 0)
For $x2D = 0 To UBound($aTemp2) - 1
$gaPuzzle[$y1D][$x2D][$giPuzzle_3D_Known] = $aTemp2[$x2D]
Next
Next
; Clear out possible array
For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
For $x2D = 0 To $giPuzzle_X2D_UBound - 1
If $gaPuzzle[$y1D][$x2D][$giPuzzle_3D_Known] > 0 Then $gaPuzzle[$y1D][$x2D][$giPuzzle_3D_aPossible] = ""
Next
Next
Return $gaPuzzle
EndFunc ;==>GenerateRandomPuzzle

side note: Solved the puzzle :)

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Although my prior code would eventually work, it would 'recurse' (not actuall recursion, but similar) through invalid options...I modified that, so what did take 10 to 20 minutes (depending on processor power), now will take 30 to 60 seconds.

#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $sDifficulty_Easy = "Easy"
Global $sDifficulty_Med = "Med"
Global $sDifficulty_Hard = "Hard"
Global $sDifficulty_Ext = "Ext"
Global $sDifficulty_Default = $sDifficulty_Ext
Global $gsFILE_Puzzle = @ScriptDir & "Puzzle_" & $sDifficulty_Default & ".txt"
$iMaxRecurssionCounter = 2
Global Enum $giPuzzle_Y1D_0 = 0, _
  $giPuzzle_Y1D_1, _
  $giPuzzle_Y1D_2, _
  $giPuzzle_Y1D_3, _
  $giPuzzle_Y1D_4, _
  $giPuzzle_Y1D_5, _
  $giPuzzle_Y1D_6, _
  $giPuzzle_Y1D_7, _
  $giPuzzle_Y1D_8, _
  $giPuzzle_Y1D_UBound
Global Enum $giPuzzle_X2D_0 = 0, _
  $giPuzzle_X2D_1, _
  $giPuzzle_X2D_2, _
  $giPuzzle_X2D_3, _
  $giPuzzle_X2D_4, _
  $giPuzzle_X2D_5, _
  $giPuzzle_X2D_6, _
  $giPuzzle_X2D_7, _
  $giPuzzle_X2D_8, _
  $giPuzzle_X2D_UBound
Global Enum $giPuzzle_3D_Control = 0, _
  $giPuzzle_3D_Known, _
  $giPuzzle_3D_aPossible, _
  $giPuzzle_3D_KnownGuess, _
  $giPuzzle_3D_aGuessPossible, _
  $giPuzzle_3D_KnownGuess2, _
  $giPuzzle_3D_aGuessPossible2, _
  $giPuzzle_3D_KnownGuess3, _
  $giPuzzle_3D_aGuessPossible3, _
  $giPuzzle_3D_KnownGuess4, _
  $giPuzzle_3D_aGuessPossible4, _
  $giPuzzle_3D_KnownGuess5, _
  $giPuzzle_3D_aGuessPossible5, _
  $giPuzzle_3D_KnownGuess6, _
  $giPuzzle_3D_aGuessPossible6, _
  $giPuzzle_3D_KnownGuess7, _
  $giPuzzle_3D_aGuessPossible7, _
  $giPuzzle_3D_KnownGuess8, _
  $giPuzzle_3D_aGuessPossible8, _
  $giPuzzle_3D_KnownGuess9, _
  $giPuzzle_3D_aGuessPossible9, _
  $giPuzzle_3D_KnownGuess10, _
  $giPuzzle_3D_aGuessPossible10, _
  $giPuzzle_3D_UBound
Global $gaPuzzle[$giPuzzle_Y1D_UBound][$giPuzzle_X2D_UBound][$giPuzzle_3D_UBound]
Global $gaPossible[9] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
; Add possible to all cells
For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
 For $x2D = 0 To $giPuzzle_X2D_UBound - 1
  $gaPuzzle[$y1D][$x2D][$giPuzzle_3D_aPossible] = $gaPossible
 Next
Next
$bExists = FileExists($gsFILE_Puzzle)
If $bExists Then
 $gaPuzzle = GenerateFILEPuzzle($gaPuzzle)
Else
 $gaPuzzle = GenerateRandomPuzzle($gaPuzzle) ; Currently, creating a fixed puzzle
EndIf
If GuiCreateCurrent() Then
 MsgBox(1, 1, "SOVLED!")
Else
 MsgBox(1, 1, "Failed!")
EndIf
While True
 $msg = GUIGetMsg()
 If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd
Func GenerateRandomPuzzle($aCallersArray)
 _FileCreate($gsFILE_Puzzle)
 $hFile = FileOpen($gsFILE_Puzzle, 2)
 Switch $sDifficulty_Default
  Case $sDifficulty_Easy, $sDifficulty_Med
   FileWrite($hFile, "2,9,,,,,8,," & @CRLF & _
     "8,5,,4,,1,3,7," & @CRLF & _
     ",,,,3,,,," & @CRLF & _
     ",3,,,,2,,5,6" & @CRLF & _
     ",4,,3,9,7,,1," & @CRLF & _
     "1,2,,5,,,,3," & @CRLF & _
     ",,,,1,,,," & @CRLF & _
     ",6,4,9,,8,,2,3" & @CRLF & _
     ",,7,,,,,8,5")
  Case $sDifficulty_Hard
   FileWrite($hFile,",,,,,,,8,4" & @CRLF & _
   ",9,,,5,,,,7" & @CRLF & _
   ",,,,,9,1,," & @CRLF & _
   ",,9,5,,,,7," & @CRLF & _
   ",7,,3,,2,,6," & @CRLF & _
   ",6,,,,1,8,," & @CRLF & _
   ",,6,7,,,,," & @CRLF & _
   "1,,,,3,,,4," & @CRLF & _
   "3,2,,,,,,,")
  Case $sDifficulty_Ext
   FileWrite($hFile, ",,,,,,,9,3" & @CRLF & _
   "4,,2,,,,,,7" & @CRLF & _
   ",3,,1,,,,," & @CRLF & _
   ",4,,2,,,6,," & @CRLF & _
   ",7,,,,,9,," & @CRLF & _
   "5,,,,6,3,,4," & @CRLF & _
   ",,,,,7,,6," & @CRLF & _
   ",,,,4,,,,8" & @CRLF & _
   ",,1,,8,,2,,")
 EndSwitch
 FileClose($hFile)
 Local $aTemp[1]
 _FileReadToArray($gsFILE_Puzzle, $aTemp)
 _ArrayDelete($aTemp, 0)
 For $y1D = 0 To UBound($aTemp) - 1
  $aTemp2 = StringSplit($aTemp[$y1D], ",")
  _ArrayDelete($aTemp2, 0)
  For $x2D = 0 To UBound($aTemp2) - 1
   $gaPuzzle[$y1D][$x2D][$giPuzzle_3D_Known] = $aTemp2[$x2D]
  Next
 Next
 ; Clear out possible array
 For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
  For $x2D = 0 To $giPuzzle_X2D_UBound - 1
   If $gaPuzzle[$y1D][$x2D][$giPuzzle_3D_Known] > 0 Then $gaPuzzle[$y1D][$x2D][$giPuzzle_3D_aPossible] = ""
  Next
 Next
 Return $gaPuzzle
EndFunc   ;==>GenerateRandomPuzzle
Func GenerateFILEPuzzle($aCallersArray)
 Local $aTemp[1]
 _FileReadToArray($gsFILE_Puzzle, $aTemp)
 _ArrayDelete($aTemp, 0)
 For $y1D = 0 To UBound($aTemp) - 1
  $aTemp2 = StringSplit($aTemp[$y1D], ",")
  _ArrayDelete($aTemp2, 0)
  For $x2D = 0 To UBound($aTemp2) - 1
   $gaPuzzle[$y1D][$x2D][$giPuzzle_3D_Known] = $aTemp2[$x2D]
  Next
 Next
 ; Clear out possible array
 For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
  For $x2D = 0 To $giPuzzle_X2D_UBound - 1
   If $gaPuzzle[$y1D][$x2D][$giPuzzle_3D_Known] > 0 Then $gaPuzzle[$y1D][$x2D][$giPuzzle_3D_aPossible] = ""
  Next
 Next
 Return $gaPuzzle
EndFunc   ;==>GenerateFILEPuzzle
Func GuiCreateCurrent()
 $iControlHeight = 15
 $iControlWidth = 15
 $iControlBuffer = 10
 $iGuiWidth = $iControlBuffer + (($iControlWidth + $iControlBuffer) * $giPuzzle_X2D_UBound)
 $iGuiHeight = $iControlBuffer + (($iControlWidth + $iControlBuffer) * $giPuzzle_Y1D_UBound)
 Global $hGui = GUICreate(@ScriptName, $iGuiWidth, $iGuiHeight)
 For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
  For $x2D = 0 To $giPuzzle_X2D_UBound - 1
   $gaPuzzle[$y1D][$x2D][$giPuzzle_3D_Control] = GUICtrlCreateLabel($gaPuzzle[$y1D][$x2D][$giPuzzle_3D_Known], $iControlBuffer + (($x2D) * ($iControlWidth + $iControlBuffer)), $iControlBuffer + (($y1D) * ($iControlWidth + $iControlBuffer)), $iControlWidth, $iControlHeight, BitOR($SS_SUNKEN, $SS_CENTER))
   Switch $y1D
    Case 0 To 2, 6 To 8
     If $x2D < 3 Or $x2D > 5 Then GUICtrlSetBkColor(-1, 0x00ff00)
    Case 3 To 5
     If $x2D > 2 And $x2D < 6 Then GUICtrlSetBkColor(-1, 0x00ff00)
   EndSwitch
  Next
 Next
 GUISetState(@SW_SHOW)
 $bReturn_GuiCreateCurrent = False
 MsgBox(1, 1, "Solve on close of this msgbox")
 Local $iGuessCounter = 0
 Local $iRecurssionCounter = 0
 While True
  $msg = GUIGetMsg()
  While FillInEasyAndRemoveKnown()
   ;MsgBox (1,1,"FillInEasyAndRemoveKnown")
  WEnd
  ; Check if number is only available in a section once...that is by default, correct
  If FillInWhenOnlyOneCellInSectionHasPossibleNumber() Then
   ;MsgBox (1,1,"FillInWhenOnlyOneCellInSectionHasPossibleNumber")
   ContinueLoop
  EndIf

  If FillInWhenOnlyOneCellInColHasPossibleNumberX() Then
   ;MsgBox (1,1,"FillInWhenOnlyOneCellInColHasPossibleNumberX")
   ContinueLoop
  EndIf
  If FillInWhenOnlyOneCellInRowHasPossibleNumberY() Then
   ;MsgBox (1,1,"FillInWhenOnlyOneCellInRowHasPossibleNumberY")
   ContinueLoop
  EndIf
  ; Last resort...guess, and attempt to fill all in based on the guess
  ; Guess fills in known values to KnownGuess, and checks if all are filled to return true
  ;MsgBox (1,1,"done")
  While True
   Switch Guess($iGuessCounter, 0)
    Case 0
     $iGuessCounter2 = 0
     While True
      Switch Guess($iGuessCounter2, 1)
       Case 0
        $iGuessCounter3 = 0
        While True
         Switch Guess($iGuessCounter3, 2)
          Case 0
           $iGuessCounter4 = 0
           While True
            Switch Guess($iGuessCounter4, 3)
             Case 0
              $iGuessCounter5 = 0
              While True
               Switch Guess($iGuessCounter5, 4)
                Case 0
                 $iGuessCounter6 = 0
                 While True
                  Switch Guess($iGuessCounter6, 5)
                   Case 0
                    $iGuessCounter7 = 0
                    While True
                     Switch Guess($iGuessCounter7, 6)
                      Case 0
                       $iGuessCounter8 = 0
                       While True
                        Switch Guess($iGuessCounter8, 7)
                         Case 0
                          $iGuessCounter9 = 0
                          While True
                           Switch Guess($iGuessCounter9, 8)
                            Case 0
                             $iGuessCounter10 = 0
                             While True
                              Switch Guess($iGuessCounter10, 9)
                               Case 1
                                Return True
                               Case 2
;~                              If Not DeleteFirstPossibleGuess(8) Then ExitLoop
                                ExitLoop
                              EndSwitch
                              $iGuessCounter10=0
                             WEnd
                            Case 1
                             Return True
                            Case 2
;~                           If Not DeleteFirstPossibleGuess(7) Then ExitLoop
                             ExitLoop
                           EndSwitch
                           $iGuessCounter9=0
                          WEnd
                         Case 1
                          Return True
                         Case 2
;~                        If Not DeleteFirstPossibleGuess(6) Then ExitLoop
                          ExitLoop
                        EndSwitch
                        $iGuessCounter8=0
                       WEnd
                      Case 1
                       Return True
                      Case 2
;~                     If Not DeleteFirstPossibleGuess(5) Then ExitLoop
                       ExitLoop
                     EndSwitch
                     $iGuessCounter7=0
                    WEnd
                   Case 1
                    Return True
                   Case 2
;~                  If Not DeleteFirstPossibleGuess(4) Then ExitLoop
                    ExitLoop
                  EndSwitch
                  $iGuessCounter6=0
                 WEnd
                Case 1
                 Return True
                Case 2
;~               If Not DeleteFirstPossibleGuess(3) Then ExitLoop
                 ExitLoop
               EndSwitch
               $iGuessCounter5=0
              WEnd
             Case 1
              Return True
             Case 2
;~            If Not DeleteFirstPossibleGuess(2) Then ExitLoop
              ExitLoop
            EndSwitch
            $iGuessCounter4=0
           WEnd
          Case 1
           Return True
          Case 2
;~         If Not DeleteFirstPossibleGuess(1) Then ExitLoop
           ExitLoop
         EndSwitch
         $iGuessCounter3=0
        WEnd
       Case 1
        Return True
       Case 2
;~      DeleteFirstPossibleGuess(0)
        ExitLoop
      EndSwitch
      $iGuessCounter2=0
     WEnd
    Case 1
     Return True
    Case 2
     Return False
   EndSwitch
   ;DeleteFirstPossibleGuess(0)
   $iGuessCounter=0
  WEnd
;~   If CheckIfWon() Then
;~    $bReturn_GuiCreateCurrent = True
;~    ExitLoop
;~   EndIf
  If $msg = $GUI_EVENT_CLOSE Then Exit
 WEnd
 Return $bReturn_GuiCreateCurrent
EndFunc   ;==>GuiCreateCurrent
Func DeleteFirstPossibleGuess ($iRecurssionCounter=0)
 If $iRecurssionCounter = 0 Then
  $iKnown = $giPuzzle_3D_Known
  $iaPossible = $giPuzzle_3D_aPossible
 ElseIf $iRecurssionCounter = 1 Then
  $iKnown = $giPuzzle_3D_KnownGuess
  $iaPossible = $giPuzzle_3D_aGuessPossible
 ElseIf $iRecurssionCounter = 2 Then
  $iKnown = $giPuzzle_3D_KnownGuess2
  $iaPossible = $giPuzzle_3D_aGuessPossible2
 ElseIf $iRecurssionCounter = 3 Then
  $iKnown = $giPuzzle_3D_KnownGuess3
  $iaPossible = $giPuzzle_3D_aGuessPossible3
 ElseIf $iRecurssionCounter = 4 Then
  $iKnown = $giPuzzle_3D_KnownGuess4
  $iaPossible = $giPuzzle_3D_aGuessPossible4
 ElseIf $iRecurssionCounter = 5 Then
  $iKnown = $giPuzzle_3D_KnownGuess5
  $iaPossible = $giPuzzle_3D_aGuessPossible5
 ElseIf $iRecurssionCounter = 6 Then
  $iKnown = $giPuzzle_3D_KnownGuess6
  $iaPossible = $giPuzzle_3D_aGuessPossible6
 ElseIf $iRecurssionCounter = 7 Then
  $iKnown = $giPuzzle_3D_KnownGuess7
  $iaPossible = $giPuzzle_3D_aGuessPossible7
 ElseIf $iRecurssionCounter = 8 Then
  $iKnown = $giPuzzle_3D_KnownGuess8
  $iaPossible = $giPuzzle_3D_aGuessPossible8
 ElseIf $iRecurssionCounter = 9 Then
  $iKnown = $giPuzzle_3D_KnownGuess9
  $iaPossible = $giPuzzle_3D_aGuessPossible9
 ElseIf $iRecurssionCounter = 10 Then
  $iKnown = $giPuzzle_3D_KnownGuess10
  $iaPossible = $giPuzzle_3D_aGuessPossible10
 Else
  MsgBox (1,1,@ScriptLineNumber)
 EndIf
 For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
  For $x2D = 0 To $giPuzzle_X2D_UBound - 1
   $aTemp = $gaPuzzle[$y1D][$x2D][$iaPossible]
   If StringLen ( $gaPuzzle[$y1D][$x2D][$iKnown] ) = 0 Then
    If IsArray ($aTemp) Then
     _ArrayDelete ($aTemp, 0)
     $gaPuzzle[$y1D][$x2D][$iaPossible] = $aTemp
     Return True
    Else
     Return False
     ; this loop means all options are false, so exit loop
    EndIf
   EndIf
  Next
 Next
 Return False
EndFunc
Func FillInEasyAndRemoveKnown($bGuess = False, $iRecurssionCounter = 0)
 If Not $bGuess Then
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_Known
   $iaPossible = $giPuzzle_3D_aPossible
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 Else
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_KnownGuess
   $iaPossible = $giPuzzle_3D_aGuessPossible
  ElseIf $iRecurssionCounter = 1 Then
   $iKnown = $giPuzzle_3D_KnownGuess2
   $iaPossible = $giPuzzle_3D_aGuessPossible2
  ElseIf $iRecurssionCounter = 2 Then
   $iKnown = $giPuzzle_3D_KnownGuess3
   $iaPossible = $giPuzzle_3D_aGuessPossible3
  ElseIf $iRecurssionCounter = 3 Then
   $iKnown = $giPuzzle_3D_KnownGuess4
   $iaPossible = $giPuzzle_3D_aGuessPossible4
  ElseIf $iRecurssionCounter = 4 Then
   $iKnown = $giPuzzle_3D_KnownGuess5
   $iaPossible = $giPuzzle_3D_aGuessPossible5
  ElseIf $iRecurssionCounter = 5 Then
   $iKnown = $giPuzzle_3D_KnownGuess6
   $iaPossible = $giPuzzle_3D_aGuessPossible6
  ElseIf $iRecurssionCounter = 6 Then
   $iKnown = $giPuzzle_3D_KnownGuess7
   $iaPossible = $giPuzzle_3D_aGuessPossible7
  ElseIf $iRecurssionCounter = 7 Then
   $iKnown = $giPuzzle_3D_KnownGuess8
   $iaPossible = $giPuzzle_3D_aGuessPossible8
  ElseIf $iRecurssionCounter = 8 Then
   $iKnown = $giPuzzle_3D_KnownGuess9
   $iaPossible = $giPuzzle_3D_aGuessPossible9
  ElseIf $iRecurssionCounter = 9 Then
   $iKnown = $giPuzzle_3D_KnownGuess10
   $iaPossible = $giPuzzle_3D_aGuessPossible10
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 EndIf
 $bReturn_FillInEasyAndRemoveKnown = False
 ; Clear out possible array of row and column
 For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
  For $x2D = 0 To $giPuzzle_X2D_UBound - 1
   If StringLen($gaPuzzle[$y1D][$x2D][$iKnown]) > 0 Then
    RemoveYRowPossibility($y1D, $gaPuzzle[$y1D][$x2D][$iKnown], $bGuess, $iRecurssionCounter)
    RemoveXColPossibility($x2D, $gaPuzzle[$y1D][$x2D][$iKnown], $bGuess, $iRecurssionCounter)
   EndIf
  Next
 Next
 ; Clear out possiblity of section
 For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
  For $x2D = 0 To $giPuzzle_X2D_UBound - 1
   ; Only enter if known
   $iTempKnown = $gaPuzzle[$y1D][$x2D][$iKnown]
   If StringLen($iTempKnown) = 0 Then ContinueLoop
   Switch $y1D
    Case 0 To 2
     $yStart = 0
    Case 3 To 5
     $yStart = 3
    Case 6 To 8
     $yStart = 6
   EndSwitch
   Switch $x2D
    Case 0 To 2
     $xStart = 0
    Case 3 To 5
     $xStart = 3
    Case 6 To 8
     $xStart = 6
   EndSwitch
   For $y = $yStart To $yStart + 2
    For $x = $xStart To $xStart + 2
     ; Skip current case
     If $y = $y1D And $x = $x2D Then ContinueLoop
     RemoveCellPossibility($y, $x, $iTempKnown, $bGuess,$iRecurssionCounter)
    Next
   Next
  Next
 Next
 ; Loop through all, and find where possible ubound = 1...that is now known...if found, return true...if none found, return false
 For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
  For $x2D = 0 To $giPuzzle_X2D_UBound - 1
   If StringLen($gaPuzzle[$y1D][$x2D][$iKnown]) = 0 Then
    $aTemp = $gaPuzzle[$y1D][$x2D][$iaPossible]
    If UBound($aTemp) = 1 Then
     UpdateGuiWithKnownValue($y1D, $x2D, $aTemp[0], $bGuess, $iRecurssionCounter)
     RemoveYRowPossibility($y1D, $aTemp[0], $bGuess, $iRecurssionCounter)
     RemoveXColPossibility($x2D, $aTemp[0], $bGuess, $iRecurssionCounter)
     Return True
    EndIf
   EndIf
  Next
 Next
 Return $bReturn_FillInEasyAndRemoveKnown
EndFunc   ;==>FillInEasyAndRemoveKnown
Func RemoveYRowPossibility($iCallersYValue, $iCallersKnownValue, $bGuess = False, $iRecurssionCounter = 0)
 If Not $bGuess Then
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_Known
   $iaPossible = $giPuzzle_3D_aPossible
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 Else
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_KnownGuess
   $iaPossible = $giPuzzle_3D_aGuessPossible
  ElseIf $iRecurssionCounter = 1 Then
   $iKnown = $giPuzzle_3D_KnownGuess2
   $iaPossible = $giPuzzle_3D_aGuessPossible2
  ElseIf $iRecurssionCounter = 2 Then
   $iKnown = $giPuzzle_3D_KnownGuess3
   $iaPossible = $giPuzzle_3D_aGuessPossible3
  ElseIf $iRecurssionCounter = 3 Then
   $iKnown = $giPuzzle_3D_KnownGuess4
   $iaPossible = $giPuzzle_3D_aGuessPossible4
  ElseIf $iRecurssionCounter = 4 Then
   $iKnown = $giPuzzle_3D_KnownGuess5
   $iaPossible = $giPuzzle_3D_aGuessPossible5
  ElseIf $iRecurssionCounter = 5 Then
   $iKnown = $giPuzzle_3D_KnownGuess6
   $iaPossible = $giPuzzle_3D_aGuessPossible6
  ElseIf $iRecurssionCounter = 6 Then
   $iKnown = $giPuzzle_3D_KnownGuess7
   $iaPossible = $giPuzzle_3D_aGuessPossible7
  ElseIf $iRecurssionCounter = 7 Then
   $iKnown = $giPuzzle_3D_KnownGuess8
   $iaPossible = $giPuzzle_3D_aGuessPossible8
  ElseIf $iRecurssionCounter = 8 Then
   $iKnown = $giPuzzle_3D_KnownGuess9
   $iaPossible = $giPuzzle_3D_aGuessPossible9
  ElseIf $iRecurssionCounter = 9 Then
   $iKnown = $giPuzzle_3D_KnownGuess10
   $iaPossible = $giPuzzle_3D_aGuessPossible10
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 EndIf
 For $i = 0 To $giPuzzle_X2D_UBound - 1
  $aTemp = $gaPuzzle[$iCallersYValue][$i][$iaPossible]
  $iDeleteValue = _ArraySearch($aTemp, $iCallersKnownValue)
  If $iDeleteValue >= 0 Then _ArrayDelete($aTemp, $iDeleteValue)
  $gaPuzzle[$iCallersYValue][$i][$iaPossible] = $aTemp
 Next
EndFunc   ;==>RemoveYRowPossibility
Func RemoveXColPossibility($iCallersXValue, $iCallersKnownValue, $bGuess = False, $iRecurssionCounter = 0)
 If Not $bGuess Then
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_Known
   $iaPossible = $giPuzzle_3D_aPossible
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 Else
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_KnownGuess
   $iaPossible = $giPuzzle_3D_aGuessPossible
  ElseIf $iRecurssionCounter = 1 Then
   $iKnown = $giPuzzle_3D_KnownGuess2
   $iaPossible = $giPuzzle_3D_aGuessPossible2
  ElseIf $iRecurssionCounter = 2 Then
   $iKnown = $giPuzzle_3D_KnownGuess3
   $iaPossible = $giPuzzle_3D_aGuessPossible3
  ElseIf $iRecurssionCounter = 3 Then
   $iKnown = $giPuzzle_3D_KnownGuess4
   $iaPossible = $giPuzzle_3D_aGuessPossible4
  ElseIf $iRecurssionCounter = 4 Then
   $iKnown = $giPuzzle_3D_KnownGuess5
   $iaPossible = $giPuzzle_3D_aGuessPossible5
  ElseIf $iRecurssionCounter = 5 Then
   $iKnown = $giPuzzle_3D_KnownGuess6
   $iaPossible = $giPuzzle_3D_aGuessPossible6
  ElseIf $iRecurssionCounter = 6 Then
   $iKnown = $giPuzzle_3D_KnownGuess7
   $iaPossible = $giPuzzle_3D_aGuessPossible7
  ElseIf $iRecurssionCounter = 7 Then
   $iKnown = $giPuzzle_3D_KnownGuess8
   $iaPossible = $giPuzzle_3D_aGuessPossible8
  ElseIf $iRecurssionCounter = 8 Then
   $iKnown = $giPuzzle_3D_KnownGuess9
   $iaPossible = $giPuzzle_3D_aGuessPossible9
  ElseIf $iRecurssionCounter = 9 Then
   $iKnown = $giPuzzle_3D_KnownGuess10
   $iaPossible = $giPuzzle_3D_aGuessPossible10
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 EndIf
 For $i = 0 To $giPuzzle_Y1D_UBound - 1
  $aTemp = $gaPuzzle[$i][$iCallersXValue][$iaPossible]
  $iDeleteValue = _ArraySearch($aTemp, $iCallersKnownValue)
  If $iDeleteValue >= 0 Then _ArrayDelete($aTemp, $iDeleteValue)
  $gaPuzzle[$i][$iCallersXValue][$iaPossible] = $aTemp
 Next
EndFunc   ;==>RemoveXColPossibility
Func RemoveCellPossibility($iCallersYValue, $iCallersXValue, $iCallersKnownValue, $bGuess = False, $iRecurssionCounter = 0)
 If Not $bGuess Then
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_Known
   $iaPossible = $giPuzzle_3D_aPossible
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 Else
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_KnownGuess
   $iaPossible = $giPuzzle_3D_aGuessPossible
  ElseIf $iRecurssionCounter = 1 Then
   $iKnown = $giPuzzle_3D_KnownGuess2
   $iaPossible = $giPuzzle_3D_aGuessPossible2
  ElseIf $iRecurssionCounter = 2 Then
   $iKnown = $giPuzzle_3D_KnownGuess3
   $iaPossible = $giPuzzle_3D_aGuessPossible3
  ElseIf $iRecurssionCounter = 3 Then
   $iKnown = $giPuzzle_3D_KnownGuess4
   $iaPossible = $giPuzzle_3D_aGuessPossible4
  ElseIf $iRecurssionCounter = 4 Then
   $iKnown = $giPuzzle_3D_KnownGuess5
   $iaPossible = $giPuzzle_3D_aGuessPossible5
  ElseIf $iRecurssionCounter = 5 Then
   $iKnown = $giPuzzle_3D_KnownGuess6
   $iaPossible = $giPuzzle_3D_aGuessPossible6
  ElseIf $iRecurssionCounter = 6 Then
   $iKnown = $giPuzzle_3D_KnownGuess7
   $iaPossible = $giPuzzle_3D_aGuessPossible7
  ElseIf $iRecurssionCounter = 7 Then
   $iKnown = $giPuzzle_3D_KnownGuess8
   $iaPossible = $giPuzzle_3D_aGuessPossible8
  ElseIf $iRecurssionCounter = 8 Then
   $iKnown = $giPuzzle_3D_KnownGuess9
   $iaPossible = $giPuzzle_3D_aGuessPossible9
  ElseIf $iRecurssionCounter = 9 Then
   $iKnown = $giPuzzle_3D_KnownGuess10
   $iaPossible = $giPuzzle_3D_aGuessPossible10
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 EndIf
 $aTemp = $gaPuzzle[$iCallersYValue][$iCallersXValue][$iaPossible]
 $iDeleteValue = _ArraySearch($aTemp, $iCallersKnownValue)
 If $iDeleteValue >= 0 Then _ArrayDelete($aTemp, $iDeleteValue)
 $gaPuzzle[$iCallersYValue][$iCallersXValue][$iaPossible] = $aTemp
EndFunc   ;==>RemoveCellPossibility
Func UpdateGuiWithKnownValue($iCallersYValue, $iCallersXValue, $iCallersKnownValue, $bGuess = False, $iRecurssionCounter = 0)
 If Not $bGuess Then
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_Known
   $iaPossible = $giPuzzle_3D_aPossible
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 Else
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_KnownGuess
   $iaPossible = $giPuzzle_3D_aGuessPossible
  ElseIf $iRecurssionCounter = 1 Then
   $iKnown = $giPuzzle_3D_KnownGuess2
   $iaPossible = $giPuzzle_3D_aGuessPossible2
  ElseIf $iRecurssionCounter = 2 Then
   $iKnown = $giPuzzle_3D_KnownGuess3
   $iaPossible = $giPuzzle_3D_aGuessPossible3
  ElseIf $iRecurssionCounter = 3 Then
   $iKnown = $giPuzzle_3D_KnownGuess4
   $iaPossible = $giPuzzle_3D_aGuessPossible4
  ElseIf $iRecurssionCounter = 4 Then
   $iKnown = $giPuzzle_3D_KnownGuess5
   $iaPossible = $giPuzzle_3D_aGuessPossible5
  ElseIf $iRecurssionCounter = 5 Then
   $iKnown = $giPuzzle_3D_KnownGuess6
   $iaPossible = $giPuzzle_3D_aGuessPossible6
  ElseIf $iRecurssionCounter = 6 Then
   $iKnown = $giPuzzle_3D_KnownGuess7
   $iaPossible = $giPuzzle_3D_aGuessPossible7
  ElseIf $iRecurssionCounter = 7 Then
   $iKnown = $giPuzzle_3D_KnownGuess8
   $iaPossible = $giPuzzle_3D_aGuessPossible8
  ElseIf $iRecurssionCounter = 8 Then
   $iKnown = $giPuzzle_3D_KnownGuess9
   $iaPossible = $giPuzzle_3D_aGuessPossible9
  ElseIf $iRecurssionCounter = 9 Then
   $iKnown = $giPuzzle_3D_KnownGuess10
   $iaPossible = $giPuzzle_3D_aGuessPossible10
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 EndIf
 $gaPuzzle[$iCallersYValue][$iCallersXValue][$iKnown] = $iCallersKnownValue
 $gaPuzzle[$iCallersYValue][$iCallersXValue][$iaPossible] = ""
 GUICtrlSetData($gaPuzzle[$iCallersYValue][$iCallersXValue][$giPuzzle_3D_Control], $gaPuzzle[$iCallersYValue][$iCallersXValue][$iKnown])
EndFunc   ;==>UpdateGuiWithKnownValue
Func FillInWhenOnlyOneCellInSectionHasPossibleNumber($bGuess = False, $iRecurssionCounter = 0)
 If Not $bGuess Then
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_Known
   $iaPossible = $giPuzzle_3D_aPossible
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 Else
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_KnownGuess
   $iaPossible = $giPuzzle_3D_aGuessPossible
  ElseIf $iRecurssionCounter = 1 Then
   $iKnown = $giPuzzle_3D_KnownGuess2
   $iaPossible = $giPuzzle_3D_aGuessPossible2
  ElseIf $iRecurssionCounter = 2 Then
   $iKnown = $giPuzzle_3D_KnownGuess3
   $iaPossible = $giPuzzle_3D_aGuessPossible3
  ElseIf $iRecurssionCounter = 3 Then
   $iKnown = $giPuzzle_3D_KnownGuess4
   $iaPossible = $giPuzzle_3D_aGuessPossible4
  ElseIf $iRecurssionCounter = 4 Then
   $iKnown = $giPuzzle_3D_KnownGuess5
   $iaPossible = $giPuzzle_3D_aGuessPossible5
  ElseIf $iRecurssionCounter = 5 Then
   $iKnown = $giPuzzle_3D_KnownGuess6
   $iaPossible = $giPuzzle_3D_aGuessPossible6
  ElseIf $iRecurssionCounter = 6 Then
   $iKnown = $giPuzzle_3D_KnownGuess7
   $iaPossible = $giPuzzle_3D_aGuessPossible7
  ElseIf $iRecurssionCounter = 7 Then
   $iKnown = $giPuzzle_3D_KnownGuess8
   $iaPossible = $giPuzzle_3D_aGuessPossible8
  ElseIf $iRecurssionCounter = 8 Then
   $iKnown = $giPuzzle_3D_KnownGuess9
   $iaPossible = $giPuzzle_3D_aGuessPossible9
  ElseIf $iRecurssionCounter = 9 Then
   $iKnown = $giPuzzle_3D_KnownGuess10
   $iaPossible = $giPuzzle_3D_aGuessPossible10
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 EndIf
 $bReturn_FillInWhenOnlyOneCellInSectionHasPossibleNumber = False
 ; loop through number until a section returns only 1 possibility for that number...return true after setting
 For $iNumber = 1 To 9
  ; Reset counter
  ; Loops to allow increasing conditional bounds
  $iYMin = 0
  $iYMax = 2
  For $y = 0 To 2
   $iXMin = 0
   $iXMax = 2
   For $x = 0 To 2
    $iTempSectionCounter = 9
    ; decided to go section by section...too tird to logically do in one loop
    $bContinueLoop = True
    For $y1D = $iYMin To $iYMax
     For $x2D = $iXMin To $iXMax
      If $gaPuzzle[$y1D][$x2D][$iKnown] = $iNumber Then
       $bContinueLoop = False
       $iTempSectionCounter = 0
      Else
       If StringLen($gaPuzzle[$y1D][$x2D][$iKnown]) > 0 Or _ArraySearch($gaPuzzle[$y1D][$x2D][$iaPossible], $iNumber) < 0 Then
        $iTempSectionCounter -= 1
       EndIf
      EndIf
      If Not $bContinueLoop Then ExitLoop
     Next
     If Not $bContinueLoop Then ExitLoop
    Next
    If $iTempSectionCounter = 1 Then
     For $y1D = $iYMin To $iYMax
      For $x2D = $iXMin To $iXMax
       If _ArraySearch($gaPuzzle[$y1D][$x2D][$iaPossible], $iNumber) >= 0 Then
        UpdateGuiWithKnownValue($y1D, $x2D, $iNumber, $bGuess, $iRecurssionCounter)
        RemoveYRowPossibility($y1D, $iNumber, $bGuess, $iRecurssionCounter)
        RemoveXColPossibility($x2D, $iNumber, $bGuess, $iRecurssionCounter)
        Return True
       EndIf
      Next
     Next
    EndIf
    ; Current section didn't include any
    $iXMin += 3
    $iXMax += 3
   Next
   $iYMin += 3
   $iYMax += 3
  Next
 Next
 Return $bReturn_FillInWhenOnlyOneCellInSectionHasPossibleNumber
EndFunc   ;==>FillInWhenOnlyOneCellInSectionHasPossibleNumber
Func FillInWhenOnlyOneCellInColHasPossibleNumberX($bGuess = False, $iRecurssionCounter = 0)
 If Not $bGuess Then
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_Known
   $iaPossible = $giPuzzle_3D_aPossible
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 Else
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_KnownGuess
   $iaPossible = $giPuzzle_3D_aGuessPossible
  ElseIf $iRecurssionCounter = 1 Then
   $iKnown = $giPuzzle_3D_KnownGuess2
   $iaPossible = $giPuzzle_3D_aGuessPossible2
  ElseIf $iRecurssionCounter = 2 Then
   $iKnown = $giPuzzle_3D_KnownGuess3
   $iaPossible = $giPuzzle_3D_aGuessPossible3
  ElseIf $iRecurssionCounter = 3 Then
   $iKnown = $giPuzzle_3D_KnownGuess4
   $iaPossible = $giPuzzle_3D_aGuessPossible4
  ElseIf $iRecurssionCounter = 4 Then
   $iKnown = $giPuzzle_3D_KnownGuess5
   $iaPossible = $giPuzzle_3D_aGuessPossible5
  ElseIf $iRecurssionCounter = 5 Then
   $iKnown = $giPuzzle_3D_KnownGuess6
   $iaPossible = $giPuzzle_3D_aGuessPossible6
  ElseIf $iRecurssionCounter = 6 Then
   $iKnown = $giPuzzle_3D_KnownGuess7
   $iaPossible = $giPuzzle_3D_aGuessPossible7
  ElseIf $iRecurssionCounter = 7 Then
   $iKnown = $giPuzzle_3D_KnownGuess8
   $iaPossible = $giPuzzle_3D_aGuessPossible8
  ElseIf $iRecurssionCounter = 8 Then
   $iKnown = $giPuzzle_3D_KnownGuess9
   $iaPossible = $giPuzzle_3D_aGuessPossible9
  ElseIf $iRecurssionCounter = 9 Then
   $iKnown = $giPuzzle_3D_KnownGuess10
   $iaPossible = $giPuzzle_3D_aGuessPossible10
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 EndIf
 $bReturn_FillInWhenOnlyOneCellInColHasPossibleNumberX = False
 For $iNumber = 1 To 9
  For $x2D = 0 To $giPuzzle_X2D_UBound - 1
   $bContinueLoop = True
   $iTempColumnCounter = 9
   For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
    If StringLen($gaPuzzle[$y1D][$x2D][$iKnown]) > 0 Or _ArraySearch($gaPuzzle[$y1D][$x2D][$iaPossible], $iNumber) < 0 Then
     $iTempColumnCounter -= 1
    EndIf
   Next
   If $iTempColumnCounter = 1 Then ExitLoop
  Next
  If $iTempColumnCounter = 1 Then
   For $x2D = $x2D To $x2D
    For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
     If _ArraySearch($gaPuzzle[$y1D][$x2D][$iaPossible], $iNumber) >= 0 Then
      UpdateGuiWithKnownValue($y1D, $x2D, $iNumber, $bGuess, $iRecurssionCounter)
      RemoveYRowPossibility($y1D, $iNumber, $bGuess, $iRecurssionCounter)
      Return True
     EndIf
    Next
   Next
  EndIf
 Next
 Return $bReturn_FillInWhenOnlyOneCellInColHasPossibleNumberX
EndFunc   ;==>FillInWhenOnlyOneCellInColHasPossibleNumberX
Func FillInWhenOnlyOneCellInRowHasPossibleNumberY($bGuess = False, $iRecurssionCounter = 0)
 If Not $bGuess Then
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_Known
   $iaPossible = $giPuzzle_3D_aPossible
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 Else
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_KnownGuess
   $iaPossible = $giPuzzle_3D_aGuessPossible
  ElseIf $iRecurssionCounter = 1 Then
   $iKnown = $giPuzzle_3D_KnownGuess2
   $iaPossible = $giPuzzle_3D_aGuessPossible2
  ElseIf $iRecurssionCounter = 2 Then
   $iKnown = $giPuzzle_3D_KnownGuess3
   $iaPossible = $giPuzzle_3D_aGuessPossible3
  ElseIf $iRecurssionCounter = 3 Then
   $iKnown = $giPuzzle_3D_KnownGuess4
   $iaPossible = $giPuzzle_3D_aGuessPossible4
  ElseIf $iRecurssionCounter = 4 Then
   $iKnown = $giPuzzle_3D_KnownGuess5
   $iaPossible = $giPuzzle_3D_aGuessPossible5
  ElseIf $iRecurssionCounter = 5 Then
   $iKnown = $giPuzzle_3D_KnownGuess6
   $iaPossible = $giPuzzle_3D_aGuessPossible6
  ElseIf $iRecurssionCounter = 6 Then
   $iKnown = $giPuzzle_3D_KnownGuess7
   $iaPossible = $giPuzzle_3D_aGuessPossible7
  ElseIf $iRecurssionCounter = 7 Then
   $iKnown = $giPuzzle_3D_KnownGuess8
   $iaPossible = $giPuzzle_3D_aGuessPossible8
  ElseIf $iRecurssionCounter = 8 Then
   $iKnown = $giPuzzle_3D_KnownGuess9
   $iaPossible = $giPuzzle_3D_aGuessPossible9
  ElseIf $iRecurssionCounter = 9 Then
   $iKnown = $giPuzzle_3D_KnownGuess10
   $iaPossible = $giPuzzle_3D_aGuessPossible10
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 EndIf
 $bReturn_FillInWhenOnlyOneCellInRowHasPossibleNumberY = False
 For $iNumber = 1 To 9
  For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
   $bContinueLoop = True
   $iTempRowCounter = 9
   For $x2D = 0 To $giPuzzle_X2D_UBound - 1
    If StringLen($gaPuzzle[$y1D][$x2D][$iKnown]) > 0 Or _ArraySearch($gaPuzzle[$y1D][$x2D][$iaPossible], $iNumber) < 0 Then
     $iTempRowCounter -= 1
    EndIf
   Next
   If $iTempRowCounter = 1 Then ExitLoop
  Next
  If $iTempRowCounter = 1 Then
   For $y1D = $y1D To $y1D
    For $x2D = 0 To $giPuzzle_X2D_UBound - 1
     If _ArraySearch($gaPuzzle[$y1D][$x2D][$iaPossible], $iNumber) >= 0 Then
      UpdateGuiWithKnownValue($y1D, $x2D, $iNumber, $bGuess, $iRecurssionCounter)
      RemoveXColPossibility($x2D, $iNumber, $bGuess, $iRecurssionCounter)
      Return True
     EndIf
    Next
   Next
  EndIf
 Next
 Return $bReturn_FillInWhenOnlyOneCellInRowHasPossibleNumberY
EndFunc   ;==>FillInWhenOnlyOneCellInRowHasPossibleNumberY
Func Guess($iGuessCounter,$iRecurssionCounter)
 ; Blindly use the first avail array possibility that matches $iGuessCounter...attempt to solve...if not, false (outside function the guess counter increments, and attempts again)
 Local $iTempGuessCounter = $iGuessCounter
;~  If CheckIfWon(False) Then Return True
 If $iRecurssionCounter = 0 Then
  $sPrefix = ""
  $iKnown = $giPuzzle_3D_Known
  $iaPossible = $giPuzzle_3D_aPossible
  $iGuess = $giPuzzle_3D_KnownGuess
  $iaGuessPossible = $giPuzzle_3D_aGuessPossible
 ElseIf $iRecurssionCounter = 1 Then
  $sPrefix = " "
  $iKnown = $giPuzzle_3D_KnownGuess
  $iaPossible = $giPuzzle_3D_aGuessPossible
  $iGuess = $giPuzzle_3D_KnownGuess2
  $iaGuessPossible = $giPuzzle_3D_aGuessPossible2
 ElseIf $iRecurssionCounter = 2 Then
  $sPrefix = "  "
  $iKnown = $giPuzzle_3D_KnownGuess2
  $iaPossible = $giPuzzle_3D_aGuessPossible2
  $iGuess = $giPuzzle_3D_KnownGuess3
  $iaGuessPossible = $giPuzzle_3D_aGuessPossible3
 ElseIf $iRecurssionCounter = 3 Then
  $sPrefix = "   "
  $iKnown = $giPuzzle_3D_KnownGuess3
  $iaPossible = $giPuzzle_3D_aGuessPossible3
  $iGuess = $giPuzzle_3D_KnownGuess4
  $iaGuessPossible = $giPuzzle_3D_aGuessPossible4
 ElseIf $iRecurssionCounter = 4 Then
  $sPrefix = "  "
  $iKnown = $giPuzzle_3D_KnownGuess4
  $iaPossible = $giPuzzle_3D_aGuessPossible4
  $iGuess = $giPuzzle_3D_KnownGuess5
  $iaGuessPossible = $giPuzzle_3D_aGuessPossible5
 ElseIf $iRecurssionCounter = 5 Then
  $sPrefix = "   "
  $iKnown = $giPuzzle_3D_KnownGuess5
  $iaPossible = $giPuzzle_3D_aGuessPossible5
  $iGuess = $giPuzzle_3D_KnownGuess6
  $iaGuessPossible = $giPuzzle_3D_aGuessPossible6
 ElseIf $iRecurssionCounter = 6 Then
  $sPrefix = "    "
  $iKnown = $giPuzzle_3D_KnownGuess6
  $iaPossible = $giPuzzle_3D_aGuessPossible6
  $iGuess = $giPuzzle_3D_KnownGuess7
  $iaGuessPossible = $giPuzzle_3D_aGuessPossible7
 ElseIf $iRecurssionCounter = 7 Then
  $sPrefix = "     "
  $iKnown = $giPuzzle_3D_KnownGuess7
  $iaPossible = $giPuzzle_3D_aGuessPossible7
  $iGuess = $giPuzzle_3D_KnownGuess8
  $iaGuessPossible = $giPuzzle_3D_aGuessPossible8
 ElseIf $iRecurssionCounter = 8 Then
  $sPrefix = "      "
  $iKnown = $giPuzzle_3D_KnownGuess8
  $iaPossible = $giPuzzle_3D_aGuessPossible8
  $iGuess = $giPuzzle_3D_KnownGuess9
  $iaGuessPossible = $giPuzzle_3D_aGuessPossible9
 ElseIf $iRecurssionCounter = 9 Then
  $sPrefix = "       "
  $iKnown = $giPuzzle_3D_KnownGuess9
  $iaPossible = $giPuzzle_3D_aGuessPossible9
  $iGuess = $giPuzzle_3D_KnownGuess10
  $iaGuessPossible = $giPuzzle_3D_aGuessPossible10
 EndIf
 ConsoleWrite($sPrefix & "Recur=[" & $iRecurssionCounter & "]; GuessCounter=[" & $iGuessCounter & "];" )
 ; Clear out all known guesses, and reset availguess array to possible array
 For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
  For $x2D = 0 To $giPuzzle_X2D_UBound - 1
   If StringLen($gaPuzzle[$y1D][$x2D][$iGuess]) > 0 And StringLen($gaPuzzle[$y1D][$x2D][$iKnown]) = 0 Then
    GUICtrlSetData($gaPuzzle[$y1D][$x2D][$giPuzzle_3D_Control], "")
   EndIf
   $gaPuzzle[$y1D][$x2D][$iGuess] = $gaPuzzle[$y1D][$x2D][$iKnown]
   $gaPuzzle[$y1D][$x2D][$iaGuessPossible] = $gaPuzzle[$y1D][$x2D][$iaPossible]
  Next
 Next
 ; Check if already won
 If CheckIfWon(True) Then Return True
 ; Loop Through until an element is found matching the current $iGuessCounter
 $bGuessFound = False
 For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
  For $x2D = 0 To $giPuzzle_X2D_UBound - 1
   If StringLen ($gaPuzzle[$y1D][$x2D][$iGuess])=0 Then
    $aTemp = $gaPuzzle[$y1D][$x2D][$iaPossible]
    If Not IsArray($aTemp) Then
     ConsoleWrite ( "cancelled out all options in one cell." & @crlf )
     Return 2
    EndIf
    $iTempGuessCounter = 0
    $iGuessNumber = $aTemp[$iTempGuessCounter]
    $bGuessFound = True
    UpdateGuiWithKnownValue($y1D, $x2D, $iGuessNumber, True, $iRecurssionCounter)
    RemoveYRowPossibility($y1D, $iGuessNumber, True, $iRecurssionCounter)
    RemoveXColPossibility($x2D, $iGuessNumber, True, $iRecurssionCounter)
    ConsoleWrite("; Start with Number=[" & $iGuessNumber & "] x|y=[" & $x2D & "|" & $y1D & "]" & @CRLF)
    ; Need to remove the guess number from guess possible array
    Switch $y1D
     Case 0 To 2
      $iYStart = 0
     Case 3 To 5
      $iYStart = 3
     Case 6 To 8
      $iYStart = 6
    EndSwitch
    Switch $x2D
     Case 0 To 2
      $iXStart = 0
     Case 3 To 5
      $iXStart = 3
     Case 6 To 8
      $iXStart = 6
    EndSwitch
    For $iY = $iYStart To $iYStart + 2
     For $iX = $iXStart To $iXStart + 2
      $aTemp2 = $gaPuzzle[$iY][$iX][$iaGuessPossible]
      $iDeleteValue = _ArraySearch($aTemp2, $iGuessNumber)
      If $iDeleteValue >= 0 Then _ArrayDelete($aTemp2, $iDeleteValue)
      $gaPuzzle[$iY][$iX][$iaGuessPossible] = $aTemp2
     Next
    Next
   EndIf
   If $bGuessFound Then ExitLoop
  Next
  If $bGuessFound Then ExitLoop
 Next
 If Not $bGuessFound Then
  ConsoleWrite ( "All Single attempt guesses tried, and failed" & @CRLF)
  Return 2
 Else
  ; remove the current guess from parents possible
  ; remove the current guess from avail prior...
  $aTemp3 = $gaPuzzle[$y1D][$x2D][$iaPossible]
  $iDeleteValue2 = _ArraySearch($aTemp3, $iGuessNumber)
  If $iDeleteValue2 >= 0 Then _ArrayDelete($aTemp3, $iDeleteValue2)
  $gaPuzzle[$y1D][$x2D][$iaPossible] = $aTemp3
 EndIf
 ; Perform same loops to check for guess fits
 While True
  $msg = GUIGetMsg()
  While FillInEasyAndRemoveKnown(True, $iRecurssionCounter)
  WEnd
  ; Check if number is only available in a section once...that is by default, correct
  If FillInWhenOnlyOneCellInSectionHasPossibleNumber(True, $iRecurssionCounter) Then ContinueLoop
  If FillInWhenOnlyOneCellInColHasPossibleNumberX(True, $iRecurssionCounter) Then ContinueLoop
  If FillInWhenOnlyOneCellInRowHasPossibleNumberY(True, $iRecurssionCounter) Then ContinueLoop
;~   ; Currently only doing one guess at a time, or resetting
;~   ; Last resort...guess, and attempt to fill all in based on the guess
;~   ; Guess fills in known values to KnownGuess, and checks if all are filled to return true
  If CheckIfWon(True,$iRecurssionCounter) Then
   Return 1
  Else
   Return 0
  EndIf
  If $msg = $GUI_EVENT_CLOSE Then Exit
 WEnd
EndFunc   ;==>Guess
Func CheckIfWon($bGuess = False, $iRecurssionCounter = 0)
 $bReturn_CheckIfWon = True
 If Not $bGuess Then
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_Known
   $iaPossible = $giPuzzle_3D_aPossible
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 Else
  If $iRecurssionCounter = 0 Then
   $iKnown = $giPuzzle_3D_KnownGuess
   $iaPossible = $giPuzzle_3D_aGuessPossible
  ElseIf $iRecurssionCounter = 1 Then
   $iKnown = $giPuzzle_3D_KnownGuess2
   $iaPossible = $giPuzzle_3D_aGuessPossible2
  ElseIf $iRecurssionCounter = 2 Then
   $iKnown = $giPuzzle_3D_KnownGuess3
   $iaPossible = $giPuzzle_3D_aGuessPossible3
  ElseIf $iRecurssionCounter = 3 Then
   $iKnown = $giPuzzle_3D_KnownGuess4
   $iaPossible = $giPuzzle_3D_aGuessPossible4
  ElseIf $iRecurssionCounter = 4 Then
   $iKnown = $giPuzzle_3D_KnownGuess5
   $iaPossible = $giPuzzle_3D_aGuessPossible5
  ElseIf $iRecurssionCounter = 5 Then
   $iKnown = $giPuzzle_3D_KnownGuess6
   $iaPossible = $giPuzzle_3D_aGuessPossible6
  ElseIf $iRecurssionCounter = 6 Then
   $iKnown = $giPuzzle_3D_KnownGuess7
   $iaPossible = $giPuzzle_3D_aGuessPossible7
  ElseIf $iRecurssionCounter = 7 Then
   $iKnown = $giPuzzle_3D_KnownGuess8
   $iaPossible = $giPuzzle_3D_aGuessPossible8
  ElseIf $iRecurssionCounter = 8 Then
   $iKnown = $giPuzzle_3D_KnownGuess9
   $iaPossible = $giPuzzle_3D_aGuessPossible9
  ElseIf $iRecurssionCounter = 9 Then
   $iKnown = $giPuzzle_3D_KnownGuess10
   $iaPossible = $giPuzzle_3D_aGuessPossible10
  Else
   MsgBox (1,1,@ScriptLineNumber)
  EndIf
 EndIf
 For $y1D = 0 To $giPuzzle_Y1D_UBound - 1
  For $x2D = 0 To $giPuzzle_X2D_UBound - 1
   If StringLen($gaPuzzle[$y1D][$x2D][$iKnown]) = 0 Then
    $bReturn_CheckIfWon = False
    Return $bReturn_CheckIfWon
   EndIf
  Next
 Next
 Return $bReturn_CheckIfWon
EndFunc   ;==>CheckIfWon
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Just adding a sudoku solving technique page. (good one I think)

http://www.sadmansoftware.com/sudoku/solvingtechniques.htm

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...