Page 1 of 2

The dice: an experiment

PostPosted: Sat Jul 01, 2006 8:50 am
by MrsMad
I decided, as I wanted to whoop ass at this game, to find out the exact chances of winning/losing armies when attacking. (ie so u know the best strategy - whether it's best to sit there building up armies or attack at every opportunity etc.). I'm a computer programmer, so I wrote a program whuich went through every combination of dice rolls to work out the statistics. Here's the results...

#(attacker) v (defender)
#3 dice v 2 dice
#2 off defender = 37%
#2 off attacker = 29%
#1 off each = 34%

#2 v 2
#2 off defender = 23%
#2 off attacker = 45%
#1 off each = 32%

#1 v 2
#1 off defender = 25%
#1 off attacker = 75%

#3 v 1
#1 off defender = 66%
#1 off attacker = 34%

At least, thats how it's SUPPOSED to be!

So, here's the thing...

I know that the dice are from random.org, but they appear incredibly biased towards the defender. There is NO WAY that when you attack with 3 dice versus 2, you only lose 2 armies only 29% of the time.

And there's no way that when attacking with 3 v 1 that you win 66% of the time.

Add a bit of code to the program which colllects the statistics on dice rolls (ie simular to the above). This would be very simple to do. Then post the percentages at the end of the month.

I am happy to retreat back into my cave if I am proved to be wrong :-)

MrsMad

ps. I know the random numbers are from random.org, but with an online game with tousdands of players based largely on the luck of the dice, it important to verify that it's accurate and truly random?

PostPosted: Sat Jul 01, 2006 10:32 am
by lackattack
If you want to test the numbers you can write a greasemonkey script of sorts that will plug into your browser. Have it log the results and you can compare the probabilities to what you have calculated above.

I won't write the script because I'm confident the dice are random and my time is better spent on inproving the game.

PostPosted: Sat Jul 01, 2006 10:36 am
by KoolBak
Wow...MrsMad does more than just kick my ass.......coool!

PostPosted: Sun Jul 02, 2006 11:12 am
by MrsMad
lackattack wrote:If you want to test the numbers you can write a greasemonkey script of sorts that will plug into your browser. Have it log the results and you can compare the probabilities to what you have calculated above.


Fair play. I'll have a bash at it.

PostPosted: Sun Jul 02, 2006 12:12 pm
by Tr0y
A simple Greasemonkey script will not work because dice results are not present in the log. And even if they were... it would take a bunch ( 1000s ) of dice rolls to fairly determine if the dice are bias.

I remember reading that the dice file looks something like this...

D# D# A# A# A#
D# D# A# A# A#
D# D# A# A# A#

Where the # is the number on the dice.

A better random file would be...

# # # # # # # # # # # # #.... and so on.

The way the dice file is setup now is random, however a bias is easier to spot because they are separated into 'battles' ... If you just load the file with #s ... all people can say is there are more x's than y's ... but that is randomness for you.

Then attacker/defender bias becomes a less of an issue ( if an issue at all )...

Other things you can do to make the dice "more fair" would be measuring the distribution of each # and the frequency of them.
Keep generating #s till you get a set that most closely represents the expected values.

Of course unlikely things are going to happen. For example, rolling three 6s... But if you took a quarter an flipped it a 100 times, I'm pretty sure you will flip 8 heads/tails in a row.

If you want me to run tests to verify the "randomness" of the #s I can.

PostPosted: Sun Jul 02, 2006 12:30 pm
by Jota
So Greasemonkey has no way to save persistent data across pageviews?

PostPosted: Sun Jul 02, 2006 12:32 pm
by Pilate
The dice are not purely random in a statistical sense.

There is a 3.6 % chance (36 in 1000) of losing 3 "3 vs 1" rolls in a row. This is significantly slower than the actual chances in CC.

PostPosted: Sun Jul 02, 2006 12:33 pm
by wacicha
dang Pilate you can do that kind of thinking and still kick my butt. good job

PostPosted: Sun Jul 02, 2006 12:38 pm
by Jota
So you've finished doing a full statistical analysis of all die roll results over an extended period of time already, Pilate? Could you please publish your raw data and collection methods so that we can all confirm your conclusions?

PostPosted: Sun Jul 02, 2006 12:41 pm
by Mr.Catfish
"Never tell me the odds"; lol star wars

PostPosted: Sun Jul 02, 2006 12:42 pm
by Tr0y
Well I was first going to respond... "It is not worth it"

But...

Then I started thinking about all those people who believe the dice are bad.

And I thought it would be funny to have a luck stat somewhere.... And maybe even a distribution of rolls as attacker.

e.g.
[ Wins x% | Losses x% ]

Rolls
1s [ # (#%) ]
2s [ # (#%) ]
3s [ # (#%) ]
4s [ # (#%) ]
5s [ # (#%) ]
6s [ # (#%) ]

So yea... I think I can do it... Dont know if I will or not... more of a fun stat...

PostPosted: Sun Jul 02, 2006 12:54 pm
by MrsMad
Currently working on it ;-)

Image

PostPosted: Sun Jul 02, 2006 12:58 pm
by Tr0y
Sonava :shock:

*clicks close on photoshop... clicks no when asked to save luck gradient... [sigh]*

Looks like I have some competition.

Very well done :wink:

Did you use gm_getValue/gm_setValue to save data?

PostPosted: Sun Jul 02, 2006 1:09 pm
by MrsMad
lol *friendly competition*

I'll be taking the 'attacker rolls xxx defender rolls xx ' line and extracting the data from that then using those gm_getvalue and gm_setvalue. What u see there is just the html at the mo.

I'm thinking, it shouldnt be too difficult to create 2 different views. One for the current game and one for all the games u've played - each games data could be stored in a single setvalue string. Would be interesting just to see how lucky/unlucky u've been each game.

PostPosted: Sun Jul 02, 2006 1:10 pm
by Pilate
Jota wrote:So you've finished doing a full statistical analysis of all die roll results over an extended period of time already, Pilate? Could you please publish your raw data and collection methods so that we can all confirm your conclusions?

I remember someone saying that the nice are not fully random, but they are as random as they can get.

For, 3 v 1 rolls. If you have 6 v1 and you attack up to three times (6v1, 5v1, 4v1) you should expect to NOT GAIN the territory one out of every 27.7 tries. I think the true value is significantly less than 27.7.

Actually, anyone can do a simple analysis.

Look at all the times you go three dice vs 1. You should expect to win 2 territories for every troop you lose. Make note of all the times that your success - troop lost ratio EXCEEDS 2. You'll notice that this happens very seldomly.

It's not random, but at least it's consistently not random. That's why i'm fine with the dice.

PostPosted: Sun Jul 02, 2006 1:17 pm
by Pilate
wacicha wrote:dang Pilate you can do that kind of thinking and still kick my butt. good job


lololo, 9 years of schooling pays off.

I think I'm going to learn the math all over again when i go to teacher's college too.

PostPosted: Sun Jul 02, 2006 1:43 pm
by joeyjordison
hey. still doin GCSE maths so i'm a long way behind u guys but i hav had a go at determining the likeliness of each dice combination using the method where u write the possible outcomes eg 1-6 and then the possible outcomes after those. so with 3 dice there are 3 columns looking something like this.

1-1
-2
-3
-4
-5
-6

only there is a third column and it is done for all the combinations. i then put in the fractions so 1/6 chance for each dice roll. my results showed pretty much the same as urs leading to the conclusion that the dice are biased to the defender.

please correct me if i hav gone wrong somewhere.

PostPosted: Sun Jul 02, 2006 1:54 pm
by Jota
Pilate wrote:Actually, anyone can do a simple analysis.
Look at all the times you go three dice vs 1.


Yes, please do this. Until you have actually done it, using statistically consistent methods, you have no justification for making any claims about the dice either way.

PostPosted: Sun Jul 02, 2006 1:57 pm
by qeee1
Joey... that post made no sense to me.

And I think you can make claims about the dice, without doing analysis, but should preface them by saying, "it seems to me" or something of the sort.

Anyway look forward to the results.

PostPosted: Sun Jul 02, 2006 3:26 pm
by Pilate
Jota wrote:
Pilate wrote:Actually, anyone can do a simple analysis.
Look at all the times you go three dice vs 1.


Yes, please do this. Until you have actually done it, using statistically consistent methods, you have no justification for making any claims about the dice either way.


have you ever heard of gregor mendel? If he used your methods, we might not know about genes and alleles

PostPosted: Mon Jul 03, 2006 1:33 pm
by Pedronicus
How long before enough data has been gathered to obtain a good gauge of dice?

PostPosted: Mon Jul 03, 2006 1:40 pm
by Jota
A few hundred rolls, maybe? There are formulas that will let you calculate your confidence level based on how many data you've accumulated, but I don't remember any of them off the top of my head.

PostPosted: Mon Jul 03, 2006 1:51 pm
by Pilate
no, a sample size of about 50 is definitely enough. i'm too lazy to check my stats textbook right now

PostPosted: Mon Jul 03, 2006 1:54 pm
by AndyDufresne
I'd go for more than 50. More people would be willing to believe the results if there was a large test field.


--Andy

PostPosted: Mon Jul 03, 2006 2:08 pm
by MrsMad
I would imagine more like 1000 dice. But it's a guess.

luck analyzer coming soon.....

Image