Sign in to follow this  
Followers 0
dandymcgee

Player vs. Computer Tic-Tac-Toe

6 posts in this topic

#1 ·  Posted (edited)

Hey all, I searched the forums and only found one other Tic-Tac-Toe game, with buttons whos text changed when they were clicked on. I made this Tic-Tac-Toe game (before I had realized somebody else had already done it before), so I thought I might as well share it with everyone. Every once in a while the computer just... doesn't go, and it kinda gets stuck in an infinate loop somewhere, although I haven't figured out exactly why yet :unsure: . Anyways here it is:

#include <GUIConstants.au3>
GUICreate("Tic-Tac-Toe", 358, 302)
$x1 = GUICtrlCreatePic(@ScriptDir & "\tic1.jpg", 96, 64, 43, 41)
$y1 = GUICtrlCreatePic(@ScriptDir & "\tic2.jpg", 96, 64, 43, 41)
$x2 = GUICtrlCreatePic(@ScriptDir & "\tic1.jpg", 160, 64, 43, 41)
$y2 = GUICtrlCreatePic(@ScriptDir & "\tic2.jpg", 160, 64, 43, 41)
$x3 = GUICtrlCreatePic(@ScriptDir & "\tic1.jpg", 224, 64, 43, 41)
$y3 = GUICtrlCreatePic(@ScriptDir & "\tic2.jpg", 224, 64, 43, 41)
$x4 = GUICtrlCreatePic(@ScriptDir & "\tic1.jpg", 96, 128, 43, 41)
$y4 = GUICtrlCreatePic(@ScriptDir & "\tic2.jpg", 96, 128, 43, 41)
$x5 = GUICtrlCreatePic(@ScriptDir & "\tic1.jpg", 160, 128, 43, 41)
$y5 = GUICtrlCreatePic(@ScriptDir & "\tic2.jpg", 160, 128, 43, 41)
$x6 = GUICtrlCreatePic(@ScriptDir & "\tic1.jpg", 224, 128, 43, 41)
$y6 = GUICtrlCreatePic(@ScriptDir & "\tic2.jpg", 224, 128, 43, 41)
$x7 = GUICtrlCreatePic(@ScriptDir & "\tic1.jpg", 96, 192, 43, 41)
$y7 = GUICtrlCreatePic(@ScriptDir & "\tic2.jpg", 96, 192, 43, 41)
$x8 = GUICtrlCreatePic(@ScriptDir & "\tic1.jpg", 160, 192, 43, 41)
$y8 = GUICtrlCreatePic(@ScriptDir & "\tic2.jpg", 160, 192, 43, 41)
$x9 = GUICtrlCreatePic(@ScriptDir & "\tic1.jpg", 224, 192, 43, 41)
$y9 = GUICtrlCreatePic(@ScriptDir & "\tic2.jpg", 224, 192, 43, 41)
$Square1 = GUICtrlCreateLabel("", 96, 64, 43, 41)
$Square2 = GUICtrlCreateLabel("", 160, 64, 43, 41)
$Square3 = GUICtrlCreateLabel("", 224, 64, 43, 41)
$Square4 = GUICtrlCreateLabel("", 96, 128, 43, 41)
$Square5 = GUICtrlCreateLabel("", 160, 128, 43, 41)
$Square6 = GUICtrlCreateLabel("", 224, 128, 43, 41)
$Square7 = GUICtrlCreateLabel("", 96, 192, 43, 41)
$Square8 = GUICtrlCreateLabel("", 160, 192, 43, 41)
$Square9 = GUICtrlCreateLabel("", 224, 192, 43, 41)
$Status = GUICtrlCreateLabel("Simply click somewhere on the grid to begin.", 85, 35)
$Reset = GUICtrlCreateButton("RESET", 135, 260, 80, 20)
GUICtrlCreateLabel("________________________________________________________________________", 96, 106, 171, 15)
GUICtrlCreateLabel("________________________________________________________________________", 96, 170, 171, 15)
GUICtrlCreateLabel("|", 148, 64, 3, 10)
GUICtrlCreateLabel("|", 148, 74, 3, 10)
GUICtrlCreateLabel("|", 148, 84, 3, 10)
GUICtrlCreateLabel("|", 148, 94, 3, 10)
GUICtrlCreateLabel("|", 148, 104, 3, 10)
GUICtrlCreateLabel("|", 148, 114, 3, 10)
GUICtrlCreateLabel("|", 148, 124, 3, 10)
GUICtrlCreateLabel("|", 148, 134, 3, 10)
GUICtrlCreateLabel("|", 148, 144, 3, 10)
GUICtrlCreateLabel("|", 148, 154, 3, 10)
GUICtrlCreateLabel("|", 148, 164, 3, 10)
GUICtrlCreateLabel("|", 148, 174, 3, 10)
GUICtrlCreateLabel("|", 148, 184, 3, 10)
GUICtrlCreateLabel("|", 148, 194, 3, 10)
GUICtrlCreateLabel("|", 148, 204, 3, 10)
GUICtrlCreateLabel("|", 148, 214, 3, 10)
GUICtrlCreateLabel("|", 148, 224, 3, 10)
;=======================================
GUICtrlCreateLabel("|", 211, 64, 3, 10)
GUICtrlCreateLabel("|", 211, 74, 3, 10)
GUICtrlCreateLabel("|", 211, 84, 3, 10)
GUICtrlCreateLabel("|", 211, 94, 3, 10)
GUICtrlCreateLabel("|", 211, 104, 3, 10)
GUICtrlCreateLabel("|", 211, 114, 3, 10)
GUICtrlCreateLabel("|", 211, 124, 3, 10)
GUICtrlCreateLabel("|", 211, 134, 3, 10)
GUICtrlCreateLabel("|", 211, 144, 3, 10)
GUICtrlCreateLabel("|", 211, 154, 3, 10)
GUICtrlCreateLabel("|", 211, 164, 3, 10)
GUICtrlCreateLabel("|", 211, 174, 3, 10)
GUICtrlCreateLabel("|", 211, 184, 3, 10)
GUICtrlCreateLabel("|", 211, 194, 3, 10)
GUICtrlCreateLabel("|", 211, 204, 3, 10)
GUICtrlCreateLabel("|", 211, 214, 3, 10)
GUICtrlCreateLabel("|", 211, 224, 3, 10)
GUICtrlSetState(3, $GUI_HIDE)
GUICtrlSetState(4, $GUI_HIDE)
GUICtrlSetState(5, $GUI_HIDE)
GUICtrlSetState(6, $GUI_HIDE)
GUICtrlSetState(7, $GUI_HIDE)
GUICtrlSetState(8, $GUI_HIDE)
GUICtrlSetState(9, $GUI_HIDE)
GUICtrlSetState(10, $GUI_HIDE)
GUICtrlSetState(11, $GUI_HIDE)
GUICtrlSetState(12, $GUI_HIDE)
GUICtrlSetState(13, $GUI_HIDE)
GUICtrlSetState(14, $GUI_HIDE)
GUICtrlSetState(15, $GUI_HIDE)
GUICtrlSetState(16, $GUI_HIDE)
GUICtrlSetState(17, $GUI_HIDE)
GUICtrlSetState(18, $GUI_HIDE)
GUICtrlSetState(19, $GUI_HIDE)
GUICtrlSetState(20, $GUI_HIDE)
GUICtrlSetBkColor(21, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor(22, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor(23, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor(24, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor(25, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor(26, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor(27, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor(28, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor(29, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel("Dandymcgee", 264, 272, 67, 17)
$side = 0
$win = 0
$ReRoll = 0
$Strategy_Move = 0
$pressed1 = 0
$pressed2 = 0
$pressed3 = 0
$pressed4 = 0
$pressed5 = 0
$pressed6 = 0
$pressed7 = 0
$pressed8 = 0
$pressed9 = 0

$select_side = MsgBox(4, "Select Your Side", "Would you like to be X? (If no is clicked you will be O)")
If $select_side = 6 Then
    $side = 0
ElseIf $select_side = 7 Then
    $side = 1
EndIf

GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $Reset
            Restart()
        Case $msg = $Square1
            If $pressed1 = 0 Then
                If $side = 0 Then
                    GUICtrlSetState(3, $GUI_SHOW)
                Else
                    GUICtrlSetState(4, $GUI_SHOW)
                EndIf
                $pressed1 = 1
                Check_Winner()
                If $win = 0 Then
                    Do
                        Computer_Turn()
                    Until $ReRoll = 0
                EndIf
            EndIf
        Case $msg = $Square2
            If $pressed2 = 0 Then
                If $side = 0 Then
                    GUICtrlSetState(5, $GUI_SHOW)
                Else
                    GUICtrlSetState(6, $GUI_SHOW)
                EndIf
                $pressed2 = 1
                Check_Winner()
                If $win = 0 Then
                    Do
                        Computer_Turn()
                    Until $ReRoll = 0
                EndIf
            EndIf
        Case $msg = $Square3
            If $pressed3 = 0 Then
                If $side = 0 Then
                    GUICtrlSetState(7, $GUI_SHOW)
                Else
                    GUICtrlSetState(8, $GUI_SHOW)
                EndIf
                $pressed3 = 1
                Check_Winner()
                If $win = 0 Then
                    Do
                        Computer_Turn()
                    Until $ReRoll = 0
                EndIf
            EndIf
        Case $msg = $Square4
            If $pressed4 = 0 Then
                If $side = 0 Then
                    GUICtrlSetState(9, $GUI_SHOW)
                Else
                    GUICtrlSetState(10, $GUI_SHOW)
                EndIf
                $pressed4 = 1
                Check_Winner()
                If $win = 0 Then
                    Do
                        Computer_Turn()
                    Until $ReRoll = 0
                EndIf
            EndIf
        Case $msg = $Square5
            If $pressed5 = 0 Then
                If $side = 0 Then
                    GUICtrlSetState(11, $GUI_SHOW)
                Else
                    GUICtrlSetState(12, $GUI_SHOW)
                EndIf
                $pressed5 = 1
                Check_Winner()
                If $win = 0 Then
                    Do
                        Computer_Turn()
                    Until $ReRoll = 0
                EndIf
            EndIf
        Case $msg = $Square6
            If $pressed6 = 0 Then
                If $side = 0 Then
                    GUICtrlSetState(13, $GUI_SHOW)
                Else
                    GUICtrlSetState(14, $GUI_SHOW)
                EndIf
                $pressed6 = 1
                Check_Winner()
                If $win = 0 Then
                    Do
                        Computer_Turn()
                    Until $ReRoll = 0
                EndIf
            EndIf
        Case $msg = $Square7
            If $pressed7 = 0 Then
                If $side = 0 Then
                    GUICtrlSetState(15, $GUI_SHOW)
                Else
                    GUICtrlSetState(16, $GUI_SHOW)
                EndIf
                $pressed7 = 1
                Check_Winner()
                If $win = 0 Then
                    Do
                        Computer_Turn()
                    Until $ReRoll = 0
                EndIf
            EndIf
        Case $msg = $Square8
            If $pressed8 = 0 Then
                If $side = 0 Then
                    GUICtrlSetState(17, $GUI_SHOW)
                Else
                    GUICtrlSetState(18, $GUI_SHOW)
                EndIf
                $pressed8 = 1
                Check_Winner()
                If $win = 0 Then
                    Do
                        Computer_Turn()
                    Until $ReRoll = 0
                EndIf
            EndIf
        Case $msg = $Square9
            If $pressed9 = 0 Then
                If $side = 0 Then
                    GUICtrlSetState(19, $GUI_SHOW)
                Else
                    GUICtrlSetState(20, $GUI_SHOW)
                EndIf
                $pressed9 = 1
                Check_Winner()
                If $win = 0 Then
                    Do
                        Computer_Turn()
                    Until $ReRoll = 0
                EndIf
            EndIf
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Func Computer_Turn()
    GUICtrlSetData($Status, "Can you beat me?")
    If $pressed1 = 0 Or $pressed2 = 0 Or $pressed3 = 0 Or $pressed4 = 0 Or  $pressed5 = 0 Or  $pressed6 = 0 Or  $pressed7 = 0 Or  $pressed8 = 0 Or  $pressed9 = 0 Then
        Select
            Case $pressed1 = 2 And $pressed4 = 2
                If $pressed7 = 0 Then
                    Global $Computer_Choice = 7
                    $Strategy_Move = 1
                EndIf
            Case $pressed2 = 2 And $pressed5 = 2
                If $pressed8 = 0 Then
                    Global $Computer_Choice = 8
                    $Strategy_Move = 1
                EndIf
            Case $pressed3 = 2 And $pressed6 = 2
                If $pressed9 = 0 Then   
                    Global $Computer_Choice = 9
                    $Strategy_Move = 1
                EndIf
            Case $pressed2 = 2 And $pressed3 = 2
                If $pressed1 = 0 Then   
                    Global $Computer_Choice = 1
                    $Strategy_Move = 1
                EndIf
            Case $pressed4 = 2 And $pressed6 = 2
                If $pressed7 = 0 Then   
                    Global $Computer_Choice = 4
                    $Strategy_Move = 1
                EndIf
            Case $pressed7 = 2 And $pressed9 = 2
                If $pressed7 = 0 Then   
                    Global $Computer_Choice = 7
                    $Strategy_Move = 1
                EndIf
            Case $pressed4 = 2 And $pressed7 = 2
                If $pressed1 = 0 Then   
                    Global $Computer_Choice = 1
                    $Strategy_Move = 1
                EndIf
            Case $pressed5 = 2 And $pressed8 = 2
                If $pressed2 = 0 Then   
                    Global $Computer_Choice = 2
                    $Strategy_Move = 1
                EndIf
            Case $pressed6 = 2 And $pressed9 = 2
                If $pressed3 = 0 Then   
                    Global $Computer_Choice = 3
                    $Strategy_Move = 1
                EndIf
            Case $pressed1 = 2 And $pressed2 = 2
                If $pressed3 = 0 Then   
                    Global $Computer_Choice = 3
                    $Strategy_Move = 1
                EndIf
            Case $pressed6 = 2 And $pressed5 = 2
                If $pressed7 = 0 Then   
                    Global $Computer_Choice = 6
                    $Strategy_Move = 1
                EndIf
            Case $pressed9 = 2 And $pressed8 = 2
                If $pressed7 = 0 Then   
                    Global $Computer_Choice = 9
                    $Strategy_Move = 1
                EndIf
            Case $pressed1 = 2 And $pressed5 = 2
                If $pressed9 = 0 Then   
                    Global $Computer_Choice = 9
                    $Strategy_Move = 1
                EndIf
            Case $pressed3 = 2 And $pressed5 = 2
                If $pressed7 = 0 Then   
                    Global $Computer_Choice = 7
                    $Strategy_Move = 1
                EndIf
            Case $pressed7 = 2 And $pressed5 = 2
                If $pressed3 = 0 Then   
                    Global $Computer_Choice = 3
                    $Strategy_Move = 1
                EndIf
            Case $pressed9 = 2 And $pressed5 = 2
                If $pressed3 = 0 Then   
                    Global $Computer_Choice = 3
                    $Strategy_Move = 1
                EndIf
            Case $pressed1 = 2 And $pressed3 = 2
                If $pressed2 = 0 Then   
                    Global $Computer_Choice = 2
                    $Strategy_Move = 1
                EndIf
            Case $pressed4 = 2 And $pressed6 = 2
                If $pressed5 = 0 Then   
                    Global $Computer_Choice = 5
                    $Strategy_Move = 1
                EndIf
            Case $pressed7 = 2 And $pressed9 = 2
                If $pressed8 = 0 Then   
                    Global $Computer_Choice = 8
                    $Strategy_Move = 1
                EndIf
            Case $pressed1 = 2 And $pressed7 = 2
                If $pressed4 = 0 Then   
                    Global $Computer_Choice = 4
                    $Strategy_Move = 1
                EndIf
            Case $pressed2 = 2 And $pressed8 = 2
                If $pressed5 = 0 Then   
                    Global $Computer_Choice = 5
                    $Strategy_Move = 1
                EndIf
            Case $pressed3 = 2 And $pressed9 = 2
                If $pressed3 = 6 Then   
                    Global $Computer_Choice = 6
                    $Strategy_Move = 1
                EndIf
        ;;=====================================================================================
            Case $pressed1 = 1 And $pressed4 = 1
                If $pressed7 = 0 Then
                    Global $Computer_Choice = 7
                    $Strategy_Move = 1
                EndIf
            Case $pressed2 = 1 And $pressed5 = 1
                If $pressed8 = 0 Then
                    Global $Computer_Choice = 8
                    $Strategy_Move = 1
                EndIf
            Case $pressed3 = 1 And $pressed6 = 1
                If $pressed9 = 0 Then   
                    Global $Computer_Choice = 9
                    $Strategy_Move = 1
                EndIf
            Case $pressed2 = 1 And $pressed3 = 1
                If $pressed1 = 0 Then   
                    Global $Computer_Choice = 1
                    $Strategy_Move = 1
                EndIf
            Case $pressed4 = 1 And $pressed6 = 1
                If $pressed7 = 0 Then   
                    Global $Computer_Choice = 4
                    $Strategy_Move = 1
                EndIf
            Case $pressed7 = 1 And $pressed9 = 1
                If $pressed7 = 0 Then   
                    Global $Computer_Choice = 7
                    $Strategy_Move = 1
                EndIf
            Case $pressed4 = 1 And $pressed7 = 1
                If $pressed1 = 0 Then   
                    Global $Computer_Choice = 1
                    $Strategy_Move = 1
                EndIf
            Case $pressed5 = 1 And $pressed8 = 1
                If $pressed2 = 0 Then   
                    Global $Computer_Choice = 2
                    $Strategy_Move = 1
                EndIf
            Case $pressed6 = 1 And $pressed9 = 1
                If $pressed3 = 0 Then   
                    Global $Computer_Choice = 3
                    $Strategy_Move = 1
                EndIf
            Case $pressed1 = 1 And $pressed2 = 1
                If $pressed3 = 0 Then   
                    Global $Computer_Choice = 3
                    $Strategy_Move = 1
                EndIf
            Case $pressed6 = 1 And $pressed5 = 1
                If $pressed7 = 0 Then   
                    Global $Computer_Choice = 6
                    $Strategy_Move = 1
                EndIf
            Case $pressed9 = 1 And $pressed8 = 1
                If $pressed7 = 0 Then   
                    Global $Computer_Choice = 9
                    $Strategy_Move = 1
                EndIf
            Case $pressed1 = 1 And $pressed5 = 1
                If $pressed9 = 0 Then   
                    Global $Computer_Choice = 9
                    $Strategy_Move = 1
                EndIf
            Case $pressed3 = 1 And $pressed5 = 1
                If $pressed7 = 0 Then   
                    Global $Computer_Choice = 7
                    $Strategy_Move = 1
                EndIf
            Case $pressed7 = 1 And $pressed5 = 1
                If $pressed3 = 0 Then   
                    Global $Computer_Choice = 3
                    $Strategy_Move = 1
                EndIf
            Case $pressed9 = 1 And $pressed5 = 1
                If $pressed3 = 0 Then   
                    Global $Computer_Choice = 3
                    $Strategy_Move = 1
                EndIf
            Case $pressed1 = 1 And $pressed3 = 1
                If $pressed2 = 0 Then   
                    Global $Computer_Choice = 2
                    $Strategy_Move = 1
                EndIf
            Case $pressed4 = 1 And $pressed6 = 1
                If $pressed5 = 0 Then   
                    Global $Computer_Choice = 5
                    $Strategy_Move = 1
                EndIf
            Case $pressed7 = 1 And $pressed9 = 1
                If $pressed8 = 0 Then   
                    Global $Computer_Choice = 8
                    $Strategy_Move = 1
                EndIf
            Case $pressed1 = 1 And $pressed7 = 1
                If $pressed4 = 0 Then   
                    Global $Computer_Choice = 4
                    $Strategy_Move = 1
                EndIf
            Case $pressed2 = 1 And $pressed8 = 1
                If $pressed5 = 0 Then   
                    Global $Computer_Choice = 5
                    $Strategy_Move = 1
                EndIf
            Case $pressed3 = 1 And $pressed9 = 1
                If $pressed3 = 6 Then   
                    Global $Computer_Choice = 6
                    $Strategy_Move = 1
                EndIf
        EndSelect
        If $Strategy_Move = 0 Then
            Global $Computer_Choice = Random(1, 9, 1)
        EndIf
        Computer_Goes()
    Else
        Check_Winner()
        If $win = 0 Then
            GUICtrlSetData($Status, "It's a TIE!")
        EndIf
    EndIf
    $Strategy_Move = 0
    Check_Winner()
EndFunc
    
Func Computer_Goes()
    Select
        Case $Computer_Choice = 1
            If $pressed1 = 0 Then
                If $side = 1 Then
                    GUICtrlSetState(3, $GUI_SHOW)
                Else
                    GUICtrlSetState(4, $GUI_SHOW)
                EndIf
                $pressed1 = 2
                $ReRoll = 0
            Else
                $ReRoll = 1
            EndIf
        Case $Computer_Choice = 2
            If $pressed2 = 0 Then
                If $side = 1 Then
                    GUICtrlSetState(5, $GUI_SHOW)
                Else
                    GUICtrlSetState(6, $GUI_SHOW)
                EndIf
                $pressed2 = 2
                $ReRoll = 0
            Else
                $ReRoll = 1
            EndIf
        Case $Computer_Choice = 3
            If $pressed3 = 0 Then
                If $side = 1 Then
                    GUICtrlSetState(7, $GUI_SHOW)
                Else
                    GUICtrlSetState(8, $GUI_SHOW)
                EndIf
                $pressed3 = 2
                $ReRoll = 0
            Else
                $ReRoll = 1
            EndIf
        Case $Computer_Choice = 4
            If $pressed4 = 0 Then
                If $side = 1 Then
                    GUICtrlSetState(9, $GUI_SHOW)
                Else
                    GUICtrlSetState(10, $GUI_SHOW)
                EndIf
                $pressed4 = 2
                $ReRoll = 0
            Else
                $ReRoll = 1
            EndIf
        Case $Computer_Choice = 5
            If $pressed5 = 0 Then
                If $side = 1 Then
                    GUICtrlSetState(11, $GUI_SHOW)
                Else
                    GUICtrlSetState(12, $GUI_SHOW)
                EndIf
                $pressed5 = 2
                $ReRoll = 0
            Else
                $ReRoll = 1
            EndIf
        Case $Computer_Choice = 6
            If $pressed6 = 0 Then
                If $side = 1 Then
                    GUICtrlSetState(13, $GUI_SHOW)
                Else
                    GUICtrlSetState(14, $GUI_SHOW)
                EndIf
                $pressed6 = 2
                $ReRoll = 0
            Else
                $ReRoll = 1
            EndIf
        Case $Computer_Choice = 7
            If $pressed7 = 0 Then
                If $side = 1 Then
                    GUICtrlSetState(15, $GUI_SHOW)
                Else
                    GUICtrlSetState(16, $GUI_SHOW)
                EndIf
                $pressed7 = 2
                $ReRoll = 0
            Else
                $ReRoll = 1
            EndIf
        Case $Computer_Choice = 8
            If $pressed8 = 0 Then
                If $side = 1 Then
                    GUICtrlSetState(17, $GUI_SHOW)
                Else
                    GUICtrlSetState(18, $GUI_SHOW)
                EndIf
                $pressed8 = 2
                $ReRoll = 0
            Else
                $ReRoll = 1
            EndIf
        Case $Computer_Choice = 9
            If $pressed9 = 0 Then
                If $side = 1 Then
                    GUICtrlSetState(19, $GUI_SHOW)
                Else
                    GUICtrlSetState(20, $GUI_SHOW)
                EndIf
                $pressed9 = 2
                $ReRoll = 0
            Else
                $ReRoll = 1
            EndIf
    EndSelect
EndFunc

Func Check_Winner()
    Select
        Case $pressed1 = 1 And $pressed2 = 1 And $pressed3 = 1
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "You Win!")
            $win = 1
        Case $pressed4 = 1 And $pressed5 = 1 And $pressed6 = 1
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "You Win!")
            $win = 1
        Case $pressed7 = 1 And $pressed8 = 1 And $pressed9 = 1
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "You Win!")
            $win = 1
        Case $pressed1 = 1 And $pressed4 = 1 And $pressed7 = 1
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "You Win!")
            $win = 1
        Case $pressed2 = 1 And $pressed5 = 1 And $pressed8 = 1
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "You Win!")
            $win = 1
        Case $pressed3 = 1 And $pressed6 = 1 And $pressed9 = 1
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "You Win!")
            $win = 1
        Case $pressed1 = 1 And $pressed5 = 1 And $pressed9 = 1
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "You Win!")
            $win = 1
        Case $pressed3 = 1 And $pressed5 = 1 And $pressed7 = 1
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "You Win!")
            $win = 1
    ;=========================================================================================
        Case $pressed1 = 2 And $pressed2 = 2 And $pressed3 = 2
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "Game Over - You Lose")
            $win = 1
        Case $pressed4 = 2 And $pressed5 = 2 And $pressed6 = 2
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "Game Over - You Lose")
            $win = 1
        Case $pressed7 = 2 And $pressed8 = 2 And $pressed9 = 2
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "Game Over - You Lose")
            $win = 1
        Case $pressed1 = 2 And $pressed4 = 2 And $pressed7 = 2
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "Game Over - You Lose")
            $win = 1
        Case $pressed2 = 2 And $pressed5 = 2 And $pressed8 = 2
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "Game Over - You Lose")
            $win = 1
        Case $pressed3 = 2 And $pressed6 = 2 And $pressed9 = 2
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "Game Over - You Lose")
            $win = 1
        Case $pressed1 = 2 And $pressed5 = 2 And $pressed9 = 2
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "Game Over - You Lose")
            $win = 1
        Case $pressed3 = 2 And $pressed5 = 2 And $pressed7 = 2
            GUICtrlSetState(21, $GUI_DISABLE)
            GUICtrlSetState(22, $GUI_DISABLE)
            GUICtrlSetState(23, $GUI_DISABLE)
            GUICtrlSetState(24, $GUI_DISABLE)
            GUICtrlSetState(25, $GUI_DISABLE)
            GUICtrlSetState(26, $GUI_DISABLE)
            GUICtrlSetState(27, $GUI_DISABLE)
            GUICtrlSetState(28, $GUI_DISABLE)
            GUICtrlSetState(29, $GUI_DISABLE)
            GUICtrlSetData($Status, "Game Over - You Lose")
    EndSelect
EndFunc

Func Restart()
    GUICtrlSetState(3, $GUI_HIDE)
    GUICtrlSetState(4, $GUI_HIDE)
    GUICtrlSetState(5, $GUI_HIDE)
    GUICtrlSetState(6, $GUI_HIDE)
    GUICtrlSetState(7, $GUI_HIDE)
    GUICtrlSetState(8, $GUI_HIDE)
    GUICtrlSetState(9, $GUI_HIDE)
    GUICtrlSetState(10, $GUI_HIDE)
    GUICtrlSetState(11, $GUI_HIDE)
    GUICtrlSetState(12, $GUI_HIDE)
    GUICtrlSetState(13, $GUI_HIDE)
    GUICtrlSetState(14, $GUI_HIDE)
    GUICtrlSetState(15, $GUI_HIDE)
    GUICtrlSetState(16, $GUI_HIDE)
    GUICtrlSetState(17, $GUI_HIDE)
    GUICtrlSetState(18, $GUI_HIDE)
    GUICtrlSetState(19, $GUI_HIDE)
    GUICtrlSetState(20, $GUI_HIDE)
    GUICtrlSetState(21, $GUI_ENABLE)
    GUICtrlSetState(22, $GUI_ENABLE)
    GUICtrlSetState(23, $GUI_ENABLE)
    GUICtrlSetState(24, $GUI_ENABLE)
    GUICtrlSetState(25, $GUI_ENABLE)
    GUICtrlSetState(26, $GUI_ENABLE)
    GUICtrlSetState(27, $GUI_ENABLE)
    GUICtrlSetState(28, $GUI_ENABLE)
    GUICtrlSetState(29, $GUI_ENABLE)
    GUICtrlSetData($Status, "Simply click somewhere on the grid to begin.")
    $win = 0
    $ReRoll = 0
    $Strategy_Move = 0
    $pressed1 = 0
    $pressed2 = 0
    $pressed3 = 0
    $pressed4 = 0
    $pressed5 = 0
    $pressed6 = 0
    $pressed7 = 0
    $pressed8 = 0
    $pressed9 = 0
EndFunc

Lol... just realized... the other Tic-Tac-Toe maker was suprised that his script was 155 lines long... mine is 855. Here are the pictures to go along with it:

Just unzip these into the same directory as the script, and it should work fine. Let me know if you find out where that infiniate loop bug is coming from >_< .

Edited by dandymcgee

- Dan [Website]

Share this post


Link to post
Share on other sites



The game does work but the logic could be improved on quite a bit. Also, if you set the gui's background colour to white, it looks a lot nicer with the pictures.


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

i cant download the pic to go with it. after i click it , it comes up with a board message and says i don't have permission o.O?

Share this post


Link to post
Share on other sites

The game does work but the logic could be improved on quite a bit. Also, if you set the gui's background colour to white, it looks a lot nicer with the pictures.

I agree, You took too much time in simulating each possible combination. you could have made some sort of AI mathematic function.

nice work though


[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I didn't make any "AI" (not sure exactly what this stands for...), because I made this game out of extreme bordum, and lack of ideas for anything better to create. If anyone has any ideas for a script, that is reasonably possible with AutoIt, let me know and I'll be more than willing to jump to it and have something intersting (an interesting idea for an AutoIt script will be the first in quite a while for me) to do for a while. Thanks for the feedback.

Edited by dandymcgee

- Dan [Website]

Share this post


Link to post
Share on other sites

AI=Artificial Intelligence.

AI would be hard in Autoit because technically it would mean learning as it goes along. Phillip Benefall is attempting this with his chat script.

Share this post


Link to post
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
Sign in to follow this  
Followers 0