• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
n00b0dy

Deterministic Critical / Dodge Chance

21 posts in this topic

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) [[b]Requirement[/b]] 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) [[b]Requirement[/b]] Between those 10 hits, player wont be able to crit twice.
From 1) 2) we conclude we want player to crit exactly once.
3) [[b]optional[/b]] 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,
0

Share this post


Link to post
Share on other sites
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... Edited by Hodgman
1

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1342077205' post='4958282']
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.
[/quote]

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 )
1

Share this post


Link to post
Share on other sites
[quote][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]3) [[/background][/left][/size][/font][/color][b]optional[/b][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][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][/left][/size][/font][/color]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][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][/left][/size][/font][/color]

[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][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][/size][/font][/color][/left]
0

Share this post


Link to post
Share on other sites
[quote name='d07RiV' timestamp='1342082032' post='4958306']

[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][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][/size][/font][/color][/left]
[/quote]
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.
0

Share this post


Link to post
Share on other sites
you know what's fun: double crits, even better triple crit.

nothing more satisfying than being on a crit streak.
0

Share this post


Link to post
Share on other sites
[quote][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][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][/size][/font][/color][/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".

[quote]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.
[CODE]
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;
}
}
[/CODE] Edited by n00b0dy
0

Share this post


Link to post
Share on other sites
[quote name='n00b0dy' timestamp='1342084621' post='4958323']
[quote][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][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][/size][/font][/color][/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 ...

[quote]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
0

Share this post


Link to post
Share on other sites
[quote]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.
0

Share this post


Link to post
Share on other sites
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. Edited by n00b0dy
0

Share this post


Link to post
Share on other sites
[quote name='n00b0dy' timestamp='1342086210' post='4958328']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.[/quote]Only on the first 10 attacks -- say crit position is 3 in the first shuffle and 9 in the next shuffle, then there's more than 10 swings between crits (same way that you can get 2 crits in a row).
0

Share this post


Link to post
Share on other sites
Hmm, if you want fairness but not necessarily predictability of crits, maybe something like the following:
1. Draw 10 out of a deck of 11 (or more generally 10 + x).
2. Put any crits not drawn into the next deck.

Alternately go the probability way instead of a deck. Adjust the probability for each crit pick based upon the expected vs actual number of crits for a sliding window.

Edit: I know it doesn't exactly fulfil the criteria, but the criteria themselves look like the problem for creating predictability. Edited by jefferytitan
0

Share this post


Link to post
Share on other sites
If you want to prevent double crits, you can simply use the deck system and just prevent the first card to be a critical if the last card was a critical (you can for example choose the first card from the previous cards but the last). But I think double crits are generally ok and the deck system already prevent triple or more crits.

Your rules themselves make it possible to predict some cards, for example the card after a crit and the tenth attack every ten attacks. If you want a less predictable system you should drop some rules.
0

Share this post


Link to post
Share on other sites
One thing to be aware of: The card system removes a little bit of the crit chance flexibility. You will only be able to move critical percent up or down by 10%. This is quite a big jump as most games have skills that only increase crit by 1-2%.
0

Share this post


Link to post
Share on other sites
[quote name='RedBaron5' timestamp='1342098516' post='4958384']
One thing to be aware of: The card system removes a little bit of the crit chance flexibility. You will only be able to move critical percent up or down by 10%. This is quite a big jump as most games have skills that only increase crit by 1-2%.
[/quote]

If you do the implementation right it should be possible to get arbitrary crit chances.


E.g. if 1 out of 4.5 hits is a crit you alternate between decks with 4 and 5 cards.

That is, use integer numbers for the deck sizes and accumulate the decimal amounts until they account for an additional card
0

Share this post


Link to post
Share on other sites
You can also use a bigger deck. 10% would mean 10 crit cards in a 100 card deck. The more cards you use, the less able a player will be to "count cards", so to speak, and try to line up guaranteed crits. At least without third-party tools to do the job for him. With in-place shuffling, you can mitigate the overhead of shuffling so that the larger decks do not become a performance problem. Set your deck size to correspond to the smallest increment of crit chance.
0

Share this post


Link to post
Share on other sites
[quote name='JTippetts' timestamp='1342100047' post='4958393']
You can also use a bigger deck. 10% would mean 10 crit cards in a 100 card deck. The more cards you use, the less able a player will be to "count cards", so to speak, and try to line up guaranteed crits. At least without third-party tools to do the job for him. With in-place shuffling, you can mitigate the overhead of shuffling so that the larger decks do not become a performance problem. Set your deck size to correspond to the smallest increment of crit chance.
[/quote]

You wouldn't be able to guarantee one crit in 10 though. You could only guarantee one crit in 91 attacks.
0

Share this post


Link to post
Share on other sites
One way to solve your problem of double-crit and predictability is to give every attack a 10% crit chance, and check the previous 2 or 3 attacks to see if there were any criticals to prevent chaining.

This will prevent your guaranteed 1 crit out of 10 attacks unfortunately, and may give up to 2-3 crits in 10 or worse player "never" gets a critical. However, that is still very unlikely with each only having 10% and now the player cannot "count cards" to know when they will get a critical, and prevents getting a critical twice in a row, or every other turn.

Just thought I'd give my two cents on how to prevent exploitation, though it will mess up some of your other requirements.
0

Share this post


Link to post
Share on other sites
[quote name='arkane7' timestamp='1342114014' post='4958479']
One way to solve your problem of double-crit and predictability is to give every attack a 10% crit chance, and check the previous 2 or 3 attacks to see if there were any criticals to prevent chaining.

This will prevent your guaranteed 1 crit out of 10 attacks unfortunately, and may give up to 2-3 crits in 10 or worse player "never" gets a critical. However, that is still very unlikely with each only having 10% and now the player cannot "count cards" to know when they will get a critical, and prevents getting a critical twice in a row, or every other turn.

Just thought I'd give my two cents on how to prevent exploitation, though it will mess up some of your other requirements.
[/quote]

I do not think predicting crits is an issue with the deck system. The crits are still random. You cannot count from the last crit, but you have to keep counting throughout the whole game. And still you can only predict a crit if it is in the last card of the deck. And you have to know how the algorithm deals with changes in crit chance. And also for numbers of cards which are not natural numbers it is totally hopeless.
0

Share this post


Link to post
Share on other sites
[quote name='RedBaron5' timestamp='1342102888' post='4958406']
[quote name='JTippetts' timestamp='1342100047' post='4958393']
You can also use a bigger deck. 10% would mean 10 crit cards in a 100 card deck. The more cards you use, the less able a player will be to "count cards", so to speak, and try to line up guaranteed crits. At least without third-party tools to do the job for him. With in-place shuffling, you can mitigate the overhead of shuffling so that the larger decks do not become a performance problem. Set your deck size to correspond to the smallest increment of crit chance.
[/quote]

You wouldn't be able to guarantee one crit in 10 though. You could only guarantee one crit in 91 attacks.
[/quote]

Lets say player has 4% crit chance. We can implement arbitrary critical chances the following way:

Plain logic:
1) Create a deck size of 100 cards.
2) Mini deck size = 100 / 4 = 25
2) place 1 critical card at each minideck[0,25].
b) [optional prevent doublecrits] with the restriction that the distance between 2 critical cards is at least A.
if (critical Chance <= 10%) A = 5;
else if (critical Chance <= 20%) A = 2;
else if (critical Chance <= 30%) A = 1;
else A = 0;


Code: performance = O( mini-decks ).
[CODE]
int A ;
for each minideck
{
int randomPos = random( minideck.min, minideck.max);
if ( A + randomPos > minideck.max)
{
getNextMinideck().min = ( randomPos + A );
}
}
[/CODE]

Lets see what points this algorithm covers:
1) arbitrary critical chance;
2) prevents too frequent crits if critical chance < 30%.
3) [predictable].If player knows critical chance, he knows A, he knows the source code (assume open source game),
he knows minideck size.

Can we remove point c? predictability ? what if we make minidecks variable size ?
instead size=25, make it size = random[20, 30].


There is one big problem that makes it complicated / impossible to implement in rpgs.
What if critical chance changes ? e.g a player uses an ability with +20% critical chance ?
Then it will have to reconstruct all decks from the beginning, losing the previous result = flawed critical chance calculation. Edited by n00b0dy
0

Share this post


Link to post
Share on other sites
What is the point of the minidecks? You could just use decks with 25 cards. And I still do not get how this system is predictable.
0

Share this post


Link to post
Share on other sites
min critical chance that can be represented = 1%.
max critical chance that can be represented = 100%.

Worst case : you would need at least decks of size 1% / 100% = size 100.

[quote]What is the point of the minidecks? You could just use decks with 25 cards[/quote]
Yes you will use 4 decks of size (25), what i meant with the term "minideck" is that you can use more than one decks.
so conceptually they are part of a bigger deck (100), as far as technical implementation is concerned
it may be ignored. Edited by n00b0dy
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0