#SingleInstance force #NoTrayIcon #NoEnv ; Rounds= 8 ;Enter the number of guesses per game. ;_____________________________________________________ Colors = FF0000|FFFF00|FF8C00|008000|0000FF|8B4513 Gui, Add, GroupBox, w240, Color Picker Gui, Font, s20, WebDings Loop,4 Random, Code%A_Index%, 1,6 Loop, Parse, Colors, | { num := A_Index clr := A_LoopField Loop,4 If Code%A_Index% = %num% { Code%A_Index% := clr Code%clr%++ } Gui, Add, Text , c%A_LoopField% v%A_LoopField% gPick xp+30 ym+20, g } Loop,4 { pos := A_Index=1 ? 70:"p+23" Gui, Font, cBlack, WebDings Gui, Add, Text, vCode%A_Index% x%pos%, g Gui, Font, cWhite, Times New Roman Gui, Add, Text, xp+7 BackgroundTrans, ? } Gui, Font, cDefault, WebDings Loop,%Rounds% { Row := A_Index Loop,4 { pos := A_Index=1 ? 10:"+0" Gui, Add, Checkbox , check3 vChk%Row%_%A_Index% gChkBox x%pos% w20 h20 } Loop,4 { pos := A_Index=1 ? "+20":"+10" Gui, Add, Text, vBox%Row%_%A_Index% gClick x%pos%, g } } Gui, Font Gui, Add, Button, vButton gSubmit x90, Submit Guess Gui, Show,,MasterMind return GuiClose: ExitApp Pick: Loop, Parse, Colors, | { If A_LoopField = %A_GuiControl% GuiControl,,%A_GuiControl%, n Else GuiControl,,%A_LoopField%, g } Color := A_GuiControl return Click: StringMid, BoxNum, A_GuiControl, 4,% StrLen(Rounds) If BoxNum != %Rounds% return Gui, Font, c%Color% s20, WebDings GuiControl, Font, %A_GuiControl% StringRight, num, A_GuiControl, 1 Guess%num% := Color return ChkBox: GuiControl,,%A_GuiControl%, 0 return Submit: Loop,4 If !Guess%A_Index% { Gui, +OwnDialogs MsgBox,48, MasterMind, Please fill in all 4 boxes. return } Loop, Parse, Colors, | %A_LoopField%=0 clr=0 pos=0 Loop,4 { Guess := Guess%A_Index% If (Code%A_Index% = Guess) { %Guess%++ clr++ } Else Loop,4 If (Code%A_Index% = Guess) AND (Code%A_Index% != Guess%A_Index%) AND (Code%Guess% > %Guess%) { %Guess%++ pos++ break } } If clr Loop,%clr% GuiControl,,Chk%Rounds%_%A_Index%,1 If pos Loop,%pos% { num := A_Index + clr GuiControl,,Chk%Rounds%_%num%,-1 } Loop,4 GuiControl, Disable, Chk%Rounds%_%A_Index% Rounds-- If (clr = 4) OR !(Rounds) { If clr = 4 msg = You Win! Else msg = You Lose. Gui, +OwnDialogs MsgBox,64, MasterMind, Game Over.`n%msg% Loop,4 { Gui, Font,% "c" Code%A_Index% GuiControl, Font, Code%A_Index% } GuiControl,,Button, New Game GuiControl, +gNewGame, Button return } Loop,4 Guess%A_Index%= return NewGame: If A_IsCompiled Run, %A_ScriptFullPath% Else Run, %A_AhkPath% "%A_ScriptFullPath%" return