Obito 122 Report post Posted July 1, 2005 Well, to make a long story short, I'm one of the administrators for an online text-based RPG. We've had a problem plaguing our game since its start that has been the subject of much debate. Let me explain. When a given character is being attacked, we invoke a formula to determine the likelihood of them being hit or they avoid the attack. This number is a % out of 100. A 100-sided die is virtually rolled. Say one has a 30% chance of avoiding a trap. If the dice roll is 30 or below, they successfully avoid it. If the % is higher than 50, it is rounded down to 50. If the % is lower than 1, it is rounded up to 1. On to the problem. The % chance is derived from two different variables, the victim's Speed and the attacker's Accuracy. We run the two through a formula to determine the %. Currently, our formula is: (1.2 * SPD) - ACC = % However, as the variables grow higher and higher, the formula begins to break down. Consider a SPD and ACC of 75 each. (1.2 * 75) - 75 = 15% That's not so bad. Now, consider a SPD and ACC of 175 each. (1.2 * 175) - 175 = 35% Here's our problem. We want to make a new formula (we thought some kind of ratio would work best) where if the two variables are the same, the result will always be the same. ANY help is appreciated. Thanks in advance. 0 Share this post Link to post Share on other sites
oliii 2196 Report post Posted July 1, 2005 ok, I'll call speed s and accuracy a.so you want the results be the same of the ratio of accuracy and speed are the same. then it's simlpy a matter of factoring an equation, not in terms of a and s, but in terms of a / s (or s / a), or (s - a).then if s = a, no matter what they are (except 0), then you'll get the same result. Let's take (s - a). Think of it as an equation taking into account the difference between the speed of the defender, and the accuracy of the attacker. You can modify the ramp as well. (like (1.2 * a - s), to give the attacker's accuracy more impact than the defender's speed). so, change = 1.2 * (a - s) + 10. Since it's a linera equation, it should be easy to factor. You can also transform that into a ratio.as an exampleratio = (1.2 * (a - s) + 10) / 100;ratio = (ratio < 0.0f)? 0.0f : (ratio > 1.0f)? 1.0f : ratio;chance = min_hit_probability + ratio * (max_hit_probability - min_hit_probability); // linear interpolationI don't know how RPGs come up with decent and fair equations, but this sounds like a job for Matlab and a probability mathematician. 0 Share this post Link to post Share on other sites
JohnBolton 1372 Report post Posted July 2, 2005 There are several ways of going about it ultimately they should be based on ACC / SPD or or perhaps ACC - SPD (as olii wrote) if you want the same ratio to give you the same result. Also, it is important that any valid combination of ACC and SPD gives results in the range 0 - 100.The reason 1.2*SPD - ACC doesn't work the way you want it to is because SPD is scaled and ACC is not. (BTW, that formula means that a higher SPD or lower ACC gives a higher chance of hit. That's backwards, right?). Also, it can give you negative % and % > 100.Here is one equation that works: % = 100 * ( atan( ACC - SPD ) / pi + .5 )Here is a simpler one (but ACC and SPD must be >= 0, and never 0 at the same time):if ACC > SPD % = 100 - 50 * SPD/ACCelse % = 50 * ACC / SPD 0 Share this post Link to post Share on other sites
Guest Anonymous Poster Report post Posted July 2, 2005 if SDP and ACC are the same, shouldnt the chance of the character being hit be 50%, no matter the values?theres the same chance that the defender will dodge as there is that the attacker will hit - so its an equal chance to swing either way. 0 Share this post Link to post Share on other sites