[VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe
Go Back  Xtreme Visual Basic Talk > > > [VB6] - teaching pc playing tic-tac-toe


Reply
 
Thread Tools Display Modes
  #1  
Old 11-01-2010, 06:42 AM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default [VB6] - teaching pc playing tic-tac-toe


i'm teaching my pc play tic-tac-toe game. but see these line:
Code:
 ElseIf intPlayerGame(2) = 1 And intPlayerGame(5) = 1 And intPlayersGamed(8) = 0 Then
        intComputerGameBoard = 8
intPlayerGame(X)=1 'if the player 1 played here
intPlayersGamed(8) = 0 'if someones players here. zero means not played.
intComputerGameBoard = 8 'for tell the pc for play here.
but why these line is ignored?
i know these because, when i try do the vertical line, i, always, win.
(the text file gives you the entire if statement.)
Attached Files
File Type: txt how i teach my pc.txt (6.2 KB, 13 views)
Reply With Quote
  #2  
Old 11-01-2010, 07:55 PM
elemein elemein is offline
Newcomer
 
Join Date: Oct 2010
Posts: 14
Default

Those are some freaky lines. But question-

Why are you trying to lead your computer to win? If you're telling it to just win, then it wont bother blocking you- it'll just try to win on it's own, and not block you.
Reply With Quote
  #3  
Old 11-02-2010, 02:07 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

Quote:
Originally Posted by elemein View Post
Those are some freaky lines. But question-

Why are you trying to lead your computer to win? If you're telling it to just win, then it wont bother blocking you- it'll just try to win on it's own, and not block you.
to be honest the pc do the 2 ways(win and block)
"Those are some freaky lines" what you mean by these?
(i'm portuguese)
Reply With Quote
  #4  
Old 11-02-2010, 06:31 PM
elemein elemein is offline
Newcomer
 
Join Date: Oct 2010
Posts: 14
Default

Tuas fala portugueso?!

Great, my portuguese is not great, but I can understand it in speech.

Anyway, the thing that is wrong in your lines is that it cannot do the 2 ways and win and block because when you do a vertical line in the beginning, it simply CANNOT go over that. You're going to have to tell the program to notice when there are two vertical lines about to win, and to abort it's strategy and block the user's strategy.
Reply With Quote
  #5  
Old 11-04-2010, 02:34 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

Quote:
Originally Posted by elemein View Post
Tuas fala portugueso?!

Great, my portuguese is not great, but I can understand it in speech.

Anyway, the thing that is wrong in your lines is that it cannot do the 2 ways and win and block because when you do a vertical line in the beginning, it simply CANNOT go over that. You're going to have to tell the program to notice when there are two vertical lines about to win, and to abort it's strategy and block the user's strategy.
sorry but how can i block that 2 lines, if i only can play 1 time?
Reply With Quote
  #6  
Old 02-18-2011, 04:00 PM
lilocrane lilocrane is offline
Newcomer
 
Join Date: Dec 2010
Posts: 3
Default

I've done a program like this... and what i did is to check for the first move, where it was placed or clicked then create a move from there.. then users turn again, check for his next move and counter check if he is creating a pattern..

well, i produced a long code and its more like arguing with myself but I've seen it create moves that i didn't code in and i'm quite surprised.. anyway it was an assignment for our Artificial Intelligence class..
Reply With Quote
  #7  
Old 02-18-2011, 04:05 PM
lilocrane lilocrane is offline
Newcomer
 
Join Date: Dec 2010
Posts: 3
Default

Here is a short code of what i did...
Code:
If com = True Then
    'possible moves beginning on box 1'
    If pattern = 1 And com = True Then
        If X2.Visible = True And X3.Visible = False And com = True And O3.Visible = False And X7.Visible = False Then
            O3.Visible = True
            com = False
            player = True
        ElseIf X2.Visible = True And X3.Visible = False And com = True And O3.Visible = True Then
            If X6.Visible = True And com = True And O7.Visible = False And X7.Visible = False Then
                O7.Visible = True
                com = False
                player = True
            ElseIf X6.Visible = True And com = True And X7.Visible = False And O7.Visible = True Then
                If com = True And X5.Visible = False And O5.Visible = False Then
                    O5.Visible = True
                    com = False
                    player = True
                ElseIf com = True And X8.Visible = False And O8.Visible = False Then
                    O8.Visible = True
                    com = False
                    player = True
                Else
                    MsgBox "This round is a Draw. Please START again", vbInformation, "Round Draw"
                    Timer2.Enabled = False
                    clear
                    Timer2.Enabled = True
                    active
                End If
            ElseIf com = True And X6.Visible = False And O6.Visible = False And O3.Visible = True Then
                O6.Visible = True
                com = False
                player = True
            Else
                MsgBox "This round is a Draw. Please START again", vbInformation, "Round Draw"
                Timer2.Enabled = False
                clear
                Timer2.Enabled = True
                active
            End If
        ElseIf X3.Visible = True And X2.Visible = False And O2.Visible = False And com = True Then
            O2.Visible = True
            com = False
            player = True
        ElseIf X3.Visible = True And X2.Visible = False And O2.Visible = True And com = True Then
            If X5.Visible = True And com = True And X7.Visible = False And O7.Visible = False Then
                O7.Visible = True
                com = False
                player = True
the move is actually marked by an image which is visible when a user click on a box (frame)...
Reply With Quote
  #8  
Old 02-18-2011, 04:05 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

Quote:
Originally Posted by lilocrane View Post
I've done a program like this... and what i did is to check for the first move, where it was placed or clicked then create a move from there.. then users turn again, check for his next move and counter check if he is creating a pattern..

well, i produced a long code and its more like arguing with myself but I've seen it create moves that i didn't code in and i'm quite surprised.. anyway it was an assignment for our Artificial Intelligence class..
my pc can play with me normaly i only can't the 2 "win lines"(you don't care if the pc block you that line, because you can use the other line for win). is only these part that i can't understand for block the player
what you advice me?
Reply With Quote
  #9  
Old 02-18-2011, 04:22 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

my code is more simpler with conditions( but i use 3 2D array instead 1: for player, for pc and for table(where was played))..
just see your self: http://www.megaupload.com/?d=H3QKDHHX
enjoy it
and the code too(i was updating it for 2 players, but ,for now, i "pause it")
the project need at least 1 ocx(see the megaupload, because i put there every depencies files)
Attached Files
File Type: zip Tic-Tac-Toe.zip (21.7 KB, 13 views)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
[VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe [VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe
 
[VB6] - teaching pc playing tic-tac-toe
[VB6] - teaching pc playing tic-tac-toe
 
-->