Help With The Math

crapscraps Member Posts: 353
edited November -1 in Working with GS (Mac)

Comments

  • crapscraps Member Posts: 353
    I am trying to add $$ to a bankroll when a player wins his bet. Set up the following but it appears to periodically display random numbers NOT the +15 added to the bankroll as I set up.

    Any suggestions?

    http://i56.tinypic.com/2zf8xs1.png
  • crapscraps Member Posts: 353
  • osucowboy18osucowboy18 Member Posts: 1,307
    What exactly is the rule you currently have that calculates the new bankroll?
  • osucowboy18osucowboy18 Member Posts: 1,307
    Nevermind...Just got the link to work :)
  • osucowboy18osucowboy18 Member Posts: 1,307
    Ok, what are the two conditions in your $5 rule?
  • crapscraps Member Posts: 353
    My problem - staring with a $1000 bankroll - "touch" the bet button - which DOES subtract the appropriate amount bet - (the payout scheme works) - which compares the chosen bet to the random outcome and pays out $$$ - but its not always the correct pay out.

    It needs to be a ongoing addition and subtraction to the bankroll depending if the player wins or loses. Sort of a score keeping idea I guess.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi Bruce, you need a bankroll attribute to update. (Or have you got it working now anyway?)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • osucowboy18osucowboy18 Member Posts: 1,307
    Is game.bankRoll an integer or a real attribute?
  • crapscraps Member Posts: 353
    Integer.
  • osucowboy18osucowboy18 Member Posts: 1,307
    The only thing I can think of is that the bank roll may get to large for an integer to handle. Try changing game.bankroll to a real. Hope that helps.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi osucowboy18: integers can can go into the tens of millions so I don't think it'll be that.

    Hi Bruce, if you're using what I suggested to you 3 or 4 days ago, i.e PlayerAmount + (UserBet *2), it could be that you haven't put the brackets around UserBet*2 possibly?

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    do you have the payout set to random, because then it will pick between the min and max no matter what the actual outcome is. If so you need to make a new attribute pay out and constrain that number to whatever the random outcome number is. That way the outcome is random but the payout will always add or subtract depending on outcome.
  • crapscraps Member Posts: 353
    Okay - made some changes. Heres what I have now and it works but needs a tuneup.

    In the bet button -
    touch.inside - change attribute - bet to bet +10
    change attribute - bankroll to bankroll - 10
    display text - game.bankroll

    In the outcome actor
    attribute - game.firstCheckbox - is true
    attribute - game.pickAdice = 1
    change attribute - game.bankroll to game.bankroll + bet

    It subtracts the $5 bet from the bankroll and displays it okay and then will add $5 to the bankroll when the
    player wins.

    I want to be able to payout odds (say 2:1 ) for each bet.

    How can I get the "game.bankroll + bet" to add the initial $5 and the 2:1 odds payout - which would be $10?
    I could just say ""game.bankroll+10
    But is there an easier or more efficient way when I will be having bets up to $100.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi Bruce; a couple of things here: if a user can click on as many bet buttons as they like up to $100 dollars, then in the bet button, you should add:
    When attribute bet < 101

    And then for a 2 to 1 payout as you want, in the outcome actor, the bankroll line should be:
    Change attribute game.bankroll to game.bankroll + (bet*2)

    Hope that sorts it for you. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • crapscraps Member Posts: 353
    Okay I can see what should happen!
    game.bankroll ($1000) to game.bankroll($1000) + (bet ($10)*2)

    should equal

    $1000 + 10 * 2 =$1020

    But what happens is this - $1000 + 10*2 +10 =$1030

    The multiplication (bet*2) works but the formula always adds an extra $10 not matter what value bet in inserted. I can work this out backwards to get the payout correct. But what is going on?

    Thanks. This stuff addictive.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    My guess is that when the roll button, or whatever you have, is pressed after the total bet is made, the bet itself is not being deleted from the bankroll. (In the Roll or Go button, put change attribute game.Bankroll to game.Bankroll - Bet )

    So what should be happening is:

    ($1000 - 10) + (10*2)
    Bankroll, minus the $10 bet = 990, plus the win, which is twice the original bet of $10, making $20; 990 + 20 equals $1010. So the user, by winning, has doubled the bet.
    craps said:
    This stuff addictive.

    It certainly can be! :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • crapscraps Member Posts: 353
    Wow I figured something out myself - I am subtracting the user bet from the bankroll as seen below
    http://i51.tinypic.com/wm146a.png

    But I think what is happening is that the $10 bet is coming out of the "display text" bankroll like you suggested - but - the $10 bet is not being taken out of the calculation - looks like I might have to subtract the bet somewhere else too.

    Thanks for your help
  • crapscraps Member Posts: 353
    It works. I did this for each of the bet buttons and it works on all the bets from $5 - $100. Only took 3.5 hours.

    Image and video hosting by TinyPic
  • crapscraps Member Posts: 353
    As stated above the subtracting a bet from the original bankroll works HOWEVER when you subtract additional bets after a win things get crazy.

    First bet

    1000 (-) 100 bet = 900 pays out at 2:1 (200) plus the 900 = total of 1100 CORRECT.

    Second bet

    1100 (-) 100 bet should equal 1000 but it makes it 900 again. However it pays out at 2:1 (200) plus the starting 1100 = 1300.

    Third bet

    1300 (-) 100 should equal 1200 but it makes it 1000. This time it pays out 300 (3:1) plus the starting 1300 = 1600.

    Fourth bet

    1600 (-) 100 should equal 1500 but it makes it 1200. This time it pays out 400 (4:1) plus the starting 1600 = 2000.

    It looks like it subtracts correctly the first time but then somehow "adds" bets together - subtracts 200, 300, 400 and pays out in the reverse adding 200, 300, 400.

    It should subtract one bet from the running total bankroll each time and add the same payout to the new running bankroll.

    Help
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    It's all down to the math somewhere: my guess is you've duplicated one of the equations. It's difficult to help without seeing the actual gamefile, but hopefully you'll get it sorted from this advice, fingers crossed. If you still have trouble, I'll take a look at your file if you like. Sometime tomorrow (Wednesday) though; it's 3.25am here in the UK and this insomniac is off to sleep! Goodnight! :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi Bruce, just had a thought: I've the idea that you're not setting the UserBet back to 0 after the payout/before the next bet....possibly.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.