need someone who is good at math
As I said I am having trouble with a program I am writing, the code is below i am writing a program where who ever picks up the last ball loses. I am trying to make this unbeatable but the only way i can think of is to make the Computer cheat and take 4 instead of the maxium of 3. How can I make it so that the player will always be the last one to pick up the ball. There are 25 balls and you can only up 1 to 3. this is the code for the computer to go.
Code:
cguess = Int(Rnd * 10) + 1
If amountleft = 1 Then
LBLwinner.Caption = "Player Wins"
pwins = pwins + 1
LBLpw(0).Caption = pwins
Else
If amountleft > 15 Then
Select Case cguess
Case 1 To 2
amount = 1
Call cscore
Case 3 To 4
amount = 2
Call cscore
Case 5 To 10
amount = 3
Call cscore
End Select
ElseIf amountleft > 6 And amountleft < 15 Or amountleft = 15 Then
Select Case cguess
Case 1 To 3
amount = 1
Call cscore
Case 4 To 7
amount = 2
Call cscore
Case 8 To 10
amount = 3
Call cscore
End Select
ElseIf amountleft = 6 Then
amount = 1
Call cscore
ElseIf amountleft = 5 Then
amount = 4
Call cscore
ElseIf amountleft = 4 Then
amount = 3
Call cscore
ElseIf amountleft = 3 Then
amount = 2
Call cscore
ElseIf amountleft = 2 Then
amount = 1
Call cscore
ElseIf amountleft = 1 Then
amount = 1
Call cscore
End If
End If
Re: need someone who is good at math
With a value like 1-3 there's no guaranteed way to make sure the computer always wins because both the computer and the player can always take enough to force the other player into a bad spot. If computer forces the balls down to *5* then no matter how many the player takes the computer can take enough to bring it to 1 ball left, it's just a mindgame to get to 5 basically and anything above that is redundant...maybe if you made it so if the computer takes 2 the player has to take 1-3, then if player takes 3 the computer takes 2-4 and vary the playability that way, that could work.
And this probably should be asked in the games programming section, not here :-P
Re: need someone who is good at math
Moved to Games Programming