Results 1 to 6 of 6

Thread: !!!Please help me with my tic-tac-toe game!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    5

    !!!Please help me with my tic-tac-toe game!!!

    Im new to the forums

    Iv made a visual basic Tic-Tac-Toe game, initially i wanted just for it to be a 2 player human game.. But iv decided i want to be able to play against a AI computer player, it does not have to be smart but it has to have some form of intelligence..

    Here is the zip file with all the neccasary vb project/form files..

    http://www.caldicot-pc-helpdesk.co.uk/Tic.zip

    Basically what i need help with, is i want some way of selecting a 1 player game, i then want to be able to code is so that when the player chooses a square, it will run through the array and find all the enabled cmdbuttons, randomise and select a random cmdbutton and place a 0 or a X depending on what the computer player is..

    Any help would be great..

  2. #2
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    Re: !!!Please help me with my tic-tac-toe game!!!


  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    5

    Re: !!!Please help me with my tic-tac-toe game!!!

    Got anything abit simpler?

  4. #4
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: !!!Please help me with my tic-tac-toe game!!!

    His example may seem complex at first, but really the bit that conserns you is relativly straight foward.

    What he's doing, in easy mode, is to randomly pic a position (by choosing a random number), then if it's already taken then choose another one... When he finds a free space, he goes there.

    VB Code:
    1. Do
    2.             'Randomize the numbers that Rnd() generates (only need to do this once)
    3.             Randomize
    4.             'Generate a random number from 0 to 8
    5.             RndNum = Int(Rnd() * 9) + 0
    6.         'If this space is free then exit this loop
    7.         Loop Until Picture1(RndNum).Picture = 0
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    5

    Re: !!!Please help me with my tic-tac-toe game!!!

    so how would i apply this to an array of 0-8 cmdbuttons (when the cmdbutton is clicked by player1, computer randomises and picks a cmdbutton, if it has a caption of X or 0 then move to the next one, if the caption of the cmdbutton = "" then place a mark)

  6. #6
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: !!!Please help me with my tic-tac-toe game!!!

    Something like this i guess:
    VB Code:
    1. Do
    2.             'Randomize the numbers that Rnd() generates (only need to do this once)
    3.             Randomize
    4.             'Generate a random number from 0 to 8
    5.             RndNum = Int(Rnd() * 9) + 0
    6.         'If this space is free then exit this loop
    7.         Loop Until cmdbuttons(RndNum).text = ""
    8.         cmdbuttons(RndNum).text = "X" 'assuming computer is Xs
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width