View Full Version : Nerd Overdrive

monkey3

2010-05-28, 09:58 AM

Fridays...

You know how there is the basic concept in D&D in which one race/class/feat should not be in all ways better than another, since it would invalidate the other one. They of course break this rule all the time, but I was thinking of a specific case:

Improved Initiative Add 4 to your Initiative roll.

Lucky Start Gives a luck point and lets you re-roll initiative.

To make it easier, lets assume we are talking about one important battle, where you'd use it, and lets assume you can take the higher of 2 initiative rolls for Lucky Start. Now, which is better? My probability is not good enough, so I wrote a little perl code:

#!/usr/bin/perl

$toti4 = 0; # Roll + 4

$totm = 0; # max (r1, r2)

print "R1 \tR2 \tR1+4 \tmax(R1,R2)\n";

for($i = 1; $i < 21; $i++) {

for($j = 1; $j < 21; $j++) {

$m = $i > $j ? $i : $j;

$i4 = $i + 4;

print "$i \t$j \t$i4 \t$m \n";

$toti4 += $i4;

$totm += $m;

}

}

# FINISH THE TABLE

print "\nAverage R+4 = ", $toti4/400.0 ,"\n";

print "Average max = ", $totm/400.0 ,"\n\n";

You can comment out the first two print lines if you just want the answer.

Have fun :)

Would you mind to tell what this thread is about to people who can't write perl?

Eloel

2010-05-28, 10:18 AM

He has written a program to show whether +4 or a reroll is better. He failed to post the conclusion.

Doesn't Improved Initiative add 4 to both rolls ?

Eloel

2010-05-28, 10:24 AM

Doesn't Improved Initiative add 4 to both rolls ?

If you have one of the feats, there's no 'both' to add 4 to, or no 4 to add to the 'both'

Though I just realized the probability needs to be out of 8000, since you're rolling 3 dice (2 for the re-roll one, 1 to add +4), so the program doesn't work.

If you have one of the feats, there's no 'both' to add 4 to, or no 4 to add to the 'both'

Aahh - I completely misunderstood the problem.

Though I just realized the probability needs to be out of 8000, since you're rolling 3 dice (2 for the re-roll one, 1 to add +4), so the program doesn't work.

Possibly because I read the code :smallsmile:

Eloel

2010-05-28, 10:35 AM

Java below, be aware.

public class Initiative{

public static void main(String [ ] args)

{

int x=0;

int y=0;

for (int a=1; a<=20; a++)

{

for (int b=1; b<=20; b++)

{

for (int c=1; c<=20; c++)

{

if (Math.max(a,b) > (c+4)) //(equal is given to +4, because higher modifier wins in case of tie)

//Even if you give ties to the reroller, it's still 3944-4056 in favor of +4

x++;

else

y++;

}

}

}

System.out.println(x + " " + y);

}

}

Answer;

Reroll wins 3560/8000

+4 wins 4440/8000

shadow_archmagi

2010-05-28, 10:37 AM

As I recall, it isn't "Choose the better of the two"

Now, let's see if my logic here is correct:

When choosing whether or not to reroll, the real question you have to ask yourself is "Am I likely to get a higher number?" Obviously if you rolled a 1 then you have a 95% chance of showing improvement, if you rolled a 2 then you have a 90% chance of improving and a 5% chance of getting worse, and so on.

Then again, it isn't just a "Better or worse" since you're comparing with a flat +4.

So really, there are 20 possible outcomes for roll 1, which then determine whether or not a reroll CAN be helpful. Obviously if you roll a 20 then a reroll cannot benefit you at all ever.

So what you need to code is something that accounts for the fact that Lucky Start gives a bonus between -19 and +19

monkey3

2010-05-28, 10:37 AM

Though I just realized the probability needs to be out of 8000, since you're rolling 3 dice (2 for the re-roll one, 1 to add +4), so the program doesn't work.

This is not the case.

In one case you have D20 + 4

Take all possibilities, and get an average.

In the other case you have max(D20, D20)

Take all possibilities and get an average.

Then I compare the averages.

What I am NOT doing (which if I did would need 8000 rolls) is to see in all cases which case won, and count up the winners.

monkey3

2010-05-28, 10:39 AM

Java below, be aware.

...

Answer;

Reroll wins 3560/8000

+4 wins 4440/8000

Nice code. I am however calculating averages, and not who wins most. Your conclusion however is correct D20+4 wins. I have not seen anyone post the final average rolls though.

RE: Shadow:

You are correct. I am intentionally solving a simpler case. The case I am solving is take higher of 2 rolls, not decide if you should re-roll.

Eloel

2010-05-28, 10:41 AM

As I recall, it isn't "Choose the better of the two"

Now, let's see if my logic here is correct:

When choosing whether or not to reroll, the real question you have to ask yourself is "Am I likely to get a higher number?" Obviously if you rolled a 1 then you have a 95% chance of showing improvement, if you rolled a 2 then you have a 90% chance of improving and a 5% chance of getting worse, and so on.

Then again, it isn't just a "Better or worse" since you're comparing with a flat +4.

So really, there are 20 possible outcomes for roll 1, which then determine whether or not a reroll CAN be helpful. Obviously if you roll a 20 then a reroll cannot benefit you at all ever.

So what you need to code is something that accounts for the fact that Lucky Start gives a bonus between -19 and +19

I'm making Lucky Start roll twice and take the better one. It assumes Lucky Start guy makes the wise decision every single time.

This is not the case.

In one case you have D20 + 4

Take all possibilities, and get an average.

In the other case you have max(D20, D20)

Take all possibilities and get an average.

Then I compare the averages.

What I am NOT doing (which if I did would need 8000 rolls) is to see in all cases which case won, and count up the winners.

Ah. I went for a non-calculation version that takes up every single probability. Most probably more accurate, but kudos for your program :)

Edit: I just got your point. You're doing 'which is better against enemies', by averaging. I'm doing 'who wins' of the two, by calculating all. So, different approaches to the same problem :smallbiggrin:

Lucky Start

If I roll a 1 then a re-roll is going to add 9.5 on average

If I roll a 20 then a re-roll is going to add 0 on average

If I roll a 10 then a re-roll is going to add 2.75 on average

(0+...0+1+2+...+10)/20 = (10*11)/2/20 = +2.75

If I roll an 11 then a re-roll is going to add 2.25 on average

(0+...0+1+2+...+9)/20 = (9*10)/2/20 = +2.25

Since an average roll is 10.5 (so +2.5 say), Improved initiative is better on average.

However Lucky Start will give you a different distribution of results and how much is a luck point worth ?

Edit:

Actually this is Wrong - I just realised

monkey3

2010-05-28, 10:52 AM

ozgun92:

In the interest of fun, there is a slight problem with your code. I know you wrote it in <5 mins, but we are having fun... so find it ;)

ozgun92:

In the interest of fun, there is a slight problem with your code. I know you wrote it in <5 mins, but we are having fun... so find it ;)

I believe that ozgun92 and I made the same error - quite independantly :smallsmile:

Eloel

2010-05-28, 10:59 AM

ozgun92:

In the interest of fun, there is a slight problem with your code. I know you wrote it in <5 mins, but we are having fun... so find it ;)

It's bound to be a logic error somewhere, since it actually works..

Care to enlighten?

monkey3

2010-05-28, 11:02 AM

It's bound to be a logic error somewhere, since it actually works..

Care to enlighten?

You are not taking into account the case where they are equal (tie).

In the interest of fairness, my code is not as efficient as it could be. I will edit to add spaces to make it more clear.

Eloel

2010-05-28, 11:06 AM

You are not taking into account the case where they are equal (tie).

In the interest of fairness, my code is not as efficient as it could be. I will edit to add spaces to make it more clear.

I commented on ties in the code actually. Ties go to Improved Initiative, due to

If two or more combatants have the same initiative check result, the combatants who are tied act in order of total initiative modifier (highest first). If there is still a tie, the tied characters should roll again to determine which one of them goes before the other.

We were using the approach of

Roll 2x d20

Take the best

When the actual algorithm is

Roll d20

Decide whether to re-roll

If Re-roll

Roll 20 and take the result, better or worse

Trying to come up with a non Kwizatch Haderach predicate.

Say I re-roll on a 10 or less

Lucky Start

If I roll a 1 then I re-roll and add 9.5 on average

If I roll a 2 then I re-roll and add 8.55 on average

If I roll a 3 then I re-roll and add 7.65 on average

If I roll a 4 then I re-roll and add 6.8 on average

If I roll a 5 then I re-roll and add 6 on average

If I roll a 6 then I re-roll and add 5.25 on average

If I roll a 7 then I re-roll and add 4.55 on average

If I roll a 8 then I re-roll and add 3.9 on average

If I roll a 9 then I re-roll and add 3.3 on average

If I roll a 10 then re-roll and add 2.75 on average

If I roll an 11 then I don't re-roll and add 0 on average

If I roll a 20 then I don't re-roll and add 0 on average

58.25/20 = 2.9125

So Improved initiative is 1.0875 better on average.

How much is a luck point worth ?

Edit:

Oops, still wrong

Hand_of_Vecna

2010-05-28, 11:32 AM

Actually if you don't just want a high initiative but to go first or at least go before a key enemy it becomes much more complicated. If the initiative your competing against is higher the odds favor improved initiative and if your initiative is higher then the reroll is more favorable. So you would either need to collect alot of data on average initiatives for enemies at your level or more likely pick an arbitrary target number you want to beat often.

Whatever your target number is it comes down to wether lowering your target number by four or having two chances to hit the target number is more favorable. If your target is 18 or greater improved initiative is better at 17 they are the same and if your target is 16 or lower the reroll is more favorable.

The correct maths is actually easier than how I first did it.

Trying to come up with a non Kwizatch Haderach predicate.

Say I re-roll on a 10 or less

Lucky Start

If I roll a 1 then I re-roll and add 9.5 on average

If I roll a 2 then I re-roll and add 8.5 on average

If I roll a 3 then I re-roll and add 7.5 on average

If I roll a 4 then I re-roll and add 6.5 on average

If I roll a 5 then I re-roll and add 5.5 on average

If I roll a 6 then I re-roll and add 4.5 on average

If I roll a 7 then I re-roll and add 3.5 on average

If I roll a 8 then I re-roll and add 2.5 on average

If I roll a 9 then I re-roll and add 1.5 on average

If I roll a 10 then I re-roll and add 0.5 on average

If I roll an 11 then I don't re-roll and add 0 on average

If I roll a 20 then I don't re-roll and add 0 on average

50/20 = 2.5

So Improved initiative is 1.5 better on average.

monkey3

2010-05-28, 12:39 PM

Excellent nerdly discussion :smallamused:

I'll go ahead and post the results for the averaging program:

Average for D20 + 4 = 14.5

Average for max(D20,D20) = 13.825

My code actually does twice as much additions as it need to. A small modification would make it more efficient.

Binks

2010-05-28, 12:51 PM

Actually 13.825 is the average for reroll take better, which lucky start isn't. For just plain rerolls you need to decide where to reroll. Optimum is to reroll on less than an 11 (so 10 or lower) which nets you an average of exactly 13. So Improved initiative gives you, on average, 1 more initiative than an optimum Lucky Start.

Of course that's ignoring the fact that Lucky Start will reduce variability significantly more than improved initiative. The standard deviation of an initiative roll with improved init is the same as that of a standard d20 without any feats whereas lucky start's stdev is somewhat smaller, so if you want more consistent initiative and are willing to take an average hit of 1 point of initiative lucky start is better, whereas if you just want the highest possible initiative and you don't care about stdev improved initiative is better.

Powered by vBulletin® Copyright © 2023 vBulletin Solutions, Inc. All rights reserved.