Deterministic Critical / Dodge Chance

Started by
20 comments, last by n00b0dy 11 years, 9 months ago
I want a propability distribution / pseudonumber generator / or simple algorithm to simulate deterministic critical chance in an rpg with the following attributes:

Lets say i have 10% critical chance.

1) [Requirement] Every 10 hits, at least one of them must be critical. I dont care which let it be random.
i.e Between those 10 hits, player will crit at least once.
2) [Requirement] Between those 10 hits, player wont be able to crit twice.
From 1) 2) we conclude we want player to crit exactly once.
3) [optional] P(X=x) = 10% for x = {1,2,3,... 10} Chance of an attack between those 10 hits to be a critical =10%. So that it's not exploitable e.g player hitting a minion first and then attacking enemy champion and getting 100% critical chance.

Ok so you math experts what is the solution to my problem, there must be a propability distribution to solve my problem.

To Conculde:
I want between [ 1 / crit_chance ] hits, player to crit exactly one time.
[optional] chance the crit to be at Xth attempt is equal for x = {1,2,3,... 10}.

thank you,
Advertisement
You could use a deck of cards instead of a dice.
Randomly shuffle 9 'hit' cards with 1 'crit' card. Every time the player attacks, draw a card. When the pile is empty, re-shuffle it randomly.

[edit]
I remember reading an article on approaches like this, and he suggested decks over dice in a lot of situations to give more stability to the designer.
If you use dice (e.g. rand), then it's still possible for a player to get 100 crits in a row, or to never ever get a single crit. If enough people play your game, these possibilities become certainties -- there's going to be one player out there who is unlucky enough to fail every "roll to hit" test that the game throws at him...

I remember reading an article on approaches like this, and he suggested decks over dice in a lot of situations to give more stability to the designer.


This would be the article you are thinking of: http://archive.gamedev.net/archive/reference/design/features/randomness/default.html (more specifically: http://archive.gamedev.net/archive/reference/design/features/randomness/page3.html )
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]3) [[/background]

[/font]optional[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]] P(X=x) = 10% for x = {1,2,3,... 10} Chance of an attack between those 10 hits to be a critical =10%. So that it's not exploitable e.g player hitting a minion first and then attacking enemy champion and getting 100% critical chance.[/quote][/background]

[/font]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]If the player attacked 9 times and neither of those crit, wouldn't he know for sure that the next attack will crit?[/background]

[/font]

[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]For simplicity, after every 10 attacks you could roll a number 1-10, which would determine which of the next 10 attacks should crit. You could achieve determinism by using a fixed random seed.[/background][/font]



[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]For simplicity, after every 10 attacks you could roll a number 1-10, which would determine which of the next 10 attacks should crit. You could achieve determinism by using a fixed random seed.[/background][/font]



That is almost what Hodgman suggested to use a deck instead of a die but less flexible and not much easier. It really doesn't extend well to more than one crit to keep track of all outcomes while with the deck you can shape any distribution with no extra work.
you know what's fun: double crits, even better triple crit.

nothing more satisfying than being on a crit streak.
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]If the player attacked 9 times and neither of those crit, wouldn't he know for sure that the next attack will crit?[/background][/font][/quote]
Thats true, it would be a huge exploit, e.g in the laning phase imagine every 10 attacks the enemy carry to get a free guaranteed crit.

How about the 10th predictable card, being a "non activated critical" that instead increases the damage of next 9 attacks by 11.1% ?

Still we would know that the 9th predictable card has 50% chance of being a critical. [still an exploit].
And the 8th has a 25% chance to be a critical. And so on ...
So that would defeat the whole point of placing the "exploit prevention".

you know what's fun: double crits, even better triple crit.

nothing more satisfying than being on a crit streak.[/quote]
And what if this happens to YOU, instead of the enemy, you instantly lose the fight in 3 sec instead 10.


Here is how i will implement the "card" algorithm.

int currentAttack = 1;
int criticalCardPosition = random(1, 10);
isCritical( )
{
f (currentAttack == criticalCardPosition)
{
return true;
}
return false;
}
onAttack()
{
currentAttack++;
if (currentAttack == 11)
{
criticalCardPosition = random(1, 10);
currentAttack = 1;
}
}


[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]If the player attacked 9 times and neither of those crit, wouldn't he know for sure that the next attack will crit?[/background][/font]


Thats true, it would be a huge exploit, e.g in the laning phase imagine every 10 attacks the enemy carry to get a free guaranteed crit.

How about the 10th predictable card, being a "non activated critical" that instead increases the damage of next 9 attacks by 11.1% ?

Still we would know that the 9th predictable card has 50% chance of being a critical. [still an exploit].
And the 8th has a 25% chance to be a critical. And so on ...

you know what's fun: double crits, even better triple crit.

nothing more satisfying than being on a crit streak.[/quote]
And what if this happens to YOU, instead of the enemy, you instantly lose the fight in 3 sec instead 10.
[/quote]

You could only predict the crit if you knew you were at the last card of the deck. But the player does not really know that. And also the prediction is only possible if the last card is the crit, which should not happen too often with lower crit chances. (with high crit chances it is not that important anyway)

On a related note :)
http://en.wikipedia.org/wiki/Unexpected_hanging_paradox
You could only predict the crit if you knew you were at the last card of the deck[/quote]
A) Player knows critical chance from tooltip. He infers that deck size is 10.
B) Player performs 9 autoattacks on simple minions, he is lucky none of them critted (10% chance).
Chance for crit to be last card of the deck = 10%.
Now he goes and attacks enemy champion getting a free guaranteed hit.

Also here is one other thing that i noticed with my algorithm. Player can get double crit in a quick succession.

Imagine the following example :
deck 1 : crit 10.
deck 2 : crit 1.
That means that the player will be able to get a double crit if he is lucky, 1% chance.
Maybe we should relax the initial requirements to see if we can make it less predictable.

Suppose : player has 10% critical chance.

Deck(1, 10) = deck with 1 critical card out of 10 cards.
Bug: Player can predict last card if he knows all the previous
Why:
a) he knows deck size in this case 10.
b) he knows current attack position (he counts his autoattacks).

We cannot change b) but we can modify a) so that player doesn't know the deck size.

Deck(2, 20) = deck with 2 critical cards out of 10 cards.
Deck(X, X*10);

how about a random size of deck is chosen when the deck ends, that way he cannot predict when he can critical.
Because he doesn't know the deck size.

What restriction does the new algorithm place:
1) It allows attacks to critical several times in a row if they get "lucky" depending on deck size.

This topic is closed to new replies.

Advertisement