Nahuel Posted September 25, 2007 Share Posted September 25, 2007 (edited) The discussion in this thread made me want to do this. I really like the way it tries to beat you.How it works:First, it will try to see if there's an obvious way of winning (Like two O's in a row). If there isn't, it will try to stop you from winning. If it can't (or there isn't anything to block) then it will try to see if there's a 'less obvious' way to win (Like an O somewhere and two free squares next to it). If it can't do anything of this, then it will just pick a random square.expandcollapse popup#include <GUIConstants.au3> #NoTrayIcon Global $over=0 Global $win=0 Global $turn=1 Global $yo=0 Global $comp=0 GUICreate("Tic Tac Toe", 254, 228) $A1 = GUICtrlCreateLabel("", 8, 8, 76, 65, BitOR($SS_CENTER,$SS_SUNKEN)) GUIctrlsetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,40) $A2 = GUICtrlCreateLabel("", 88, 8, 76, 65, BitOR($SS_CENTER,$SS_SUNKEN)) GUIctrlsetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,40) $A3 = GUICtrlCreateLabel("", 168, 8, 76, 65, BitOR($SS_CENTER,$SS_SUNKEN)) GUIctrlsetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,40) $B1 = GUICtrlCreateLabel("", 8, 80, 76, 65, BitOR($SS_CENTER,$SS_SUNKEN)) GUIctrlsetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,40) $B2 = GUICtrlCreateLabel("", 88, 80, 76, 65, BitOR($SS_CENTER,$SS_SUNKEN)) GUIctrlsetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,40) $B3 = GUICtrlCreateLabel("", 168, 80, 76, 65, BitOR($SS_CENTER,$SS_SUNKEN)) GUIctrlsetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,40) $C1 = GUICtrlCreateLabel("", 8, 152, 76, 65, BitOR($SS_CENTER,$SS_SUNKEN)) GUIctrlsetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,40) $C2 = GUICtrlCreateLabel("", 88, 152, 76, 65, BitOR($SS_CENTER,$SS_SUNKEN)) GUIctrlsetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,40) $C3 = GUICtrlCreateLabel("", 168, 152, 76, 65, BitOR($SS_CENTER,$SS_SUNKEN)) GUIctrlsetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,40) GUISetBkColor(0x000000) GUISetState(@SW_SHOW) Randomize() While 1 clear() Do $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $A1 jugar($A1) Case $A2 jugar($A2) Case $A3 jugar($A3) Case $B1 jugar($B1) Case $B2 jugar($B2) Case $B3 jugar($B3) Case $C1 jugar($C1) Case $C2 jugar($C2) Case $C3 jugar($C3) EndSwitch win() Until $win=1 OR $win=2 OR $over=1 If $win=1 Then $yo+=1 SoundPlay(@WindowsDir&"\media\tada.wav") MsgBox(0,"","You Won!"&@CR&@CR&"You= "&$yo&@CR&"Bot= "&$Comp) EndIf If $win=2 Then $comp+=1 MsgBox(0,"","You Lost!"&@CR&@CR&"You= "&$yo&@CR&"Bot= "&$Comp) EndIf If $win=0 AND $over=1 Then MsgBox(0,"","It's A Tie!"&@CR&@CR&"You= "&$yo&@CR&"Bot= "&$Comp) EndIf WEnd Func jugar($oCasi) GUICtrlSetData($oCasi,"X") GUICtrlSetState($oCasi,$GUI_DISABLE) ;TRATAR DE GANAR(EVIDENTE) ;Horizontal= If GUICtrlRead($A1)="O" AND GUICtrlRead($A2)="O" AND GUICtrlRead($A3)="" Then GUICtrlSetData($A3,"O") GUICtrlSetState($A3,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="" AND GUICtrlRead($A2)="O" AND GUICtrlRead($A3)="O" Then GUICtrlSetData($A1,"O") GUICtrlSetState($A1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="O" AND GUICtrlRead($A2)="" AND GUICtrlRead($A3)="O" Then GUICtrlSetData($A2,"O") GUICtrlSetState($A2,$GUI_DISABLE) Return EndIf If GUICtrlRead($B1)="O" AND GUICtrlRead($B2)="O" AND GUICtrlRead($B3)="" Then GUICtrlSetData($B3,"O") GUICtrlSetState($B3,$GUI_DISABLE) Return EndIf If GUICtrlRead($B1)="" AND GUICtrlRead($B2)="O" AND GUICtrlRead($B3)="O" Then GUICtrlSetData($B1,"O") GUICtrlSetState($B1,$GUI_DISABLE) Return EndIf If GUICtrlRead($B1)="O" AND GUICtrlRead($B2)="" AND GUICtrlRead($B3)="O" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf If GUICtrlRead($C1)="O" AND GUICtrlRead($C2)="O" AND GUICtrlRead($C3)="" Then GUICtrlSetData($C3,"O") GUICtrlSetState($C3,$GUI_DISABLE) Return EndIf If GUICtrlRead($C1)="" AND GUICtrlRead($C2)="O" AND GUICtrlRead($C3)="O" Then GUICtrlSetData($C1,"O") GUICtrlSetState($C1,$GUI_DISABLE) Return EndIf If GUICtrlRead($C1)="O" AND GUICtrlRead($C2)="" AND GUICtrlRead($C3)="O" Then GUICtrlSetData($C2,"O") GUICtrlSetState($C2,$GUI_DISABLE) Return EndIf ;======== ;Vertical= If GUICtrlRead($A1)="O" AND GUICtrlRead($B1)="" AND GUICtrlRead($C1)="O" Then GUICtrlSetData($B1,"O") GUICtrlSetState($B1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="" AND GUICtrlRead($B1)="O" AND GUICtrlRead($C1)="O" Then GUICtrlSetData($A1,"O") GUICtrlSetState($A1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="O" AND GUICtrlRead($B1)="O" AND GUICtrlRead($C1)="" Then GUICtrlSetData($C1,"O") GUICtrlSetState($C1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A2)="O" AND GUICtrlRead($B2)="" AND GUICtrlRead($C2)="O" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A2)="" AND GUICtrlRead($B2)="O" AND GUICtrlRead($C2)="O" Then GUICtrlSetData($A2,"O") GUICtrlSetState($A2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A2)="O" AND GUICtrlRead($B2)="O" AND GUICtrlRead($C2)="" Then GUICtrlSetData($C2,"O") GUICtrlSetState($C2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="O" AND GUICtrlRead($B3)="" AND GUICtrlRead($C3)="O" Then GUICtrlSetData($B3,"O") GUICtrlSetState($B3,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="" AND GUICtrlRead($B3)="O" AND GUICtrlRead($C3)="O" Then GUICtrlSetData($A3,"O") GUICtrlSetState($A3,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="O" AND GUICtrlRead($B3)="O" AND GUICtrlRead($C3)="" Then GUICtrlSetData($C3,"O") GUICtrlSetState($C3,$GUI_DISABLE) Return EndIf ;============== ;Diagonal= If GUICtrlRead($A1)="O" AND GUICtrlRead($B2)="O" AND GUICtrlRead($C3)="" Then GUICtrlSetData($C3,"O") GUICtrlSetState($C3,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="O" AND GUICtrlRead($B2)="" AND GUICtrlRead($C3)="O" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="" AND GUICtrlRead($B2)="O" AND GUICtrlRead($C3)="O" Then GUICtrlSetData($A1,"O") GUICtrlSetState($A1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="O" AND GUICtrlRead($B2)="O" AND GUICtrlRead($C1)="" Then GUICtrlSetData($C1,"O") GUICtrlSetState($C1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="O" AND GUICtrlRead($B2)="" AND GUICtrlRead($C1)="O" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="" AND GUICtrlRead($B2)="O" AND GUICtrlRead($C1)="O" Then GUICtrlSetData($A3,"O") GUICtrlSetState($A3,$GUI_DISABLE) Return EndIf ;====================== ;TRATAR DE EVITAR QUE USUARIO GANE= ;Horizontal= If GUICtrlRead($A1)="X" AND GUICtrlRead($A2)="X" AND GUICtrlRead($A3)="" Then GUICtrlSetData($A3,"O") GUICtrlSetState($A3,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="" AND GUICtrlRead($A2)="X" AND GUICtrlRead($A3)="X" Then GUICtrlSetData($A1,"O") GUICtrlSetState($A1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="X" AND GUICtrlRead($A2)="" AND GUICtrlRead($A3)="X" Then GUICtrlSetData($A2,"O") GUICtrlSetState($A2,$GUI_DISABLE) Return EndIf If GUICtrlRead($B1)="X" AND GUICtrlRead($B2)="X" AND GUICtrlRead($B3)="" Then GUICtrlSetData($B3,"O") GUICtrlSetState($B3,$GUI_DISABLE) Return EndIf If GUICtrlRead($B1)="" AND GUICtrlRead($B2)="X" AND GUICtrlRead($B3)="X" Then GUICtrlSetData($B1,"O") GUICtrlSetState($B1,$GUI_DISABLE) Return EndIf If GUICtrlRead($B1)="X" AND GUICtrlRead($B2)="" AND GUICtrlRead($B3)="X" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf If GUICtrlRead($C1)="X" AND GUICtrlRead($C2)="X" AND GUICtrlRead($C3)="" Then GUICtrlSetData($C3,"O") GUICtrlSetState($C3,$GUI_DISABLE) Return EndIf If GUICtrlRead($C1)="" AND GUICtrlRead($C2)="X" AND GUICtrlRead($C3)="X" Then GUICtrlSetData($C1,"O") GUICtrlSetState($C1,$GUI_DISABLE) Return EndIf If GUICtrlRead($C1)="X" AND GUICtrlRead($C2)="" AND GUICtrlRead($C3)="X" Then GUICtrlSetData($C2,"O") GUICtrlSetState($C2,$GUI_DISABLE) Return EndIf ;======== ;Vertical= If GUICtrlRead($A1)="X" AND GUICtrlRead($B1)="" AND GUICtrlRead($C1)="X" Then GUICtrlSetData($B1,"O") GUICtrlSetState($B1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="" AND GUICtrlRead($B1)="X" AND GUICtrlRead($C1)="X" Then GUICtrlSetData($A1,"O") GUICtrlSetState($A1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="X" AND GUICtrlRead($B1)="X" AND GUICtrlRead($C1)="" Then GUICtrlSetData($C1,"O") GUICtrlSetState($C1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A2)="X" AND GUICtrlRead($B2)="" AND GUICtrlRead($C2)="X" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A2)="" AND GUICtrlRead($B2)="X" AND GUICtrlRead($C2)="X" Then GUICtrlSetData($A2,"O") GUICtrlSetState($A2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A2)="X" AND GUICtrlRead($B2)="X" AND GUICtrlRead($C2)="" Then GUICtrlSetData($C2,"O") GUICtrlSetState($C2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="X" AND GUICtrlRead($B3)="" AND GUICtrlRead($C3)="X" Then GUICtrlSetData($B3,"O") GUICtrlSetState($B3,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="" AND GUICtrlRead($B3)="X" AND GUICtrlRead($C3)="X" Then GUICtrlSetData($A3,"O") GUICtrlSetState($A3,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="X" AND GUICtrlRead($B3)="X" AND GUICtrlRead($C3)="" Then GUICtrlSetData($C3,"O") GUICtrlSetState($C3,$GUI_DISABLE) Return EndIf ;============== ;Diagonal= If GUICtrlRead($A1)="X" AND GUICtrlRead($B2)="X" AND GUICtrlRead($C3)="" Then GUICtrlSetData($C3,"O") GUICtrlSetState($C3,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="X" AND GUICtrlRead($B2)="" AND GUICtrlRead($C3)="X" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="" AND GUICtrlRead($B2)="X" AND GUICtrlRead($C3)="X" Then GUICtrlSetData($A1,"O") GUICtrlSetState($A1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="X" AND GUICtrlRead($B2)="X" AND GUICtrlRead($C1)="" Then GUICtrlSetData($C1,"O") GUICtrlSetState($C1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="X" AND GUICtrlRead($B2)="" AND GUICtrlRead($C1)="X" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="" AND GUICtrlRead($B2)="X" AND GUICtrlRead($C1)="X" Then GUICtrlSetData($A3,"O") GUICtrlSetState($A3,$GUI_DISABLE) Return EndIf ;====================== ;TRATAR DE GANAR(NO EVIDENTE) ;Horizontal= If GUICtrlRead($A1)="O" AND GUICtrlRead($A2)="" AND GUICtrlRead($A3)="" Then GUICtrlSetData($A3,"O") GUICtrlSetState($A3,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="" AND GUICtrlRead($A2)="O" AND GUICtrlRead($A3)="" Then GUICtrlSetData($A1,"O") GUICtrlSetState($A1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="" AND GUICtrlRead($A2)="" AND GUICtrlRead($A3)="O" Then GUICtrlSetData($A2,"O") GUICtrlSetState($A2,$GUI_DISABLE) Return EndIf If GUICtrlRead($B1)="O" AND GUICtrlRead($B2)="" AND GUICtrlRead($B3)="" Then GUICtrlSetData($B3,"O") GUICtrlSetState($B3,$GUI_DISABLE) Return EndIf If GUICtrlRead($B1)="" AND GUICtrlRead($B2)="O" AND GUICtrlRead($B3)="" Then GUICtrlSetData($B1,"O") GUICtrlSetState($B1,$GUI_DISABLE) Return EndIf If GUICtrlRead($B1)="" AND GUICtrlRead($B2)="" AND GUICtrlRead($B3)="O" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf If GUICtrlRead($C1)="O" AND GUICtrlRead($C2)="" AND GUICtrlRead($C3)="" Then GUICtrlSetData($C3,"O") GUICtrlSetState($C3,$GUI_DISABLE) Return EndIf If GUICtrlRead($C1)="" AND GUICtrlRead($C2)="O" AND GUICtrlRead($C3)="" Then GUICtrlSetData($C1,"O") GUICtrlSetState($C1,$GUI_DISABLE) Return EndIf If GUICtrlRead($C1)="" AND GUICtrlRead($C2)="" AND GUICtrlRead($C3)="O" Then GUICtrlSetData($C2,"O") GUICtrlSetState($C2,$GUI_DISABLE) Return EndIf ;======== ;Vertical= If GUICtrlRead($A1)="O" AND GUICtrlRead($B1)="" AND GUICtrlRead($C1)="" Then GUICtrlSetData($B1,"O") GUICtrlSetState($B1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="" AND GUICtrlRead($B1)="" AND GUICtrlRead($C1)="O" Then GUICtrlSetData($A1,"O") GUICtrlSetState($A1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="" AND GUICtrlRead($B1)="O" AND GUICtrlRead($C1)="" Then GUICtrlSetData($C1,"O") GUICtrlSetState($C1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A2)="O" AND GUICtrlRead($B2)="" AND GUICtrlRead($C2)="" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A2)="" AND GUICtrlRead($B2)="" AND GUICtrlRead($C2)="O" Then GUICtrlSetData($A2,"O") GUICtrlSetState($A2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A2)="" AND GUICtrlRead($B2)="O" AND GUICtrlRead($C2)="" Then GUICtrlSetData($C2,"O") GUICtrlSetState($C2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="O" AND GUICtrlRead($B3)="" AND GUICtrlRead($C3)="" Then GUICtrlSetData($B3,"O") GUICtrlSetState($B3,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="" AND GUICtrlRead($B3)="" AND GUICtrlRead($C3)="O" Then GUICtrlSetData($A3,"O") GUICtrlSetState($A3,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="" AND GUICtrlRead($B3)="O" AND GUICtrlRead($C3)="" Then GUICtrlSetData($C3,"O") GUICtrlSetState($C3,$GUI_DISABLE) Return EndIf ;============== ;Diagonal= If GUICtrlRead($A1)="O" AND GUICtrlRead($B2)="" AND GUICtrlRead($C3)="" Then GUICtrlSetData($C3,"O") GUICtrlSetState($C3,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="" AND GUICtrlRead($B2)="" AND GUICtrlRead($C3)="O" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A1)="" AND GUICtrlRead($B2)="O" AND GUICtrlRead($C3)="" Then GUICtrlSetData($A1,"O") GUICtrlSetState($A1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="O" AND GUICtrlRead($B2)="" AND GUICtrlRead($C1)="" Then GUICtrlSetData($C1,"O") GUICtrlSetState($C1,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="" AND GUICtrlRead($B2)="" AND GUICtrlRead($C1)="O" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf If GUICtrlRead($A3)="" AND GUICtrlRead($B2)="O" AND GUICtrlRead($C1)="" Then GUICtrlSetData($A3,"O") GUICtrlSetState($A3,$GUI_DISABLE) Return EndIf ;====================== ;AL AZAR _Random() EndFunc;==>Jugar() Func _Random() ;Random= $a=0 Do $a+=1 $oRan=Random(1,9,1) If $oRan=1 Then $iCas=$A1 If $oRan=2 Then $iCas=$A2 If $oRan=3 Then $iCas=$A3 If $oRan=4 Then $iCas=$B1 If $oRan=5 Then $iCas=$B2 If $oRan=6 Then $iCas=$B3 If $oRan=7 Then $iCas=$C1 If $oRan=8 Then $iCas=$C2 If $oRan=9 Then $iCas=$C3 If GUICtrlRead($iCas)="" Then ExitLoop Until $a=100 If $a<>100 Then GUICtrlSetData($iCas,"O") GUICtrlSetState($iCas,$GUI_DISABLE) Else $over=1 EndIf Check() EndFunc Func win() ;"X" If GUICtrlRead($A1)="X" and GUICtrlRead($A2)="X" and GUICtrlRead($A3)="X" Then $win=1 Return EndIf If GUICtrlRead($B1)="X" and GUICtrlRead($B2)="X" and GUICtrlRead($B3)="X" Then $win=1 Return EndIf If GUICtrlRead($C1)="X" and GUICtrlRead($C2)="X" and GUICtrlRead($C3)="X" Then $win=1 Return EndIf If GUICtrlRead($A1)="X" and GUICtrlRead($B1)="X" and GUICtrlRead($C1)="X" Then $win=1 Return EndIf If GUICtrlRead($A2)="X" and GUICtrlRead($B2)="X" and GUICtrlRead($C2)="X" Then $win=1 Return EndIf If GUICtrlRead($A3)="X" and GUICtrlRead($B3)="X" and GUICtrlRead($C3)="X" Then $win=1 Return EndIf If GUICtrlRead($A1)="X" and GUICtrlRead($B2)="X" and GUICtrlRead($C3)="X" Then $win=1 Return EndIf If GUICtrlRead($A3)="X" and GUICtrlRead($B2)="X" and GUICtrlRead($C1)="X" Then $win=1 Return EndIf ;"O" If GUICtrlRead($A1)="O" and GUICtrlRead($A2)="O" and GUICtrlRead($A3)="O" Then $win=2 Return EndIf If GUICtrlRead($B1)="O" and GUICtrlRead($B2)="O" and GUICtrlRead($B3)="O" Then $win=2 Return EndIf If GUICtrlRead($C1)="O" and GUICtrlRead($C2)="O" and GUICtrlRead($C3)="O" Then $win=2 Return EndIf If GUICtrlRead($A1)="O" and GUICtrlRead($B1)="O" and GUICtrlRead($C1)="O" Then $win=2 Return EndIf If GUICtrlRead($A2)="O" and GUICtrlRead($B2)="O" and GUICtrlRead($C2)="O" Then $win=2 Return EndIf If GUICtrlRead($A3)="O" and GUICtrlRead($B3)="O" and GUICtrlRead($C3)="O" Then $win=2 Return EndIf If GUICtrlRead($A1)="O" and GUICtrlRead($B2)="O" and GUICtrlRead($C3)="O" Then $win=2 Return EndIf If GUICtrlRead($A3)="O" and GUICtrlRead($B2)="O" and GUICtrlRead($C1)="O" Then $win=2 Return EndIf Check() EndFunc;===>Win() Func clear() GUICtrlSetData($A1,"") GUICtrlSetState($A1,$GUI_ENABLE) GUICtrlSetData($A2,"") GUICtrlSetState($A2,$GUI_ENABLE) GUICtrlSetData($A3,"") GUICtrlSetState($A3,$GUI_ENABLE) GUICtrlSetData($B1,"") GUICtrlSetState($B1,$GUI_ENABLE) GUICtrlSetData($B2,"") GUICtrlSetState($B2,$GUI_ENABLE) GUICtrlSetData($B3,"") GUICtrlSetState($B3,$GUI_ENABLE) GUICtrlSetData($C1,"") GUICtrlSetState($C1,$GUI_ENABLE) GUICtrlSetData($C2,"") GUICtrlSetState($C2,$GUI_ENABLE) GUICtrlSetData($C3,"") GUICtrlSetState($C3,$GUI_ENABLE) $win=0 $over=0 $turn = Not $turn If $turn Then _Random() EndIf EndFunc Func Randomize() Sleep(200) GUICtrlSetData($A1,"TA") Sleep(200) GUICtrlSetData($B2,"TE") Sleep(200) GUICtrlSetData($C3,"TI") Sleep(200) GUICtrlSetData($A1,"") Sleep(200) GUICtrlSetData($B2,"") Sleep(200) GUICtrlSetData($C3,"") Sleep(200) EndFunc Func Check() If GUICtrlRead($A1)<>"" AND GUICtrlRead($A2)<>"" AND GUICtrlRead($A3)<>"" AND GUICtrlRead($B1)<>"" AND GUICtrlRead($B2)<>"" AND GUICtrlRead($B3)<>""AND GUICtrlRead($C1)<>"" AND GUICtrlRead($C2)<>"" AND GUICtrlRead($C3)<>"" Then $over=1 EndIf EndFunc Edited September 25, 2007 by Nahuel Link to comment Share on other sites More sharing options...
maqleod Posted September 25, 2007 Share Posted September 25, 2007 (edited) nice, great job with the AI maybe add a two player mode so you don't have to play the AI all the time? Edited September 25, 2007 by maqleod [u]You can download my projects at:[/u] Pulsar Software Link to comment Share on other sites More sharing options...
Generator Posted September 25, 2007 Share Posted September 25, 2007 Looks like it was alot of scripting on the AI, good job and i like it , make it multiplayer is definately the way to go. Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted September 25, 2007 Share Posted September 25, 2007 nice, great job with the AImaybe add a two player mode so you don't have to play the AI all the time?Great work, Did you come up with the AI yourself or find it somewhere? Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
gseller Posted September 25, 2007 Share Posted September 25, 2007 Sweet!! That is a tricky bot!! Hard to beat... Link to comment Share on other sites More sharing options...
qwer85 Posted September 25, 2007 Share Posted September 25, 2007 (edited) Well I was just testing the ai... after 10 seconds of random placement of "X"'es I won [EDIT 1] Well... I'm winning now every time.[EDIT 2] There is one of the tactics to win: Edited September 25, 2007 by qwer85 Link to comment Share on other sites More sharing options...
jvanegmond Posted September 25, 2007 Share Posted September 25, 2007 (edited) I won on the first go.. This is the part responsible. I win by putting my cross on either one of the corners, let's say A3, the AI then puts it in B2 then you put it in C1, now, when the bot puts a cross in one of the corners that are left you have won. Don't put a cross in the middle when another player has put their cross in one of the corners first. If GUICtrlRead($B2)="" Then GUICtrlSetData($B2,"O") GUICtrlSetState($B2,$GUI_DISABLE) Return EndIf Edited September 25, 2007 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Valuater Posted September 25, 2007 Share Posted September 25, 2007 Awesome AI ... a little tuffer expandcollapse popup#include <GUIConstants.au3> #NoTrayIcon Global $over = 0 Global $win = 0 Global $turn = 0 GUICreate("Tic Tac Toe", 254, 228) $A1 = GUICtrlCreateLabel("", 8, 8, 76, 65, BitOR($SS_CENTER, $SS_SUNKEN)) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 40) $A2 = GUICtrlCreateLabel("", 88, 8, 76, 65, BitOR($SS_CENTER, $SS_SUNKEN)) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 40) $A3 = GUICtrlCreateLabel("", 168, 8, 76, 65, BitOR($SS_CENTER, $SS_SUNKEN)) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 40) $B1 = GUICtrlCreateLabel("", 8, 80, 76, 65, BitOR($SS_CENTER, $SS_SUNKEN)) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 40) $B2 = GUICtrlCreateLabel("", 88, 80, 76, 65, BitOR($SS_CENTER, $SS_SUNKEN)) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 40) $B3 = GUICtrlCreateLabel("", 168, 80, 76, 65, BitOR($SS_CENTER, $SS_SUNKEN)) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 40) $C1 = GUICtrlCreateLabel("", 8, 152, 76, 65, BitOR($SS_CENTER, $SS_SUNKEN)) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 40) $C2 = GUICtrlCreateLabel("", 88, 152, 76, 65, BitOR($SS_CENTER, $SS_SUNKEN)) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 40) $C3 = GUICtrlCreateLabel("", 168, 152, 76, 65, BitOR($SS_CENTER, $SS_SUNKEN)) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 40) GUISetBkColor(0x000000) GUISetState(@SW_SHOW) Randomize() While 1 clear() Do $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $A1 jugar($A1) Case $A2 jugar($A2) Case $A3 jugar($A3) Case $B1 jugar($B1) Case $B2 jugar($B2) Case $B3 jugar($B3) Case $C1 jugar($C1) Case $C2 jugar($C2) Case $C3 jugar($C3) EndSwitch win() Until $win = 1 Or $win = 2 Or $over = 1 If $win = 1 Then MsgBox(262144, "", "You won!", 5) EndIf If $win = 2 Then MsgBox(262144, "", "You lost!", 5) EndIf If $win = 0 And $over = 1 Then MsgBox(262144, "", "It's a tie!", 5) EndIf WEnd Func jugar($oCasi) GUICtrlSetData($oCasi, "X") GUICtrlSetState($oCasi, $GUI_DISABLE) If GUICtrlRead($B2) = "" Then Return Place($B2) ;TRATAR DE GANAR ;Diagonal= If GUICtrlRead($A1) = "O" And GUICtrlRead($B2) = "O" And GUICtrlRead($C3) = "" Then Return Place($C3) If GUICtrlRead($A1) = "" And GUICtrlRead($B2) = "O" And GUICtrlRead($C3) = "O" Then Return Place($A1) If GUICtrlRead($A3) = "O" And GUICtrlRead($B2) = "O" And GUICtrlRead($C1) = "" Then Return Place($C1) If GUICtrlRead($A3) = "" And GUICtrlRead($B2) = "O" And GUICtrlRead($C1) = "O" Then Return Place($A3) ;======== ;Horizontal= If GUICtrlRead($A1) = "O" And GUICtrlRead($A2) = "O" And GUICtrlRead($A3) = "" Then Return Place($A3) If GUICtrlRead($A1) = "" And GUICtrlRead($A2) = "O" And GUICtrlRead($A3) = "O" Then Return Place($A1) If GUICtrlRead($A1) = "O" And GUICtrlRead($A2) = "" And GUICtrlRead($A3) = "O" Then Return Place($A2) If GUICtrlRead($B1) = "O" And GUICtrlRead($B2) = "O" And GUICtrlRead($B3) = "" Then Return Place($B3) If GUICtrlRead($B1) = "" And GUICtrlRead($B2) = "O" And GUICtrlRead($B3) = "O" Then Return Place($B1) If GUICtrlRead($C1) = "O" And GUICtrlRead($C2) = "O" And GUICtrlRead($C3) = "" Then Return Place($C3) If GUICtrlRead($C1) = "" And GUICtrlRead($C2) = "O" And GUICtrlRead($C3) = "O" Then Return Place($C1) If GUICtrlRead($C1) = "O" And GUICtrlRead($C2) = "" And GUICtrlRead($C3) = "O" Then Return Place($C2) ;======== ;Vertical= If GUICtrlRead($A1) = "O" And GUICtrlRead($B1) = "" And GUICtrlRead($C1) = "O" Then Return Place($B1) If GUICtrlRead($A1) = "" And GUICtrlRead($B1) = "O" And GUICtrlRead($C1) = "O" Then Return Place($A1) If GUICtrlRead($A1) = "O" And GUICtrlRead($B1) = "O" And GUICtrlRead($C1) = "" Then Return Place($C1) If GUICtrlRead($A2) = "" And GUICtrlRead($B2) = "O" And GUICtrlRead($C2) = "O" Then Return Place($A2) If GUICtrlRead($A2) = "O" And GUICtrlRead($B2) = "O" And GUICtrlRead($C2) = "" Then Return Place($C2) If GUICtrlRead($A3) = "O" And GUICtrlRead($B3) = "" And GUICtrlRead($C3) = "O" Then Return Place($B3) If GUICtrlRead($A3) = "" And GUICtrlRead($B3) = "O" And GUICtrlRead($C3) = "O" Then Return Place($A3) If GUICtrlRead($A3) = "O" And GUICtrlRead($B3) = "O" And GUICtrlRead($C3) = "" Then Return Place($C3) ;============== ;====================== ;TRATAR DE EVITAR QUE GANE= ;Horizontal= If GUICtrlRead($A1) = "X" And GUICtrlRead($A2) = "X" And GUICtrlRead($A3) = "" Then Return Place($A3) If GUICtrlRead($A1) = "" And GUICtrlRead($A2) = "X" And GUICtrlRead($A3) = "X" Then Return Place($A1) If GUICtrlRead($A1) = "X" And GUICtrlRead($A2) = "" And GUICtrlRead($A3) = "X" Then Return Place($A2) If GUICtrlRead($B1) = "X" And GUICtrlRead($B2) = "X" And GUICtrlRead($B3) = "" Then Return Place($B3) If GUICtrlRead($B1) = "" And GUICtrlRead($B2) = "X" And GUICtrlRead($B3) = "X" Then Return Place($B1) If GUICtrlRead($C1) = "X" And GUICtrlRead($C2) = "X" And GUICtrlRead($C3) = "" Then Return Place($C3) If GUICtrlRead($C1) = "" And GUICtrlRead($C2) = "X" And GUICtrlRead($C3) = "X" Then Return Place($C1) If GUICtrlRead($C1) = "X" And GUICtrlRead($C2) = "" And GUICtrlRead($C3) = "X" Then Return Place($C2) ;======== ;Vertical= If GUICtrlRead($A1) = "X" And GUICtrlRead($B1) = "" And GUICtrlRead($C1) = "X" Then Return Place($B1) If GUICtrlRead($A1) = "" And GUICtrlRead($B1) = "X" And GUICtrlRead($C1) = "X" Then Return Place($A1) If GUICtrlRead($A1) = "X" And GUICtrlRead($B1) = "X" And GUICtrlRead($C1) = "" Then Return Place($C1) If GUICtrlRead($A2) = "" And GUICtrlRead($B2) = "X" And GUICtrlRead($C2) = "X" Then Return Place($A2) If GUICtrlRead($A2) = "X" And GUICtrlRead($B2) = "X" And GUICtrlRead($C2) = "" Then Return Place($C2) If GUICtrlRead($A3) = "X" And GUICtrlRead($B3) = "" And GUICtrlRead($C3) = "X" Then Return Place($B3) If GUICtrlRead($A3) = "" And GUICtrlRead($B3) = "X" And GUICtrlRead($C3) = "X" Then Return Place($A3) If GUICtrlRead($A3) = "X" And GUICtrlRead($B3) = "X" And GUICtrlRead($C3) = "" Then Return Place($C3) ;============== ;Diagonal= If GUICtrlRead($A1) = "X" And GUICtrlRead($B2) = "X" And GUICtrlRead($C3) = "" Then Return Place($C3) If GUICtrlRead($A1) = "" And GUICtrlRead($B2) = "X" And GUICtrlRead($C3) = "X" Then Return Place($A1) If GUICtrlRead($A3) = "X" And GUICtrlRead($B2) = "X" And GUICtrlRead($C1) = "" Then Return Place($C1) If GUICtrlRead($A3) = "" And GUICtrlRead($B2) = "X" And GUICtrlRead($C1) = "X" Then Return Place($A3) ;====================== ;Random= $a = 0 Do $a += 1 $oRan = Random(1, 9, 1) If $oRan = 1 Then $iCas = $A1 If $oRan = 2 Then $iCas = $A2 If $oRan = 3 Then $iCas = $A3 If $oRan = 4 Then $iCas = $B1 If $oRan = 5 Then $iCas = $B2 If $oRan = 6 Then $iCas = $B3 If $oRan = 7 Then $iCas = $C1 If $oRan = 8 Then $iCas = $C2 If $oRan = 9 Then $iCas = $C3 If GUICtrlRead($iCas) = "" Then ExitLoop Until $a = 100 If $a <> 100 Then GUICtrlSetData($iCas, "O") GUICtrlSetState($iCas, $GUI_DISABLE) Else $over = 1 EndIf EndFunc ;==>jugar Func Place($Ctrl) GUICtrlSetData($Ctrl, "O") GUICtrlSetState($Ctrl, $GUI_DISABLE) EndFunc ;==>Place Func win() ;"X" $win = 1 If GUICtrlRead($A1) = "X" And GUICtrlRead($A2) = "X" And GUICtrlRead($A3) = "X" Then Return If GUICtrlRead($B1) = "X" And GUICtrlRead($B2) = "X" And GUICtrlRead($B3) = "X" Then Return If GUICtrlRead($C1) = "X" And GUICtrlRead($C2) = "X" And GUICtrlRead($C3) = "X" Then Return If GUICtrlRead($A1) = "X" And GUICtrlRead($B1) = "X" And GUICtrlRead($C1) = "X" Then Return If GUICtrlRead($A2) = "X" And GUICtrlRead($B2) = "X" And GUICtrlRead($C2) = "X" Then Return If GUICtrlRead($A3) = "X" And GUICtrlRead($B3) = "X" And GUICtrlRead($C3) = "X" Then Return If GUICtrlRead($A1) = "X" And GUICtrlRead($B2) = "X" And GUICtrlRead($C3) = "X" Then Return If GUICtrlRead($A3) = "X" And GUICtrlRead($B2) = "X" And GUICtrlRead($C1) = "X" Then Return ;"O" $win = 2 If GUICtrlRead($A1) = "O" And GUICtrlRead($A2) = "O" And GUICtrlRead($A3) = "O" Then Return If GUICtrlRead($B1) = "O" And GUICtrlRead($B2) = "O" And GUICtrlRead($B3) = "O" Then Return If GUICtrlRead($C1) = "O" And GUICtrlRead($C2) = "O" And GUICtrlRead($C3) = "O" Then Return If GUICtrlRead($A1) = "O" And GUICtrlRead($B1) = "O" And GUICtrlRead($C1) = "O" Then Return If GUICtrlRead($A2) = "O" And GUICtrlRead($B2) = "O" And GUICtrlRead($C2) = "O" Then Return If GUICtrlRead($A3) = "O" And GUICtrlRead($B3) = "O" And GUICtrlRead($C3) = "O" Then Return If GUICtrlRead($A1) = "O" And GUICtrlRead($B2) = "O" And GUICtrlRead($C3) = "O" Then Return If GUICtrlRead($A3) = "O" And GUICtrlRead($B2) = "O" And GUICtrlRead($C1) = "O" Then Return $win = 0 If $turn Then For $x = 1 To 3 If GUICtrlRead(Eval("A" & $x)) = "" Or GUICtrlRead(Eval("B" & $x)) = "" Or GUICtrlRead(Eval("C" & $x)) = "" Then Return Next $over = 1 EndIf EndFunc ;==>win Func clear() For $x = 1 To 3 GUICtrlSetData(Eval("A" & $x), "") GUICtrlSetState(Eval("A" & $x), $GUI_ENABLE) GUICtrlSetData(Eval("B" & $x), "") GUICtrlSetState(Eval("B" & $x), $GUI_ENABLE) GUICtrlSetData(Eval("C" & $x), "") GUICtrlSetState(Eval("C" & $x), $GUI_ENABLE) Next $win = 0 $over = 0 $turn = Not $turn If $turn Then GUICtrlSetData($B2, "O") GUICtrlSetState($B2, $GUI_DISABLE) EndIf EndFunc ;==>clear Func Randomize() Sleep(200) GUICtrlSetData($A1, "TA") Sleep(200) GUICtrlSetData($B2, "TE") Sleep(200) GUICtrlSetData($C3, "TI") Sleep(200) GUICtrlSetData($A1, "") Sleep(200) GUICtrlSetData($B2, "") Sleep(200) GUICtrlSetData($C3, "") Sleep(200) EndFunc ;==>Randomize 8) Link to comment Share on other sites More sharing options...
Nahuel Posted September 25, 2007 Author Share Posted September 25, 2007 @maqleod and @Generator: Thanks, good idea. I never used the network functions in Auoit though..@mrRevoked: Yeah, I made everything. If you see in the thread I posted, you'll see that sccrstvn98 was making one with arrays, which I think is way better. But I had already gone far till I realized that, hehe.@gesller: Thanks! @qwer85: Yeah, it's true... doesn't happen every time though. I'll have to cover those possibilites. If you have two possibilites of winning, the bot can't cover both. It'll choose a 'pseudo-random' one. I got to improve that.@Manadar: If you don't start by putting your cross in the center, the bot will. I thought that this would cover most possibilites. I mean, if it uses the center, then it's covering 4 possibilites. But if it puts it somewhere else then it's just 2. I'll see what I can do to improve it So far it can only play like an amateur tic tac toe player @Valuater: Awesome! You made it take turns! That gives the bot more chances of winning. Link to comment Share on other sites More sharing options...
Gaev Posted September 25, 2007 Share Posted September 25, 2007 I hope I am not violating any forum rules by posting this ... but I made some Tic Tac Toe applications/games earlier this year ... albeit using a program other than AutoIt.TicTacWithTheBear is available for download at no cost ... and is the one that has the intelligence built in to prevent it from losing.TicTacWithTheSockMonkey ... available for a small charge ... where Chimp the Sock Monkey (the computer) is clueless and will pick available squares at random ... so even young kids will be able to beat him from time to time.TicTacWithAFriend... also available for a small charge ... enables you to play the game with a friend ... each player taking turns to make his/her selection.Details of these games can be found at http://www.scriptedlogic.com/products_TicTac.htmI will understand if ...- some people are reluctant to download/run programs without access to the source code- if this is post is considered inappropriate for this forum Gaevhttp://www.scriptedlogic.com Link to comment Share on other sites More sharing options...
SmLex 2006 Posted September 25, 2007 Share Posted September 25, 2007 X&O - Server CODE#Compiler_AUT2EXE = C:\Program Files\AutoIt3\beta\Aut2exe\aut2exea.exe ;Override the default compiler with this version. #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Opt("ExpandVarStrings", 1) Global $matrice[10][10], $server = "", $nume = @UserName, $mut = 1, $nick = "" Global $program_nume = "X&0 SL" Global $program_versiune = "0.7" Dim $buton[10] HotKeySet("{F2}", "meniu_joc_nou") Dim $szIPADDRESS = @IPAddress1 Dim $nPORT = 1234 TCPStartup() $MainSocket = TCPListen($szIPADDRESS, $nPORT, 100) If $MainSocket = -1 Then Exit Dim $ConnectedSocket = -1 Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 Dim $szIP_Accepted = SocketToIP($ConnectedSocket) Dim $msg, $recv For $i = 1 To 3 For $j = 1 To 3 $matrice[$i][$j] = 0 Next Next $form_principal = GUICreate("$program_nume$ v$program_versiune$ - Server", 170, 285, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "form_principalClose") $Group1 = GUICtrlCreateGroup("Tabla de joc", 6, 16, 160, 183) $buton[1] = GUICtrlCreateButton("", 12, 36, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "boton_1Click") $buton[2] = GUICtrlCreateButton("", 63, 36, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_2Click") $buton[3] = GUICtrlCreateButton("", 114, 36, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_3Click") $buton[4] = GUICtrlCreateButton("", 12, 88, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_4Click") $buton[5] = GUICtrlCreateButton("", 63, 88, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_5Click") $buton[6] = GUICtrlCreateButton("", 114, 88, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_6Click") $buton[7] = GUICtrlCreateButton("", 12, 141, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_7Click") $buton[8] = GUICtrlCreateButton("", 63, 141, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_8Click") $buton[9] = GUICtrlCreateButton("", 114, 141, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_9Click") GUICtrlCreateGroup("", -99, -99, 1, 1) $fisier = GUICtrlCreateMenu("Fisier") $fisier_nou = GUICtrlCreateMenuItem("&Nou ", $fisier) GUICtrlSetOnEvent(-1, "meniu_joc_nou") $fisier_iesire = GUICtrlCreateMenuItem("Iesire", $fisier) $ajutor = GUICtrlCreateMenu("Ajutor") $ajutor_ajutor = GUICtrlCreateMenuItem("Ajutor", $ajutor) $ajutor_despre = GUICtrlCreateMenuItem("Despre", $ajutor) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) $recv = TCPRecv($ConnectedSocket, 2048) If @error Then TCPCloseSocket($ConnectedSocket) TCPShutdown() TCPStartup() $MainSocket = TCPListen($szIPADDRESS, $nPORT, 100) Dim $ConnectedSocket = -1 Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 $szIP_Accepted = SocketToIP($ConnectedSocket) EndIf If $recv <> "" Then primeste($recv) WEnd Func form_principalClose() Exit If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket) TCPShutdown() EndFunc ;==>form_principalClose Func boton_1Click() If $mut = 0 Then Return If $matrice[1][1] = 0 Then $matrice[1][1] = 1 GUICtrlSetData($buton[1], "X") TCPSend($ConnectedSocket, "muta<|*|>1") $mut = 0 verifica() EndIf EndFunc ;==>boton_1Click Func buton_2Click() If $mut = 0 Then Return If $matrice[1][2] = 0 Then $matrice[1][2] = 1 GUICtrlSetData($buton[2], "X") TCPSend($ConnectedSocket, "muta<|*|>2") $mut = 0 verifica() EndIf EndFunc ;==>buton_2Click Func buton_3Click() If $mut = 0 Then Return If $matrice[1][3] = 0 Then $matrice[1][3] = 1 GUICtrlSetData($buton[3], "X") TCPSend($ConnectedSocket, "muta<|*|>3") $mut = 0 verifica() EndIf EndFunc ;==>buton_3Click Func buton_4Click() If $mut = 0 Then Return If $matrice[2][1] = 0 Then $matrice[2][1] = 1 GUICtrlSetData($buton[4], "X") TCPSend($ConnectedSocket, "muta<|*|>4") $mut = 0 verifica() EndIf EndFunc ;==>buton_4Click Func buton_5Click() If $mut = 0 Then Return If $matrice[2][2] = 0 Then $matrice[2][2] = 1 GUICtrlSetData($buton[5], "X") TCPSend($ConnectedSocket, "muta<|*|>5") $mut = 0 verifica() EndIf EndFunc ;==>buton_5Click Func buton_6Click() If $mut = 0 Then Return If $matrice[2][3] = 0 Then $matrice[2][3] = 1 GUICtrlSetData($buton[6], "X") TCPSend($ConnectedSocket, "muta<|*|>6") $mut = 0 verifica() EndIf EndFunc ;==>buton_6Click Func buton_7Click() If $mut = 0 Then Return If $matrice[3][1] = 0 Then $matrice[3][1] = 1 GUICtrlSetData($buton[7], "X") TCPSend($ConnectedSocket, "muta<|*|>7") $mut = 0 verifica() EndIf EndFunc ;==>buton_7Click Func buton_8Click() If $mut = 0 Then Return If $matrice[3][2] = 0 Then $matrice[3][2] = 1 GUICtrlSetData($buton[8], "X") TCPSend($ConnectedSocket, "muta<|*|>8") $mut = 0 verifica() EndIf EndFunc ;==>buton_8Click Func buton_9Click() If $mut = 0 Then Return If $matrice[3][3] = 0 Then $matrice[3][3] = 1 GUICtrlSetData($buton[9], "X") TCPSend($ConnectedSocket, "muta<|*|>9") $mut = 0 verifica() EndIf EndFunc ;==>buton_9Click Func verifica() If ((GUICtrlRead($buton[1]) = GUICtrlRead($buton[2])) And (GUICtrlRead($buton[2]) = GUICtrlRead($buton[3])) And (GUICtrlRead($buton[1]) <> "") And (GUICtrlRead($buton[2]) <> "") And (GUICtrlRead($buton[3]) <> "")) Then GUICtrlSetColor($buton[1], 0xff0000) GUICtrlSetColor($buton[2], 0xff0000) GUICtrlSetColor($buton[3], 0xff0000) If GUICtrlRead($buton[1]) = "X" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[4]) = GUICtrlRead($buton[5])) And (GUICtrlRead($buton[5]) = GUICtrlRead($buton[6])) And (GUICtrlRead($buton[4]) <> "") And (GUICtrlRead($buton[5]) <> "") And (GUICtrlRead($buton[6]) <> "")) Then GUICtrlSetColor($buton[4], 0xff0000) GUICtrlSetColor($buton[5], 0xff0000) GUICtrlSetColor($buton[6], 0xff0000) If GUICtrlRead($buton[4]) = "X" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[7]) = GUICtrlRead($buton[8])) And (GUICtrlRead($buton[8]) = GUICtrlRead($buton[9])) And (GUICtrlRead($buton[7]) <> "") And (GUICtrlRead($buton[8]) <> "") And (GUICtrlRead($buton[9]) <> "")) Then GUICtrlSetColor($buton[7], 0xff0000) GUICtrlSetColor($buton[8], 0xff0000) GUICtrlSetColor($buton[9], 0xff0000) If GUICtrlRead($buton[7]) = "X" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[1]) = GUICtrlRead($buton[4])) And (GUICtrlRead($buton[4]) = GUICtrlRead($buton[7])) And (GUICtrlRead($buton[1]) <> "") And (GUICtrlRead($buton[4]) <> "") And (GUICtrlRead($buton[7]) <> "")) Then GUICtrlSetColor($buton[1], 0xff0000) GUICtrlSetColor($buton[4], 0xff0000) GUICtrlSetColor($buton[7], 0xff0000) If GUICtrlRead($buton[1]) = "X" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[2]) = GUICtrlRead($buton[5])) And (GUICtrlRead($buton[5]) = GUICtrlRead($buton[8])) And (GUICtrlRead($buton[2]) <> "") And (GUICtrlRead($buton[5]) <> "") And (GUICtrlRead($buton[8]) <> "")) Then GUICtrlSetColor($buton[2], 0xff0000) GUICtrlSetColor($buton[5], 0xff0000) GUICtrlSetColor($buton[8], 0xff0000) If GUICtrlRead($buton[2]) = "X" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[3]) = GUICtrlRead($buton[6])) And (GUICtrlRead($buton[6]) = GUICtrlRead($buton[9])) And (GUICtrlRead($buton[3]) <> "") And (GUICtrlRead($buton[6]) <> "") And (GUICtrlRead($buton[9]) <> "")) Then GUICtrlSetColor($buton[3], 0xff0000) GUICtrlSetColor($buton[6], 0xff0000) GUICtrlSetColor($buton[9], 0xff0000) If GUICtrlRead($buton[3]) = "X" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[1]) = GUICtrlRead($buton[5])) And (GUICtrlRead($buton[5]) = GUICtrlRead($buton[9])) And (GUICtrlRead($buton[1]) <> "") And (GUICtrlRead($buton[5]) <> "") And (GUICtrlRead($buton[9]) <> "")) Then GUICtrlSetColor($buton[1], 0xff0000) GUICtrlSetColor($buton[5], 0xff0000) GUICtrlSetColor($buton[9], 0xff0000) If GUICtrlRead($buton[1]) = "X" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[3]) = GUICtrlRead($buton[5])) And (GUICtrlRead($buton[5]) = GUICtrlRead($buton[7])) And (GUICtrlRead($buton[3]) <> "") And (GUICtrlRead($buton[5]) <> "") And (GUICtrlRead($buton[7]) <> "")) Then GUICtrlSetColor($buton[3], 0xff0000) GUICtrlSetColor($buton[5], 0xff0000) GUICtrlSetColor($buton[7], 0xff0000) If GUICtrlRead($buton[3]) = "X" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf $x = 0 For $i = 1 To 3 For $j = 1 To 3 If $matrice[$i][$j] = 1 Then $x = $x + 1 EndIf Next Next If $x = 9 Then MsgBox(0, "$program_nume$ v$program_versiune$", "Remiza") meniu_joc_nou() EndIf EndFunc ;==>verifica Func SocketToIP($SHOCKET) Local $sockaddr = DllStructCreate("short;ushort;uint;char[8]") Local $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _ "ptr", DllStructGetPtr($sockaddr), "int_ptr", DllStructGetSize($sockaddr)) If Not @error And $aRet[0] = 0 Then $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3)) If Not @error Then $aRet = $aRet[0] Else $aRet = 0 EndIf $sockaddr = 0 Return $aRet EndFunc ;==>SocketToIP Func primeste($recv) ;~ MsgBox(0,"",$recv) $data = StringSplit($recv, "<|*|>", 1) Switch $data[1] Case "nume" $nick = $data[2] TCPSend($ConnectedSocket, "nume<|*|>$nume$") Case "muta" GUICtrlSetData($buton[$data[2]], "0") Switch $data[2] Case "1" $matrice[1][1] = 1 Case "2" $matrice[1][2] = 1 Case "3" $matrice[1][3] = 1 Case "4" $matrice[2][1] = 1 Case "5" $matrice[2][2] = 1 Case "6" $matrice[2][3] = 1 Case "7" $matrice[3][1] = 1 Case "8" $matrice[3][2] = 1 Case "9" $matrice[3][3] = 1 EndSwitch $mut = 1 verifica() Case "joc_nou" joc_nou() EndSwitch EndFunc ;==>primeste Func meniu_joc_nou() TCPSend($ConnectedSocket, "joc_nou") joc_nou() EndFunc ;==>meniu_joc_nou Func joc_nou() $mut = 1 For $i = 1 To 3 For $j = 1 To 3 $matrice[$i][$j] = 0 Next Next For $i = 1 To 9 GUICtrlSetData($buton[$i], "") GUICtrlSetColor($buton[$i], 0x000000) Next EndFunc ;==>joc_nou X&0 - Client CODE#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Opt("ExpandVarStrings", 1) Global $matrice[10][10], $server = "", $nume = "", $mut = 0, $nick = "" Global $program_nume = "X&0 SL" Global $program_versiune = "0.7" Dim $buton[10] HotKeySet("{F2}", "meniu_joc_nou") $server = InputBox("Alege un server.", "Ip-ul server : ", @IPAddress1, "", 120, 25, -1, -1) If @error Then Exit $nr_ip = StringSplit($server, ".") If $nr_ip[0] <> 4 Then MsgBox(0, "$program_nume$ v$program_versiune$", "Ip-ul nu este corect") Exit EndIf For $i = 1 To 4 If (($nr_ip[$i] > 255) Or ($nr_ip[$i] < 0)) Then MsgBox(0, "$program_nume$ v$program_versiune$", "Ip-ul nu este corect") Exit EndIf Next $nume = "" While $nume = "" $nume = InputBox("Alege un nick.", "Nick : ", "", "", 120, 25, -1, -1) WEnd TCPStartup() Dim $szIPADDRESS = $server $nPORT = "1234" $ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT) If @error = 0 Then $szData = "nume<|*|>$nume$" TCPSend($ConnectedSocket, $szData) EndIf For $i = 1 To 3 For $j = 1 To 3 $matrice[$i][$j] = 0 Next Next $form_principal = GUICreate("$program_nume$ v$program_versiune$ - Client", 170, 285, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "form_principalClose") $Group1 = GUICtrlCreateGroup("Tabla de joc", 6, 16, 160, 183) $buton[1] = GUICtrlCreateButton("", 12, 36, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "boton_1Click") $buton[2] = GUICtrlCreateButton("", 63, 36, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_2Click") $buton[3] = GUICtrlCreateButton("", 114, 36, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_3Click") $buton[4] = GUICtrlCreateButton("", 12, 88, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_4Click") $buton[5] = GUICtrlCreateButton("", 63, 88, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_5Click") $buton[6] = GUICtrlCreateButton("", 114, 88, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_6Click") $buton[7] = GUICtrlCreateButton("", 12, 141, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_7Click") $buton[8] = GUICtrlCreateButton("", 63, 141, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_8Click") $buton[9] = GUICtrlCreateButton("", 114, 141, 40, 40, 0) GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman") GUICtrlSetOnEvent(-1, "buton_9Click") GUICtrlCreateGroup("", -99, -99, 1, 1) $fisier = GUICtrlCreateMenu("Fisier") $fisier_nou = GUICtrlCreateMenuItem("&Nou ", $fisier) GUICtrlSetOnEvent(-1, "meniu_joc_nou") $fisier_iesire = GUICtrlCreateMenuItem("Iesire", $fisier) $ajutor = GUICtrlCreateMenu("Ajutor") $ajutor_ajutor = GUICtrlCreateMenuItem("Ajutor", $ajutor) $ajutor_despre = GUICtrlCreateMenuItem("Despre", $ajutor) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) $recv = TCPRecv($ConnectedSocket, 2048) If @error Then TCPCloseSocket($ConnectedSocket) TCPShutdown() TCPStartup() $MainSocket = TCPListen($szIPADDRESS, $nPORT, 100) Dim $ConnectedSocket = -1 Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 $szIP_Accepted = SocketToIP ($ConnectedSocket) EndIf If $recv <> "" Then primeste($recv) WEnd Func form_principalClose() Exit EndFunc ;==>form_principalClose Func boton_1Click() If $mut = 0 Then Return If $matrice[1][1] = 0 Then $matrice[1][1] = 1 GUICtrlSetData($buton[1], "0") TCPSend($ConnectedSocket, "muta<|*|>1") $mut = 0 verifica() EndIf EndFunc ;==>boton_1Click Func buton_2Click() If $mut = 0 Then Return If $matrice[1][2] = 0 Then $matrice[1][2] = 1 GUICtrlSetData($buton[2], "0") TCPSend($ConnectedSocket, "muta<|*|>2") $mut = 0 verifica() EndIf EndFunc ;==>buton_2Click Func buton_3Click() If $mut = 0 Then Return If $matrice[1][3] = 0 Then $matrice[1][3] = 1 GUICtrlSetData($buton[3], "0") TCPSend($ConnectedSocket, "muta<|*|>3") $mut = 0 verifica() EndIf EndFunc ;==>buton_3Click Func buton_4Click() If $mut = 0 Then Return If $matrice[2][1] = 0 Then $matrice[2][1] = 1 GUICtrlSetData($buton[4], "0") TCPSend($ConnectedSocket, "muta<|*|>4") $mut = 0 verifica() EndIf EndFunc ;==>buton_4Click Func buton_5Click() If $mut = 0 Then Return If $matrice[2][2] = 0 Then $matrice[2][2] = 1 GUICtrlSetData($buton[5], "0") TCPSend($ConnectedSocket, "muta<|*|>5") $mut = 0 verifica() EndIf EndFunc ;==>buton_5Click Func buton_6Click() If $mut = 0 Then Return If $matrice[2][3] = 0 Then $matrice[2][3] = 1 GUICtrlSetData($buton[6], "0") TCPSend($ConnectedSocket, "muta<|*|>6") $mut = 0 verifica() EndIf EndFunc ;==>buton_6Click Func buton_7Click() If $mut = 0 Then Return If $matrice[3][1] = 0 Then $matrice[3][1] = 1 GUICtrlSetData($buton[7], "0") TCPSend($ConnectedSocket, "muta<|*|>7") $mut = 0 verifica() EndIf EndFunc ;==>buton_7Click Func buton_8Click() If $mut = 0 Then Return If $matrice[3][2] = 0 Then $matrice[3][2] = 1 GUICtrlSetData($buton[8], "0") TCPSend($ConnectedSocket, "muta<|*|>8") $mut = 0 verifica() EndIf EndFunc ;==>buton_8Click Func buton_9Click() If $mut = 0 Then Return If $matrice[3][3] = 0 Then $matrice[3][3] = 1 GUICtrlSetData($buton[9], "0") TCPSend($ConnectedSocket, "muta<|*|>9") $mut = 0 verifica() EndIf EndFunc ;==>buton_9Click Func verifica() If ((GUICtrlRead($buton[1]) = GUICtrlRead($buton[2])) And (GUICtrlRead($buton[2]) = GUICtrlRead($buton[3])) And (GUICtrlRead($buton[1]) <> "") And (GUICtrlRead($buton[2]) <> "") And (GUICtrlRead($buton[3]) <> "")) Then GUICtrlSetColor($buton[1], 0xff0000) GUICtrlSetColor($buton[2], 0xff0000) GUICtrlSetColor($buton[3], 0xff0000) If GUICtrlRead($buton[1]) = "0" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[4]) = GUICtrlRead($buton[5])) And (GUICtrlRead($buton[5]) = GUICtrlRead($buton[6])) And (GUICtrlRead($buton[4]) <> "") And (GUICtrlRead($buton[5]) <> "") And (GUICtrlRead($buton[6]) <> "")) Then GUICtrlSetColor($buton[4], 0xff0000) GUICtrlSetColor($buton[5], 0xff0000) GUICtrlSetColor($buton[6], 0xff0000) If GUICtrlRead($buton[4]) = "0" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[7]) = GUICtrlRead($buton[8])) And (GUICtrlRead($buton[8]) = GUICtrlRead($buton[9])) And (GUICtrlRead($buton[7]) <> "") And (GUICtrlRead($buton[8]) <> "") And (GUICtrlRead($buton[9]) <> "")) Then GUICtrlSetColor($buton[7], 0xff0000) GUICtrlSetColor($buton[8], 0xff0000) GUICtrlSetColor($buton[9], 0xff0000) If GUICtrlRead($buton[7]) = "0" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[1]) = GUICtrlRead($buton[4])) And (GUICtrlRead($buton[4]) = GUICtrlRead($buton[7])) And (GUICtrlRead($buton[1]) <> "") And (GUICtrlRead($buton[4]) <> "") And (GUICtrlRead($buton[7]) <> "")) Then GUICtrlSetColor($buton[1], 0xff0000) GUICtrlSetColor($buton[4], 0xff0000) GUICtrlSetColor($buton[7], 0xff0000) If GUICtrlRead($buton[1]) = "0" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[2]) = GUICtrlRead($buton[5])) And (GUICtrlRead($buton[5]) = GUICtrlRead($buton[8])) And (GUICtrlRead($buton[2]) <> "") And (GUICtrlRead($buton[5]) <> "") And (GUICtrlRead($buton[8]) <> "")) Then GUICtrlSetColor($buton[2], 0xff0000) GUICtrlSetColor($buton[5], 0xff0000) GUICtrlSetColor($buton[8], 0xff0000) If GUICtrlRead($buton[2]) = "0" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[3]) = GUICtrlRead($buton[6])) And (GUICtrlRead($buton[6]) = GUICtrlRead($buton[9])) And (GUICtrlRead($buton[3]) <> "") And (GUICtrlRead($buton[6]) <> "") And (GUICtrlRead($buton[9]) <> "")) Then GUICtrlSetColor($buton[3], 0xff0000) GUICtrlSetColor($buton[6], 0xff0000) GUICtrlSetColor($buton[9], 0xff0000) If GUICtrlRead($buton[3]) = "0" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[1]) = GUICtrlRead($buton[5])) And (GUICtrlRead($buton[5]) = GUICtrlRead($buton[9])) And (GUICtrlRead($buton[1]) <> "") And (GUICtrlRead($buton[5]) <> "") And (GUICtrlRead($buton[9]) <> "")) Then GUICtrlSetColor($buton[1], 0xff0000) GUICtrlSetColor($buton[5], 0xff0000) GUICtrlSetColor($buton[9], 0xff0000) If GUICtrlRead($buton[1]) = "0" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf If ((GUICtrlRead($buton[3]) = GUICtrlRead($buton[5])) And (GUICtrlRead($buton[5]) = GUICtrlRead($buton[7])) And (GUICtrlRead($buton[3]) <> "") And (GUICtrlRead($buton[5]) <> "") And (GUICtrlRead($buton[7]) <> "")) Then GUICtrlSetColor($buton[3], 0xff0000) GUICtrlSetColor($buton[5], 0xff0000) GUICtrlSetColor($buton[7], 0xff0000) If GUICtrlRead($buton[3]) = "0" Then $castigator = $nume Else $castigator = $nick EndIf MsgBox(0, "$program_nume$ v$program_versiune$", "A castigat $castigator$") meniu_joc_nou() EndIf $x = 0 For $i = 1 To 3 For $j = 1 To 3 If $matrice[$i][$j] = 1 Then $x = $x + 1 EndIf Next Next If $x = 9 Then MsgBox(0, "$program_nume$ v$program_versiune$", "Remiza") meniu_joc_nou() EndIf EndFunc ;==>verifica Func primeste($recv) ;~ MsgBox(0,"",$recv) $data = StringSplit($recv, "<|*|>", 1) Switch $data[1] Case "nume" $nick = $data[2] Case "muta" GUICtrlSetData($buton[$data[2]], "X") Switch $data[2] Case "1" $matrice[1][1] = 1 Case "2" $matrice[1][2] = 1 Case "3" $matrice[1][3] = 1 Case "4" $matrice[2][1] = 1 Case "5" $matrice[2][2] = 1 Case "6" $matrice[2][3] = 1 Case "7" $matrice[3][1] = 1 Case "8" $matrice[3][2] = 1 Case "9" $matrice[3][3] = 1 EndSwitch $mut = 1 verifica() Case "joc_nou" joc_nou() EndSwitch EndFunc ;==>primeste Func meniu_joc_nou() TCPSend($ConnectedSocket, "joc_nou") joc_nou() EndFunc ;==>meniu_joc_nou Func joc_nou() $mut = 0 For $i = 1 To 3 For $j = 1 To 3 $matrice[$i][$j] = 0 Next Next For $i = 1 To 9 GUICtrlSetData($buton[$i], "") GUICtrlSetColor($buton[$i], 0x000000) Next EndFunc ;==>joc_nou Link to comment Share on other sites More sharing options...
Nahuel Posted September 25, 2007 Author Share Posted September 25, 2007 ^Cool! I'll try it Updated mine, highly improved! Please tell me what you think Link to comment Share on other sites More sharing options...
jvanegmond Posted September 25, 2007 Share Posted September 25, 2007 Great job on the new AI!! I was playing like I was before and now the bot beat me 3-1 .. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Achilles Posted September 25, 2007 Share Posted September 25, 2007 Great work on this! This seems to be a habit of mine concerning your ideas, but I was making one of these but got bored of it. Technically I think you could make a bot that would never lose. And if the user plays right they should never lose either. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Nahuel Posted September 25, 2007 Author Share Posted September 25, 2007 Great job on the new AI!! I was playing like I was before and now the bot beat me 3-1 .. haha, I'm a sucker for Tic Tac Toe, but making this made me learn lots of tricks for winning. My next step will be to add 'tricks' that the bot can perform to ensure victory Great work on this! This seems to be a habit of mine concerning your ideas, but I was making one of these but got bored of it. Technically I think you could make a bot that would never lose. And if the user plays right they should never lose either.Thank you. As I said to Manadar, my next step will be to add tricks for the bot to make it even harder to beat, it's not really that hard. I've been thinking of ways to do this. Link to comment Share on other sites More sharing options...
enaiman Posted September 26, 2007 Share Posted September 26, 2007 Great Job Nahuel (said it in the other thread but you deserve it anyway) You can use anything you want from my script anytime. I just felt "challenged" by this idea. This is a game that can be never won if the players play correctly. Because of the large number of situations I couldn't fully test it but yourself and others helped me. My aim was to make it unbeatable - I hope I succeded now (I think it can handle now all those "corner" patterns) SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Valuater Posted September 26, 2007 Share Posted September 26, 2007 I can't believe you didn't use my "shorter" code it was more direct than yours and cut out duplicated stuff 8) Link to comment Share on other sites More sharing options...
Nahuel Posted September 26, 2007 Author Share Posted September 26, 2007 Great Job Nahuel (said it in the other thread but you deserve it anyway)You can use anything you want from my script anytime. I just felt "challenged" by this idea. This is a game that can be never won if the players play correctly.Because of the large number of situations I couldn't fully test it but yourself and others helped me. My aim was to make it unbeatable - I hope I succeded now (I think it can handle now all those "corner" patterns)Thanks, but mine isn't unbeatable... I was planning on modifying it and make it less random but watching that it still looks 'natural'.I can't believe you didn't use my "shorter" codeit was more direct than yours and cut out duplicated stuff8)Yes, I'm going to Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now