I am making a poker game and i am trying to get the computer to make a random move based on the options fold check call and raise.
I have a PLAYER class which when the game runs has, for example, 10 instances, which i put into an arraylist called playerList() so player1 is playerList(0), player2 is playerList(1) etc. etc.
I can get and set all values for these players, eg:
playerList(0).pChipCount = 1000
playerList(1).pChipCount = 800 etc. etc.
BUT...when i try and access the method below it doesnt work.
This is the call to it from my form:
Private Sub preFlop()
playerList(1).pAvailableMoves = "Fold" & "Check" & "Call" & "Raise"
MsgBox(playerList(1).pName & "," & playerList(1).pActive & "," & playerList(1).pStyle & "," & playerList(1).pAvailableMoves)
'IT WORKS UP UNTIL HERE
playerList(1).mMove(1)
End Sub
This is the method in my class PLAYER:
Public Sub mMove(ByVal player As Integer)
Dim RandomClass As New Random()
Dim randomNumber As Integer
Dim availableMoves(5) As String
availableMoves(1) = "Fold"
availableMoves(2) = "Check"
availableMoves(3) = "Call"
availableMoves(4) = "Raise"
'RANDOM PLAYER
If playerList(player).pStyle = "Random" Then
'if the randomly selected move is in the available move list for the player then use it
Do Until InStr(availableMoves(randomNumber), playerList(player).pAvailableMoves)
randomNumber = RandomClass.Next(1, 4)
Loop
End If
'this sets the players chosen move property
playerList(player).pMove = availableMoves(randomNumber)
End Sub
Hopefully that makes sense...VS2005 just freezes and i have to stop debuggin and after 3hours cannot work out how to fix it!!!
I have a PLAYER class which when the game runs has, for example, 10 instances, which i put into an arraylist called playerList() so player1 is playerList(0), player2 is playerList(1) etc. etc.
I can get and set all values for these players, eg:
playerList(0).pChipCount = 1000
playerList(1).pChipCount = 800 etc. etc.
BUT...when i try and access the method below it doesnt work.
This is the call to it from my form:
Private Sub preFlop()
playerList(1).pAvailableMoves = "Fold" & "Check" & "Call" & "Raise"
MsgBox(playerList(1).pName & "," & playerList(1).pActive & "," & playerList(1).pStyle & "," & playerList(1).pAvailableMoves)
'IT WORKS UP UNTIL HERE
playerList(1).mMove(1)
End Sub
This is the method in my class PLAYER:
Public Sub mMove(ByVal player As Integer)
Dim RandomClass As New Random()
Dim randomNumber As Integer
Dim availableMoves(5) As String
availableMoves(1) = "Fold"
availableMoves(2) = "Check"
availableMoves(3) = "Call"
availableMoves(4) = "Raise"
'RANDOM PLAYER
If playerList(player).pStyle = "Random" Then
'if the randomly selected move is in the available move list for the player then use it
Do Until InStr(availableMoves(randomNumber), playerList(player).pAvailableMoves)
randomNumber = RandomClass.Next(1, 4)
Loop
End If
'this sets the players chosen move property
playerList(player).pMove = availableMoves(randomNumber)
End Sub
Hopefully that makes sense...VS2005 just freezes and i have to stop debuggin and after 3hours cannot work out how to fix it!!!