Results 1 to 3 of 3

Thread: need someone who is good at math

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2006
    Posts
    48

    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

  2. #2
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    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
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: need someone who is good at math

    Moved to Games Programming

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