Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-23-2003, 10:34 PM
Chrisz Chrisz is offline
Registered User
Join Date: Oct 2002
Location: Lost...
Posts: 176
Chrisz is on a distinguished road
Send a message via AIM to Chrisz Send a message via Yahoo to Chrisz
Cool Infinite probabillities

Well.. I'm trying to create a type of infinite probabillity, in which say... lets use basketball as an example, a player can be good, but no one, can ever, score ALL the baskets they take. Begginners will be able to score some baskets, 1 in 10 chance say, Amateurs will be able to score say 6 in 10, and Pros, say 9 in 10, but no matter how good they will get they won't ever score 10 in 10.. (Though some people will but, just imagine they cant ;D)

At first to tackle this I thought, half lives!

e.g...

10, 5, 2.5, 1.25, 0.625..... etc etc.. Always halves the number, but never reaches 0... That is great and all.. But i cant think how to apply this to my problem. x.x And besides the leap from level 1, 10, to level 2, 5, thats huge. :X Thats a whole 5 units :O. Yeah.

NPC Code:

chance = random(1,10);
if (chance == ?) {
//...
}


What would ? be substituted for, even if half lives were used to calculate the probabillity?.. It's confusing. ! I either need help with this, or a brand new concept. x.x
__________________
-Chrisz
Reply With Quote
  #2  
Old 09-23-2003, 11:32 PM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
There are several ways you can accomplish this. One would be to set up a levels system based upon the amount of baskets. You could do something like:

NPC Code:
level = int(baskets / arbitrary number);



And then calculate probability based on level.

-------------------------

However, If you want their probability to steadily increase over time (without a level type system), that's where exponents would come into play. You could apply it several ways; perhaps the simplest would be to calculate the chance to miss, and use that to figure out if the player made the shot or not.

NPC Code:
misschance = basemisschance * e ^ -(constant*numberofbaskets);



For example:

Say you want them to start off missing about 50% of their shots. You'd set the basemisschance to 50 (keep in mind we're dealing with percents).

NPC Code:
misschance = 50 * e ^ -(constant*numberofbaskets);



We still have one constant left in there: What does that do? It controls just how much chance to miss is lost per basket (how much chance to hit is gained per basket). Vary the constant to vary how fast people improve.

Then, you can add a check if the miss chance ends up below 10%, and if so, then set it to 10%.

Now you've got a percent chance to miss. From here, it's a simple matter of comparing a random number between 1 and 100 to the miss chance; if it's greater than the miss chance then it will hit, else it will fail.

Hope this helps!
Reply With Quote
  #3  
Old 09-23-2003, 11:37 PM
Chrisz Chrisz is offline
Registered User
Join Date: Oct 2002
Location: Lost...
Posts: 176
Chrisz is on a distinguished road
Send a message via AIM to Chrisz Send a message via Yahoo to Chrisz
Mmmmm.. Yeep. All I have to do.. is figure out a way to make its leaps smaller.... 10-5-2.5... 10-5 thats a BIG probabillity leap, from crap scoring to good scoring.
__________________
-Chrisz
Reply With Quote
  #4  
Old 09-23-2003, 11:40 PM
Chrisz Chrisz is offline
Registered User
Join Date: Oct 2002
Location: Lost...
Posts: 176
Chrisz is on a distinguished road
Send a message via AIM to Chrisz Send a message via Yahoo to Chrisz
YYEEES I got it, make const val < 0.1! !! That makes the half life, very slow, which is what I want. <3!!!!!!
__________________
-Chrisz
Reply With Quote
  #5  
Old 09-24-2003, 12:13 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
(As I said on AIM to clarify, but for the benefit of future people with the same problem:) You can vary the constant and the base to achieve the effect which you desire.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:56 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.