0 Replies - 311 Views - Last Post: 01 May 2011 - 09:40 AM Rate Topic: -----

#1 John-Ellis  Icon User is offline

  • D.I.C Regular

Reputation: 8
  • View blog
  • Posts: 305
  • Joined: 23-March 10

help creating a computer player

Posted 01 May 2011 - 09:40 AM

Hi All,

I want to make my noughts and crosses game a bit more interesting, I created it about a year ago for college but now I am making it even better, I want to create an AI player, so a human user can play against the computer.

can anyone help me get started with this, I have posted below the code I have written for human players, im not sure how to write the code for the computer to take a turn.

 'Declaired HumanPlayer variable
    Dim HumanPlayer As String

 'This sub handles the buttons 2-10 for the user to select
    'X or O to play the game.
    Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
        If btn2.Text <> "" Then
            Exit Sub
        End If

        If HumanPlayer = "O" Then
            btn2.Text = "O"
            btn2.ForeColor = Color.Blue
            HumanPlayer = "X"

        Else
            btn2.Text = "X"
            btn2.ForeColor = Color.Red
            HumanPlayer = "O"
        End If


        Call CheckWinner()
        Call CheckDraw()
        Call KeepScore()

    End Sub



and the code goes on for the other squares (buttons) on the game board.

Any help on this would be great.

Thanks very much

John

Is This A Good Question/Topic? 0
  • +

Page 1 of 1