Setting up an odds/weight system? Help me, I'm stumped!

Discussion in 'PHP' started by Renegadez, Jan 14, 2008.

  1. #1
    What's a good way to setup an odds/weight system?

    It's for a game, where let's say there's 3 health items you can win.

    regular health potion is easiest
    then super potion
    then max potion

    How would I setup an odds system for this?

    The system I've come up with is:
    Generating a random number.
    Setting weight for each item(1-950 for regular health potion, 951-999 for super potion and 1000 for max potion). (Out of 1,000).

    Then depending on the random number, it would depend on which item you get!

    how would I determine odds like 1:50, 1:25 etc be calculated from that?

    I don't get how to setup an odds system. I don't think my method is very sufficient and has many flaws to it - I need a real way to do this.....

    + The person should have a chance to win every prize, but certain prizes should be harder to get than others. That is the key. How would I set this up? Let's hear your suggestions!

    Anyone else got a better system for odds? Etc

    Post it up here!
     
    Renegadez, Jan 14, 2008 IP
  2. decepti0n

    decepti0n Peon

    Messages:
    519
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    To calculate odds from that ^ (say 1-950 of 1000 for a crappy prize), since you have 950 chances of that, simplify 950 over 1000 (although im pretty sure it simplifies down to 95/100, or you could do smaller if you want fractions)

    The 1-950, 950-999 etc way of doing odds is probably the best (but to be fair I don't know of any other ones)
     
    decepti0n, Jan 15, 2008 IP