Tic Tac
0
Posted by admin | Posted in Uncategorized | Posted on 22-08-2006
Tags: blog, educación, recursos, tic, tic tac, tic tac toe, tic tac toe game, tic tac toe online, tic tac toe strategy
Tic Tac
![]() |
![]() 15 $1 3 Single Pks of Tic Tac Mints Can Double snacks candy US $2.25
|
![]() 25 Kids Party Loot Goodies Bags PInata Fillers Toys Birthday Favours Gifts US $6.31
|
![]() ADULT TIC TAC TOE DRINKING GAME US $3.99
|
![]() TIC TAC TOE SHOT GLASS SET US $2.00
|
![]() EXECUTIVE TIC TAC TOE FOR HOME OR OFFICE WOOD BRASS US $18.50
|
![]() Milwaukee 4932352975 Shockwave 50mm PH2 Pozi Screwdriver Drill Bits x10 US $20.53
|
![]() TICTAC Mints Breast Cancer Awareness PINK RIBBON New UNOPENED US $.01
|
![]() Tic Tac Freshmints Breath Mint 12 count Pack tictac US $13.49
|
![]() Squirrel TIC TAC TOE US $5.00
|
![]() Tortoise Hare Tic Tac Toe Garden Figurines US $22.99
|
![]() Tic Tac Mints WINTERGREEN 24 BIG Paks TicTacs TicTac US $37.30
|
![]() TIC TAC TOE GAME DECORATIVE DUCK HUNTERS FREE SHIPPING US $15.00
|
![]() Personalized TEAM UMIZOOMI Lollipop Sticker Tag Labels US $2.00
|
![]() AMERICAN MINT ASSORTMENT TIC TAC MINTS 21 Packs 7 Flavors 3 Each US $34.30
|
![]() Baby Snoopy Cute Baby Shower Invitations US $7.50
|
![]() Personalized HELLO KITTY Lollipop Sticker Tag Labels US $2.00
|
![]() Personalized Wedding Bridal Shower Nugget Candy Bar Wrappers Favors US $4.49
|
![]() 10 Coupons Save $1 3 Single Tic Tac Mints US $2.01
|
![]() 14 Cap Diploma Graduation Tic Tac Labels Several Colors US $2.00
|
![]() Birthday 1st Birthday MINNIE MOUSE WATER BOTTLE LABELS US $12.99
|
![]() Birthday Super Mario Brothers WATER BOTTLE LABELS US $22.99
|
![]() Tic Tac Green Apple Flavor 12 Big Packs 1oz American Mini Mints Candy US $19.15
|
![]() Large Care Bear Unstuffed Pillows ALL FOUR US $15.00
|
![]() Tic Tac Toe Drinking Game Perfect party game US $7.99
|
![]() Bachelorette Party Tic Tac Party Favor Labels Cute US $2.70
|
![]() Personalized DORA Birthday Lollipop Sticker Tag Labels US $2.00
|
Simple Tic-tac-toe Game Logic
n this article I will discuss about a very simple game. Yes, it is a Tic-Tak-Toe game of 3X3 dimension. It is a very simple game and I believe each and every one knows the rules of this game. So I am not going to mention anything about the game rules here. This article also gives you an idea about AI (Artificial Inelegancy) used in computer game. It is like giving thinking ability to you PC.
In this game you can play against computer. That is man vs. computer. The game is developed in VB6.0 and coded in very easy way to make the algorithm easy to understand. There are comments for each chunk of code which acts like a particular AI or games rule. I hope anyone can understand what I am going to do seeing the codes and comments. I used some Matrix formula to calculate/ find next move after a Human move.
Here is the complete listing of source code.
Private Sub Command1_Click(Index As Integer)
If Command1(Index).Caption = "" Then
Command1(Index).Caption = "X"
Call computer
Call win
Else
Beep
End If
End Sub
Public Sub computer()
Dim i, numb1, numb0, cou1, cou2 As Integer
'************CALCULATE THE NUMBER OF "X"************
For i = 0 To 8
If Command1(i).Caption = "X" Then
numb1 = numb1 + 1
End If
Next i
'*****************WIN OPPERTUNITY************
If (Command1(0).Caption = "O" And Command1(1).Caption = "O" And Command1(2).Caption = "") Then
Command1(2).Caption = "O"
Exit Sub
End If
If (Command1(0).Caption = "O" And Command1(2).Caption = "O" And Command1(1).Caption = "") Then
Command1(1).Caption = "O"
Exit Sub
End If
If (Command1(0).Caption = "O" And Command1(3).Caption = "O" And Command1(6).Caption = "") Then
Command1(6).Caption = "O"
Exit Sub
End If
If (Command1(0).Caption = "O" And Command1(6).Caption = "O" And Command1(3).Caption = "") Then
Command1(3).Caption = "O"
Exit Sub
End If
'****************************************
If (Command1(8).Caption = "O" And Command1(5).Caption = "O" And Command1(2).Caption = "") Then
Command1(2).Caption = "O"
Exit Sub
End If
If (Command1(8).Caption = "O" And Command1(2).Caption = "O" And Command1(5).Caption = "") Then
Command1(5).Caption = "O"
Exit Sub
End If
If (Command1(8).Caption = "O" And Command1(7).Caption = "O" And Command1(6).Caption = "") Then
Command1(6).Caption = "O"
Exit Sub
End If
If (Command1(8).Caption = "O" And Command1(6).Caption = "O" And Command1(7).Caption = "") Then
Command1(7).Caption = "O"
Exit Sub
End If
'********************************
If (Command1(6).Caption = "O" And Command1(7).Caption = "O" And Command1(8).Caption = "") Then
Command1(8).Caption = "O"
Exit Sub
End If
If (Command1(6).Caption = "O" And Command1(3).Caption = "O" And Command1(0).Caption = "") Then
Command1(0).Caption = "O"
Exit Sub
End If
'*****************************************
If (Command1(2).Caption = "O" And Command1(1).Caption = "O" And Command1(0).Caption = "") Then
Command1(0).Caption = "O"
Exit Sub
End If
If (Command1(2).Caption = "O" And Command1(5).Caption = "O" And Command1(8).Caption = "") Then
Command1(8).Caption = "O"
Exit Sub
End If
'***************LOGICS IF THE CENTER BOX CONTAIN "O"***********
If Command1(4).Caption = "O" Then
'*********************CROSS(X) LOGICS*****************
For q = 0 To 8 Step 2
If q = 4 Then
GoTo 2
End If
If Command1(q).Caption = "O" Then
n = 4 * 2 - q
If Command1(n).Caption = "" Then
Command1(n).Caption = "O"
Exit Sub
End If
End If
2 Next q
'*********************PLUSE(+) LOGICS*****************
For w = 1 To 7 Step 2
If w = 4 Then
GoTo 4
End If
If Command1(w).Caption = "O" Then
n = 4 * 2 - w
If Command1(n).Caption = "" Then
Command1(n).Caption = "O"
Exit Sub
End If
End If
4 Next w
End If
'************************PROCTECT GAME***********************
If (Command1(0).Caption = "X" And Command1(1).Caption = "X" And Command1(2).Caption = "") Then
Command1(2).Caption = "O"
Exit Sub
End If
If (Command1(0).Caption = "X" And Command1(2).Caption = "X" And Command1(1).Caption = "") Then
Command1(1).Caption = "O"
Exit Sub
End If
If (Command1(0).Caption = "X" And Command1(3).Caption = "X" And Command1(6).Caption = "") Then
Command1(6).Caption = "O"
Exit Sub
End If
If (Command1(0).Caption = "X" And Command1(6).Caption = "X" And Command1(3).Caption = "") Then
Command1(3).Caption = "O"
Exit Sub
End If
'****************************************
If (Command1(8).Caption = "X" And Command1(5).Caption = "X" And Command1(2).Caption = "") Then
Command1(2).Caption = "O"
Exit Sub
End If
If (Command1(8).Caption = "X" And Command1(2).Caption = "X" And Command1(5).Caption = "") Then
Command1(5).Caption = "O"
Exit Sub
End If
If (Command1(8).Caption = "X" And Command1(7).Caption = "X" And Command1(6).Caption = "") Then
Command1(6).Caption = "O"
Exit Sub
End If
If (Command1(8).Caption = "X" And Command1(6).Caption = "X" And Command1(7).Caption = "") Then
Command1(7).Caption = "O"
Exit Sub
End If
If (Command1(1).Caption = "X" And Command1(2).Caption = "X" And Command1(0).Caption = "") Then
Command1(0).Caption = "O"
Exit Sub
End If
If (Command1(6).Caption = "X" And Command1(7).Caption = "X" And Command1(8).Caption = "") Then
Command1(8).Caption = "O"
Exit Sub
End If
If (Command1(2).Caption = "X" And Command1(5).Caption = "X" And Command1(8).Caption = "") Then
Command1(8).Caption = "O"
Exit Sub
End If
If (Command1(3).Caption = "X" And Command1(6).Caption = "X" And Command1(0).Caption = "") Then
Command1(0).Caption = "O"
Exit Sub
End If
'**************PUT "O" IN CENTER BOX IF BLANK****************
If (numb1 = 1 And Command1(4).Caption = "") Then
Command1(4).Caption = "O"
Exit Sub
End If
'***************LOGICS IF THE CENTER BOX CONTAIN "X"***********
If Command1(4).Caption = "X" Then
'*********************CROSS(X) LOGICS*****************
For q = 0 To 8 Step 2
If q = 4 Then
GoTo 5
End If
If Command1(q).Caption = "X" Then
n = 4 * 2 - q
If Command1(n).Caption = "" Then
Command1(n).Caption = "O"
Exit Sub
End If
End If
5 Next q
'*********************PLUSE(+) LOGICS*****************
For q = 1 To 7 Step 2
If q = 4 Then
GoTo 6
End If
If Command1(q).Caption = "X" Then
n = 4 * 2 - q
If Command1(n).Caption = "" Then
Command1(n).Caption = "O"
Exit Sub
End If
End If
6 Next q
If Command1(0).Caption = "" Then
Command1(0).Caption = "O"
Exit Sub
End If
If Command1(2).Caption = "" Then
Command1(2).Caption = "O"
Exit Sub
End If
If Command1(6).Caption = "" Then
Command1(6).Caption = "O"
Exit Sub
End If
If Command1(8).Caption = "" Then
Command1(8).Caption = "O"
Exit Sub
End If
End If
'*******************MASTER LOGICS(1)*********
If (Command1(3).Caption = "X" And Command1(1).Caption = "X") Then
If Command1(0).Caption = "" Then
Command1(0).Caption = "O"
Exit Sub
End If
End If
If (Command1(1).Caption = "X" And Command1(5).Caption = "X") Then
If Command1(2).Caption = "" Then
Command1(2).Caption = "O"
Exit Sub
End If
End If
If (Command1(5).Caption = "X" And Command1(7).Caption = "X") Then
If Command1(8).Caption = "" Then
Command1(8).Caption = "O"
Exit Sub
End If
End If
If (Command1(3).Caption = "X" And Command1(7).Caption = "X") Then
If Command1(6).Caption = "" Then
Command1(6).Caption = "O"
Exit Sub
End If
End If
'************************master logics(2)***************
If (Command1(3).Caption = "X") Then
If Command1(2).Caption = "X" And Command1(0).Caption = "" Then
Command1(0).Caption = "O"
Exit Sub
End If
If Command1(8).Caption = "X" And Command1(6).Caption = "" Then
Command1(6).Caption = "O"
Exit Sub
End If
End If
If (Command1(5).Caption = "X") Then
If Command1(0).Caption = "X" And Command1(2).Caption = "" Then
Command1(2).Caption = "O"
Exit Sub
End If
If Command1(6).Caption = "X" And Command1(8).Caption = "" Then
Command1(8).Caption = "O"
Exit Sub
End If
End If
If (Command1(7).Caption = "X") Then
If Command1(0).Caption = "X" And Command1(6).Caption = "" Then
Command1(6).Caption = "O"
Exit Sub
End If
If Command1(2).Caption = "X" And Command1(8).Caption = "" Then
Command1(8).Caption = "O"
Exit Sub
End If
End If
If (Command1(1).Caption = "X") Then
If Command1(6).Caption = "X" And Command1(0).Caption = "" Then
Command1(0).Caption = "O"
Exit Sub
End If
If Command1(8).Caption = "X" And Command1(2).Caption = "" Then
Command1(2).Caption = "O"
Exit Sub
End If
End If
'**********************************************
If (numb1 = 5) Then
MsgBox "*****Game over*****"
Call newer
GoTo 10
End If
'*************Master Logics(1)*****************
For K = 1 To 7 Step 2
If Command1(4).Caption = "O" And Command1(K).Caption = "" Then
Command1(K).Caption = "O"
Exit Sub
End If
Next K
8 cou1 = Int(Rnd * 9)
If Command1(cou1).Caption = "" Then
Command1(cou1).Caption = "O"
Else
GoTo 8
End If
10 End Sub
Private Sub exit_Click()
End
End Sub
Private Sub Form_Load()
Open "C:WIN.TXT" For Append As #1
Close #1
End Sub
Private Sub new_Click()
Call newer
End Sub
Public Sub win()
'**********************YOU WIN*************
If (Command1(1).Caption = "X" And Command1(0).Caption = "X" And Command1(2).Caption = "X") Then
MsgBox "***You win***"
Call newer
End If
If (Command1(0).Caption = "X" And Command1(4).Caption = "X" And Command1(8).Caption = "X") Then
MsgBox "***You win***"
Call newer
End If
If (Command1(0).Caption = "X" And Command1(3).Caption = "X" And Command1(6).Caption = "X") Then
MsgBox "***You win***"
Call newer
End If
If (Command1(1).Caption = "X" And Command1(4).Caption = "X" And Command1(7).Caption = "X") Then
MsgBox "***You win***"
Call newer
End If
If (Command1(2).Caption = "X" And Command1(5).Caption = "X" And Command1(8).Caption = "X") Then
MsgBox "***You win***"
Call newer
End If
If (Command1(3).Caption = "X" And Command1(4).Caption = "X" And Command1(5).Caption = "X") Then
MsgBox "***You win***"
Call newer
End If
If (Command1(6).Caption = "X" And Command1(7).Caption = "X" And Command1(8).Caption = "X") Then
MsgBox "***You win***"
Call newer
End If
If (Command1(6).Caption = "X" And Command1(4).Caption = "X" And Command1(2).Caption = "X") Then
MsgBox "***You win***"
Call newer
End If
'*****************YOU LOST*************
If (Command1(1).Caption = "O" And Command1(0).Caption = "O" And Command1(2).Caption = "O") Then
MsgBox "***You loset***"
Call newer
End If
If (Command1(4).Caption = "O" And Command1(0).Caption = "O" And Command1(8).Caption = "O") Then
MsgBox "***You loset***"
Call newer
End If
If (Command1(3).Caption = "O" And Command1(0).Caption = "O" And Command1(6).Caption = "O") Then
MsgBox "***You loset***"
Call newer
End If
If (Command1(1).Caption = "O" And Command1(4).Caption = "O" And Command1(7).Caption = "O") Then
MsgBox "***You loset***"
Call newer
End If
If (Command1(2).Caption = "O" And Command1(5).Caption = "O" And Command1(8).Caption = "O") Then
MsgBox "***You loset***"
Call newer
End If
If (Command1(3).Caption = "O" And Command1(4).Caption = "O" And Command1(5).Caption = "O") Then
MsgBox "***You loset***"
Call newer
End If
If (Command1(6).Caption = "O" And Command1(7).Caption = "O" And Command1(8).Caption = "O") Then
MsgBox "***You loset***"
Call newer
End If
If (Command1(6).Caption = "O" And Command1(4).Caption = "O" And Command1(2).Caption = "O") Then
MsgBox "***You loset***"
Call newer
End If
End Sub
Public Sub newer()
For i = 0 To 8
Command1(i).Caption = ""
Next i
End Sub
Download the project from BD Experts site
About the Author
I am basically a Application/web developer. Microsoft technology is my working tool. I am interested with new advance technologies of programming and database. I am also running a website http://www.bd-experts.com which is mostly a article sharing website.
How do you play shot glass tic-tac-toe?
hi =)
i have a shot glass tic tac toe game. i know how to play regular tic tac toe, but not the shot glass one. how do you know when to take a shot?
I'm not exactly sure but maybe the loser takes a shot or maybe it'd make more sense for the winner to take a shot? I have no clue, sorry! I tried!



US $5.75
















































