I was messing with dialogs and decided to make this script. I've seen it before, but never done with dialogs. It seems to work smoothly and correctly as far as I can tell. It's a little hard to navigate because mIRC's dialogs really aren't designed for something like this.
The dialog runs left to right, top to bottom. So if you tab through it, it will move one box at a time left to right till it reaches the end and then it will drop to the far left of the next line.
Shift+tab will take you back one box.
Double clicking a box will put the box in edit/overwrite mode.
Check will display the number of errors, number of moves made and the percent complete. If you have completed the puzzle it will display Winner!! and the number of Moves it took.
Reset will start a new puzzle with the selected skill level.
Solve will fill in all the boxes with the correct numbers.
Easy, Medium, Hard and Evil are skill level settings. Medium is default.
;Sudoku Script by Ford_Lawnmower #Emule-USA Irc.mindforge.org
dialog Sudoku {
title "Sudoku"
size -1 -1 74 120
option dbu
edit "", 1, 0 0 8 8, limit 1 center
edit "", 2, 8 0 8 8, limit 1 center
edit "", 3, 16 0 8 8, limit 1 center
edit "", 4, 25 0 8 8, limit 1 center
edit "", 5, 33 0 8 8, limit 1 center
edit "", 6, 41 0 8 8, limit 1 center
edit "", 7, 50 0 8 8, limit 1 center
edit "", 8, 58 0 8 8, limit 1 center
edit "", 9, 66 0 8 8, limit 1 center
edit "", 10, 0 8 8 8, limit 1 center
edit "", 11, 8 8 8 8, limit 1 center
edit "", 12, 16 8 8 8, limit 1 center
edit "", 13, 25 8 8 8, limit 1 center
edit "", 14, 33 8 8 8, limit 1 center
edit "", 15, 41 8 8 8, limit 1 center
edit "", 16, 50 8 8 8, limit 1 center
edit "", 17, 58 8 8 8, limit 1 center
edit "", 18, 66 8 8 8, limit 1 center
edit "", 19, 0 16 8 8, limit 1 center
edit "", 20, 8 16 8 8, limit 1 center
edit "", 21, 16 16 8 8, limit 1 center
edit "", 22, 25 16 8 8, limit 1 center
edit "", 23, 33 16 8 8, limit 1 center
edit "", 24, 41 16 8 8, limit 1 center
edit "", 25, 50 16 8 8, limit 1 center
edit "", 26, 58 16 8 8, limit 1 center
edit "", 27, 66 16 8 8, limit 1 center
edit "", 28, 0 25 8 8, limit 1 center
edit "", 29, 8 25 8 8, limit 1 center
edit "", 30, 16 25 8 8, limit 1 center
edit "", 31, 25 25 8 8, limit 1 center
edit "", 32, 33 25 8 8, limit 1 center
edit "", 33, 41 25 8 8, limit 1 center
edit "", 34, 50 25 8 8, limit 1 center
edit "", 35, 58 25 8 8, limit 1 center
edit "", 36, 66 25 8 8, limit 1 center
edit "", 37, 0 33 8 8, limit 1 center
edit "", 38, 8 33 8 8, limit 1 center
edit "", 39, 16 33 8 8, limit 1 center
edit "", 40, 25 33 8 8, limit 1 center
edit "", 41, 33 33 8 8, limit 1 center
edit "", 42, 41 33 8 8, limit 1 center
edit "", 43, 50 33 8 8, limit 1 center
edit "", 44, 58 33 8 8, limit 1 center
edit "", 45, 66 33 8 8, limit 1 center
edit "", 46, 0 41 8 8, limit 1 center
edit "", 47, 8 41 8 8, limit 1 center
edit "", 48, 16 41 8 8, limit 1 center
edit "", 49, 25 41 8 8, limit 1 center
edit "", 50, 33 41 8 8, limit 1 center
edit "", 51, 41 41 8 8, limit 1 center
edit "", 52, 50 41 8 8, limit 1 center
edit "", 53, 58 41 8 8, limit 1 center
edit "", 54, 66 41 8 8, limit 1 center
edit "", 55, 0 50 8 8, limit 1 center
edit "", 56, 8 50 8 8, limit 1 center
edit "", 57, 16 50 8 8, limit 1 center
edit "", 58, 25 50 8 8, limit 1 center
edit "", 59, 33 50 8 8, limit 1 center
edit "", 60, 41 50 8 8, limit 1 center
edit "", 61, 50 50 8 8, limit 1 center
edit "", 62, 58 50 8 8, limit 1 center
edit "", 63, 66 50 8 8, limit 1 center
edit "", 64, 0 58 8 8, limit 1 center
edit "", 65, 8 58 8 8, limit 1 center
edit "", 66, 16 58 8 8, limit 1 center
edit "", 67, 25 58 8 8, limit 1 center
edit "", 68, 33 58 8 8, limit 1 center
edit "", 69, 41 58 8 8, limit 1 center
edit "", 70, 50 58 8 8, limit 1 center
edit "", 71, 58 58 8 8, limit 1 center
edit "", 72, 66 58 8 8, limit 1 center
edit "", 73, 0 66 8 8, limit 1 center
edit "", 74, 8 66 8 8, limit 1 center
edit "", 75, 16 66 8 8, limit 1 center
edit "", 76, 25 66 8 8, limit 1 center
edit "", 77, 33 66 8 8, limit 1 center
edit "", 78, 41 66 8 8, limit 1 center
edit "", 79, 50 66 8 8, limit 1 center
edit "", 80, 58 66 8 8, limit 1 center
edit "", 81, 66 66 8 8, limit 1 center
button "Check", 82, 2 75 21 12
button "Solve", 83, 51 75 21 12
text "", 84, 0 88 73 8, center
radio "Easy", 85, 4 96 26 10
radio "Medium", 86, 42 96 34 10
radio "Hard", 87, 4 106 26 10
radio "Evil", 88, 42 106 26 10
button "Reset", 89, 27 75 21 12
icon 90, 0 0 74 74
}
On *:Dialog:Sudoku:Close:*: {
unset %Sudoku.*
}
On *:Dialog:Sudoku:Sclick:82: {
var %Errors $calc($Sudoku.CkRows + $Sudoku.Ck.Cols + $Sudoku.CkBlocks)
if (!%Errors) && ($Sudoku.Done == 100) { did -a Sudoku 84 Winner!!! in %Sudoku.moves Moves }
else {
did -a Sudoku 84 %Errors Errors in %Sudoku.moves Moves - $Sudoku.Done $+ % Done
.timer 1 5 did -a Sudoku 84
}
}
On *:Dialog:Sudoku:Sclick:83: {
Sudoku.Solve
}
On *:Dialog:Sudoku:Sclick:89: {
set %Sudoku.Moves 0
getcheat %Sudoku.level
}
On *:Dialog:Sudoku:Sclick:85-88: {
if ($did(Sudoku,85).state) { set %Sudoku.level 35 | Set %Sudoku.skill 1 }
if ($did(Sudoku,86).state) { set %Sudoku.level 32 | Set %Sudoku.skill 2 }
if ($did(Sudoku,87).state) { set %Sudoku.level 30 | Set %Sudoku.skill 3 }
if ($did(Sudoku,88).state) { set %Sudoku.level 27 | Set %Sudoku.skill 4 }
}
On *:Dialog:Sudoku:init:*: {
did -g Sudoku 90 $qt($+($mircdir,ColorIcon\,Red150-150.bmp))
did -c Sudoku 86
if (!%Sudoku.level) { set %Sudoku.level 32 | Set %Sudoku.skill 2 }
set %Sudoku.Moves 0
getcheat
}
On *:Dialog:Sudoku:Edit:1-81: {
if ($did(Sudoku,$did).text !isnum) || ($did(Sudoku,$did).text == 0) { did -rf Sudoku $did }
else { set %Sudoku.Moves $calc(%Sudoku.Moves + 1) }
}
alias -l Sudoku {
if (!$isfile($+(ColorIcon\,Red150-150.bmp))) {
var %c 4
if (!$isdir($+($mircdir,ColorIcon))) { mkdir ColorIcon }
if (!$window(@MakeColorIcons)) { window -hBpf +d @MakeColorIcons -1 -1 150 150 }
drawfill @MakeColorIcons %c %c 0 0 150 150
drawsave @MakeColorIcons $qt($+($mircdir,ColorIcon\,Red150-150.bmp))
window -c @MakeColorIcons
}
dialog $iif($dialog(Sudoku),-v,-md) Sudoku Sudoku
}
alias -l Sudoku.Done {
var %count = 1, %counter = 0
while (%count <= 81) {
if ($did(Sudoku,%count).text) { inc %counter }
inc %count
}
return $round($calc(%counter / 81 * 100),2)
}
alias -l Sudoku.Solve {
var %count = 1
Sudoku.Clear
while (%count <= 81) {
did -am Sudoku %count $mid(%Sudoku.Cheat,%count,1)
inc %count
}
}
alias -l Sudoku.Clear {
var %count = 1
while (%count <= 81) {
did -rn Sudoku %count
inc %count
}
}
alias -l getcheat {
sockclose getcheat
sockopen getcheat view.websudoku.com 80
}
on *:sockopen:getcheat: {
sockwrite -n $sockname GET /?level= $+ %Sudoku.skill HTTP/1.1
sockwrite -n $sockname Host: view.websudoku.com $+ $CRLF $+ $CRLF
}
on *:sockread:getcheat: {
if ($sockerr > 0) { echo -at >sock error< getcheat | sockclose getcheat }
else {
var %getcheatvar | sockread %getcheatvar
if (var cheat=' isin %getcheatvar) {
set %Sudoku.Cheat $remove(%getcheatvar,var cheat=',';,$chr(32),$chr(9),$chr(11))
Sudoku.init %Sudoku.Cheat %Sudoku.Level
sockclose getcheat
halt
}
}
}
alias -l Sudoku.init {
var %cheat $1, %count 1, %rand, %level $2
Sudoku.Clear
while (%count <= %level) {
%rand = $rand(1,81)
if (!$did(Sudoku,%rand).text) { did -am Sudoku %rand $mid(%cheat,%rand,1) }
inc %count
}
}
alias -l Sudoku.CkBlocks {
if ($dialog(Sudoku)) {
var %counter = 1, %count = 1, %result = 0
while (%counter <= 79) {
while (%counter <= $calc(%count + 6)) {
%result = $calc(%result + $Sudoku.CkBlock(%counter))
inc %counter 3
}
inc %counter 18
%count = %counter
}
return %result
}
else { return 100 }
}
alias -l Sudoku.CkBlock {
if ($dialog(Sudoku)) {
var %start = $1, %count = %start, %counter = 1, %mark = %start
while (%count <= $calc(%start + 20)) {
while (%count <= $calc(%mark + 2)) {
if ($did(Sudoku,%count).text) { hadd -m Sblock %counter $did(Sudoku,%count).text }
inc %count
inc %counter
}
inc %count 6
%mark = %count
}
%count = 1
%mark = 0
while (%count <= 9) {
%counter = 1
while (%counter <= 9) {
if ($hget(Sblock,%count) && $hget(Sblock,%count) == $hget(Sblock,%counter)) && (%count != %counter) {
%mark = $calc(%mark + 1)
}
inc %counter
}
inc %count
}
if ($hget(Sblock)) { hfree Sblock }
return $calc(%mark / 2)
}
else { return 100 }
}
alias -l Sudoku.CkCols {
if ($dialog(Sudoku)) {
var %count = 1, %result
while (%count <= 9) {
%result = $calc(%result + $Sudoku.CkCol(%count))
inc %count
}
return %result
}
else { return 100 }
}
alias -l Sudoku.CkCol {
if ($dialog(Sudoku)) {
var %start = $1, %row1 = %start, %return 0
while (%row1 <= $calc(%start + 72)) {
var %row2 %start
while (%row2 <= $calc(%start + 72)) {
if (%row1 != %row2) && ($did(Sudoku,%row1).text == $did(Sudoku,%row2).text) && $did(Sudoku,%row1).text {
inc %return
}
inc %row2 9
}
inc %row1 9
}
return $calc(%return / 2)
}
else { return 100 }
}
alias -l Sudoku.CkRows {
if ($dialog(Sudoku)) {
var %count = 1, %result = 0
while (%count <= 73) {
%result = $calc(%result + $Sudoku.CkRow(%count))
inc %count 9
}
return %result
}
else { return 100 }
}
alias -l Sudoku.CkRow {
if ($dialog(Sudoku)) {
var %start = $1, %column1 = %start, %return 0
while (%column1 <= $calc(%start + 8)) {
var %column2 = %start
while (%column2 <= $calc(%start + 8)) {
if (%column1 != %column2) && ($did(Sudoku,%column1).text == $did(Sudoku,%column2).text) && $did(Sudoku,%column1).text {
inc %return
}
inc %column2
}
inc %column1
}
return $calc(%return / 2)
}
else { return 100 }
}
alias -l Sudoku.Count {
if ($dialog(Sudoku)) {
var %Count = 0, %Counter = 1
while (%Counter <= 81) {
if ($did(Sudoku,%Counter).text) { inc %Count }
inc %Counter
}
return %Count
}
else { return 0 }
}
menu * {
Sudoku:Sudoku
}