I've said it before, and I'll say it again. I very much dislike playing against CPU players that aren't better, just luckier. A classic example of this can be found in nearly every backgammon game for mobile phones. The hard CPU players just roll better dice all the time. I found this out by noting down the dice rolled on paper over 20 games, the CPU rolled way better dice. It's a short cut to making the game more difficult. Making better CPU players is a hard problem to solve, it's much easier just to give them better dice.

This drives me mad, so I made a specific decision to code a more intelligent CPU player, one that would make informed decisions like a human but would still be at the mercy of the dice. That is how I have coded all three CPU players.

Cautious and Reckless basically follow the same rules:

- Always go with the highest scoring option every time
- If it's the final round then keep on rolling until you either zilch or have more points than the opponent
- If using all the score options results in a free roll, take it
- If any scoring option is a free roll, take it
- If you have more than X points on the board, bank them
- If there are more than Y dice left unused, roll again

For cautious and reckless, X and Y are slightly different, as their names would suggest. Reckless is more likely to roll with fewer dice, Cautious has a lower X threshold so will bank fewer points each time but should avoid zilching more often.

The Realist player has much more human-like strategy coded in. It will look for free rolls using combinations of scoring options, it will avoid the third zilch where possible, it will choose a single 1 over three 2's if possible, it will take a single 1 from a pair to increase the number of dice left to roll, all of this on top of the standard strategies employed by the Cautious and Reckless players.

The Realist player has much more human-like strategy coded in. It will look for free rolls using combinations of scoring options, it will avoid the third zilch where possible, it will choose a single 1 over three 2's if possible, it will take a single 1 from a pair to increase the number of dice left to roll, all of this on top of the standard strategies employed by the Cautious and Reckless players.

There isn't a single line of code that nudges the dice in the favour of either the CPU or the human players, not one. It's all strategy. What do we learn from this?

- Sometimes it pays to be reckless
- Nobody likes losing a game of chance
- The dice have the final say

It's completely random, I promise.

## 57 comments:

And that's the way it should be. Good on you.

The game freezes from time to time whenever the game gives a warning to the CPU player. Otherwise it's a great game.

I like the game and I really appreciate trying to improve the AI rather than cheat. But the AIs are still very simple. I suggest a marginal approach, make it be more actively reckless as the distance between the players increases.

Things to consider:

- if you have a significant advantage, it pays to be reckless and try to get the high score

- if the overall trend of the opponent shows he will reach 10000 first, you must become more reckless or less in order to get "trendier"

- nobody likes to lose, therefore the AI should mimic some basic emotions

- learn from mistakes. Like remember past games.

- AIs should strive for awards as well, no?

Anyway, congratulations.

Thanks for the explanation. It looked fair to me...sounds like a case of "confirmation bias" with some of the players. They think the dice are rigged so whenever the CPU gets a good roll that expectation is reinforced. Bad CPU rolls don't have the opposite effect.

I noticed the achievements are not all being saved (over at kongregate). Why is this? Is there anything the player must do to ensure they're saved, e.g. start a new game?

Thanks for the game. Know anyone that can do a best strategy statistical analysis on this (bank x with y dice remaining to get the best scoring odds?, etc)? I'll look at Wizard of Odds and let you know.

I absolutely LOVE this game. It's very intelligently designed, pleasant to spend time with, and of course lots of fun to play.

Have you thought about making Zilch an application for the iPhone? This is the first game I can actually see myself paying for and using. It's quick enough to play while waiting in line (unlike others), pretty enough to sell a lot of, and it would be nice to be able to keep awards after closing the game.

What do you think?

Way to go man. I hate games that have obviously rigged CPUs. It's just frustrating when you play well and get screwed by the not so "random" chances. Love this game. I'm with the last guy though. I would deffo download this for iPhone if you made it for a buck or two, and you could make a ton of money.

If you do decide to make an iPhone version I write iPhone game reviews for a website, so let me know, and I'd be happy to help get the word out with a good review.

Fun game, but the source code link on Kongregate is broken.

Also, the cpu starts every game with 500 points. If you want to insist on making the CPU have the same RNG as the human, you should also take away the starting advantage for the CPU

"Also, the cpu starts every game with 500 points."

What game are you playing? The one on Kong doesn't start with 500 points, at least not in the hours I played it today.

Yeah. The computer actually zilched and had -500 points one of the rounds I played, so I'm with Paul on this one.

I wish I could reproduce. I started 5 or 6 games yesterday, and in every one (regardless of who went first, the difficulty, etc) the opponent started with 500 points. Today, I can't get it to happen again....

Yes, that was a mistake on my part. I was trying to test what happens when scores are equal and the lead changes, as well as the lead changing in reverse when points are lost. I accidentally left some debug code in there which left 500 points already on the CPU scoreboard at the start. I corrected the problem within 15 minutes of uploading but some players will have seen this wrong version in the meantime.

My bad!

Wow,

Good to know I'm not crazy. Thanks for making a great game, Gaby.

Great Game! Thanks!

Couple of things. The Bank button shouldn't end my turn if I have a Free Roll coming. The Bank button should take any unclaimed points.

It is your own fault if you click the Bank button if you have any unclaimed points or a free roll coming.

A few more games under my belt and I see where I might want to leave points unclaimed. That extends to abandoning a free roll. So, yes, it is my own fault if I don't click the right button for what I want to do.

so when then when I take your game and record down what the computer does and about 15/20 times the computer gets over 1500 points that means its not rigged? And then I somehow manage to get 8 zilches in row? Go back to making games like duck hunter for the calculator and leave the game making to professionals

Well bogdan, thanks for stopping by. Now go play a game you enjoy and leave us to play Zilch, which we enjoy. Don't let the door hit you in the back. And look both ways before crossing the street - you're clearly an unlucky fellow.

I don't think bogdan understands how the bank button works.

gaby,

i'd like to make a clone of this game in javascript. any objections?

Good luck!

Sorry, I don't believe you that your game isn't rigged. I'll only believe the code if I can see it. There's no other explanation for having multiple occurrences of hitting 10,000 points when the CPU is at 5,000 and then watching the CPU get 6,000+ points on its final rolls. There is also no other explanation for watching the CPU get one zilch per game versus my 7 or 8 - with no opportunities to score 300 points during my run of zilches.

Gaby,

I started doing an analysis of this game on my blog. Check out Viviomancy on Blogspot. If you want my source after I'm done searching the game space, let me know. I've already had some good results with looking at the 2-2-2-5-X-Y case (where taking the 5 is your best move). I hope to eventually develop a "book" strategy for this game. Let me know if you have any questions...

--Nate

@kenny: http://blog.playr.co.uk/2008/11/random-it-is-random.html

ive played 10+ games... the number of zilches i get from not being able to score at all (1/5 then 1/5/nothing then nothing) is MUCH higher than the CPU. ive gotten it 12 times ive counted. on the other hand the CPU has rolled straight after straight or 3 pairs about the same amount as ive had unavoidable zilches.

Sometimes realist seems to miss points when banking. When it rolls five dice and gets 3 sixes and a lone five, I think I've seen it leave the five.

Great game, great interface.

Thank you.

o rigged I mean come on what are the odds that it gets a 123456 then gets 3 pairs then gets nothing then gets 5 sixes then banks

*sigh*

I wish it was illegal for someone to start a sentence with "what are the odds..." unless they've taken a basic statistics course and actually know what "odds" are. Repeat after me:

"Unlikely Does Not Mean Impossible". Given enough opportunities, *every* possible combination of dice rolls *will* happen to *someone*.

To whit: With 6 6-sided dice, where the order of the dice does not matter (that is, 1-1-1-5-5-5 is the same as 5-5-5-1-1-1), there are only (6 + 6 - 1)! / 6! * (6 - 1)!, or 462, possible rolls.

Since there is only 1 roll that is 1-2-3-4-5-6, obviously the odds are 1:462 of rolling that. There are 5 ways to roll 5 sixes, so the odds of that are 5:460. There are multiple ways to roll 3 pair, or no score, so the odds are better than 1:462 of rolling any one of those (and the math there hurts my brain).

*Worst* case, the odds of the computer rolling the exact sequence of 4 rolls you saw in your game is 1 : 45,558,341,136. Considering a typical game may include upwards of 100 rolls, that means you should see exactly that roll of dice about once ever 400 million games, which is really a not-unreasonable number given the number of games being played.

*applause*

Thank you. I've been waiting for someone to actually explain the odds of these things happening. I really didn't want to have to think that much xD

@kutulu: that's all good and well, but you're forgetting the fact that each dice roll is independent of the other, so while the same roll happening in a different order counts the same, it is in fact a different roll. there are actually 6^6 rolls possible, or 46,656 rolls. the number of ways to roll a straight for instance, is 6!, or 720. 720/46656 = .01543, or ~1.5%. Seems high, but start counting...123456, 123465, 123546, 123564, 123645, 123654, etc., and you'll find that it is indeed true! 1 out of 64.8 is a little ridiculous :)

to whoever saw 3 straights in a row, the probability of that is .01543^3, or .000003675, so 3.675 out of 1 million, or roughly 1 out of 272,098. So yes, it can and will happen...to someone. XD

For those who care, here are the probabilities:

6 of a #, 1 out of 46656, 0.002143%

5 of a #, 30 out of 46656, 0.0643%

~1 out of 1555

4 of a #, 375 out of 46656, 0.8038%

~1 out of 125

Straight, 720 out of 46656, 1.543%

~1 out of 65

3 Pair, 2256 out of 46656, 4.8354%

~1 out of 20

3 of a #, 2500 out of 46656, 5.358%

~1 out of 19

No score, 4096 out of 46656, 8.779%

~1 out of 11

2 1's, 9375 out of 46656, 20.09%

2 5's, 9375 out of 46656, 20.09%

~1 out of 5

1 1, 18750 out of 46656, 40.19%

1 5, 18750 out of 46656, 40.19%

~2 out of 5

Notes:

better "of a #" are not included...meaning, to count possible rolls of 5 1's, I am NOT including 6 1's in that count. You would obviously take the 6 1's instead of the 5!! ;)

However, the "No score" count is NOT removing the possibility of 2 "3 of a #'s" or a "4 of a #", or 3 pairs, as well, the "3 pair" count is not removing the possibility of "No Score" or "4 of a #". This is b/c in the game you have the choice of what to take!

Enjoy!

Fireshock

What I believe is happening is that you are talking about rolls, while Kutulu is talking about outcomes. His formula counts 1-2-1-2-1-2 and 1-1-1-2-2-2 as the same, while yours counts every single one independently. Yours is actually more accurate because while there may only be 462 different outcomes (I'm too lazy to check if this is right) some of them have more than a 1/462 chance of occurring, and some have less than a 1/462 chance of occurring (there is only one way to roll six 1s but many ways to roll one 1).

And, correct me if I'm wrong, but there are only 36 ways to roll a straight (1-2-3-4-5-6), definitely not 720. There are 6 die, and each of them can have 1 of 6 numbers on them, and none of them can repeat. So, there are 6*6 or 36 different ways to roll this. Now, while the way I explained it may not be perfect I challenge anyone to list 37 ways to roll a straight.

123456, 123465, 123546, 123564, 123645, 123654, 124356, 124365, 124536, 124563, 124635, 124653, 125346, 125364, 125436, 125463, 125634, 125643, 126345, 126354, 126435, 126453, 126534, 126543, 132456, 132465, 132546, 132564, 132645, 132654, 134256, 134265, 134526, 134562, 134625, 134652, 135246, 135264, 135426, 135462, 135624, 135642, 136245, 136254, 136425, 136452, 136524, 136542.

I believe thats 48...and those are only the ones that begin with "12" or "13". there are 24 for each combination of 2 numbers to begin with...of which there are 30(11,22,33,44,55,66 don't count, 36-6=30), and 24*30=720 XD

You have no life xD

But I concede to you. I believe I am still correct about the first paragraph however.

haha, no i don't ;) i didn't want to have to write all those out, but thinking about it got me curious, and now...i don't lose this game anymore? haha. your first paragraph is true, i'll give you that, and from kutulu's numbers, out of all the DIFFERENT rolls you can have, those ratios are correct, then his ratios should be 1:461 and 5:457 though...because ratios add up to the possible outcomes. but if you're actually looking for the percentages to do say, expected outcomes, then mine will help you out a little more ;)

Hi sorry for my english. I like very much your game, it's a nice way to pass an hour... I played many games and I'm conviced it's random. But I have a suggestion about the behavior of the realist cpu player. An example: after the first shot he bank three dices and reshot, bank two dices with a total of 900 a risk another shot (sometimes even I risk, it's a game...) and gain 1 or 5 e reshot all six dices. This time he have just a 1, can reshot the other 5 dices again but he banks 1000 point and he doesn't shot anymore. It's a strange strategy: you can reshot 5 dices I'll try without doubts. I saw this behavior 4-5 times in a hundred games. Can improve the AI of the realist? It would make the game better.

If those rules are the rest, I think it is better to add one more rules

If i-1 and i-2 are zilch (for reckless)

If i-1 are zilch (for cautious and realist) ,then bank if >=300

It can be more... clever =]

First and foremost, thanks for bringing this game to the Internet. I've had a lot of fun figuring out the strategies and railing against the various opponents. I've made it past 90 awards, and I'm slowing down on that aspect of the game. I'm not one to zilch 10 times in a row just because there's a merit badge for it. In case anyone's looking for my ID, I'm playing through BrainBashers, so you won't see me on The Lists.

I quite agree with your take on AIs that cheat. I did my graduate work in AI, and I find it ... well, I use the euphemism "inelegant". I'm sure many of you can read what I'm actually thinking. I quit playing the on-line backgammon games for exactly that reason, and I've tapered off Dice Wars to the level of mental chewing gum.

However, there are problems with the implementation of Zilch. The RNG is simply not up to your assertion of "totally random". I suspect that the RNG you're using is a linear congruential algorithm with a 32-bit value. This is fine for small sequences of die-rolling, but it just doesn't cut the mustard for the longer ones.

Consider an all-too-typical turn in Zilch: roll, score one die, roll 5 score one, and so on, until you bank with two dice at large. This is a total of 6+5+4+3 or 18 die rolls. In order to cover all the permutations of dice, you need your RNG to have a period of at least 6^18. In order to pass a simple chi-squared test for randomness, you'll need at least four times that. Note that this doesn't cover "complete randomness" for the "Reckless" AI, which stretches to 20 dice at times. This also fails to account for the extra rolls generated by free turns / rollovers.

To cover all of this, you'll need either a more complex RNG with a longer seed value, or more bits in the stored value (which reduce to the same concept). You'll need about 56 bits for a decent random pattern. For fewer than 51 bits, any sequence of 17 rolls reveals the remaining sequence deterministically (tedious, but deterministic).

Frankly, I don't think it's worth the trouble. Yes, the given RNG favors the consistent style of the AI's somewhat. Good strategy is sufficient to overcome the inherent advantages -- they're not that strong. I've collected some statistics on "hot" rolling, which I'll try to summarize in a future posting.

Briefly, I'll put it this way: for those who think the AIs have a non-random advantage, you're right ... but not nearly as much as you think you are. Play well, and you'll still beat any of the AIs on a regular basis. I'm managing about 60% against "Realistic", myself, and I'm hardly an expert.death2

great game. I'm sure I'm seeing Realist rolling a pair of ones, taking the score, but then only leaving a single one dice frozen when moving to the next roll. again, super fun, but it looks to me like realist is taking an edge by having more dive to roll after scoring.

jason, if you watch closely, I believe you'll find that Realist takes only 100 points in that case (for the single ace it's scoring). As Gaby already told us, one of the advantages of the Realist strategy is that it knows how to split a pair.

It's time for statistics. Like many posters before me, I got suspicious of the NPC's (non-player contestant's) ability to get great dice more often than I did. Of course, my first hypothesis was that it was the novelty effect: I tended to remember the events that deviated from my expectations. Since we generally expect to win, I suspected that I simply remembered unusual losses more readily.

I tried counting really good turns on each side. The numbers came up in favor of the NPC quite more often than for me. I refined my gut feeling of "unusual good luck" from an emotional "surprise" count to a set of measurable standards, and revised those. I also tried counting undeserved zilches, but that muddied the waters somewhat.

I finally settled on criteria and designed the experiment:

(1) Play fifty games against each opponent, no quitting, played to the end.

(2) Count "good luck" as either (a) any single roll of 500 points or more; (b) winning a free roll with only 1 or 2 dice.

(3) I play with what I consider a relatively strong strategy, fairly close to that of realistic (see below).

(4) Test the hypothesis that the NPCs get better luck than I do, using a one-tailed T-test, p>.98 for each NPC (reckless, cautious, and realistic). I picked .98 because I wanted something in the range of .95 for *any* of the three looking like a cheater.

(5) The T-test was performed on the set of 50 proportions, the fraction of total "good luck" rolls accumulated by the NPC. For instance, if I got 4 good rolls to the CPU's 6, that would be a score of 0.60 for that game. Using this proportion helped to normalize the figures between long and short games.

My strategy:

(a) Any time I get a free roll, take it.

(b) If I get at least 400 points available on a roll, grab everything available and bank it.

(c) With a "cheap" roll (a smattering of 1's and 5's, perhaps three 2's), take the highest-scoring single die available and roll again.

(d) Once I get to 1 or 2 dice left, bank as soon as I have the required 300 points.

For instance, if I start with three 3's, I'll roll once more, grab it, and bank it. If I have 350 points and 2 dice left, I bank it. If I start with a 1, a 5, and three 2's, I'll take the single 1 and roll 5 dice.

To summarize the results:

Reckless:

CPU 479

me 337

t-score 1.0000

Cautious:

CPU 363

me 312

t-score 0.9846

Realistic

CPU 434

me 367

t-score 0.9941

In short, the preliminary conclusion is that something is stacking the deck in favor of the NPCs (CPU players). It's not overwhelming: I won over half the games against each NPC.

38-12 against Reckless

28-22 against Cautious

33-17 against Realistic

So, what are the confounding factors? For one thing, the number of opportunities for good luck: typically, how many times I roll with at least 3 dice. I kept track of the rolls available for at least 10 games near the middle of each of these test runs.

Reckless took more rolls with 1 or 2 dice than I did; however, I had a compensating number of rolls with 3-5 dice, as Reckless does not take one of two 1's or 5's. With Cautious and Realistic, I had slightly more rolls at each number of dice 3-5; Realistic had a couple more rolls at 1-2 dice, overbalanced by my totals at 3-5.

In short, the simple computation of odds suggests that I should have more good rolls than the NPCs. So, how did I win more games? My observations suggest that my strategy is a little less prone to zilches than Cautious or Realistic, much more so than Reckless. I seem to squeeze a little more (on the average) from a turn than the others. Over 50 games at an average of 15-20 turns each, that small difference adds up to a few more wins.

So, now what do I conclude? Since we've been through the pain of the accusations of outright biasing the code, we're left with (1) finding a flaw in the experiment; (2) finding a flaw in the code; (3) some other explanation.

I invite comments on any of these. As far as a flaw in the code, I posted my worries above, dated 27 November. It's *possible* that the very regularity of the strategies *happens* to "stick" the NPCs into favorable cycles peculiar to the RNG: e.g. there are certain sequences of die rolls that the NPC strategies will stumble into, where the human players tend to make other decisions.

Anyway, there are the figures. I'd love to see some other ideas of what causes the bias in the above results. The given figures are simply too lopsided to dismiss as random variation.

First, thank you for this great game. I've already played it IRL with lots of friends and some different rules. But i 'm really happy to play it again.

A thing I have noticed with the Realist AI several times. And i think it's a bad choice :

_ the AI keep 3 dices then roll

_ it takes 2 "one" and choose to keep one and roll again.

I don't think this is a good choice because there is no combination with 2 dices. It should keep the 2 dices to bank or roll the last. there is no advantage to keep only one dice and roll the 2 last at this point.

A great game - I haven't place since I used to play D & D (the real,dice-rolling version) and we used it as a tavern game - would you consider doing a version for the iphone? I would definitely buy it !!

Fireshock,your absolutely correct about independent dice. Permutations matter, combinations don't. However when I add up your numbers, I come up with 80,758 - not 46,656. Also I don't see where you took into account: 1) 2 Ones w/ 2 Fives,x,y {where x,y,z are garbage}, 2) 2 Ones w/ a Five,x,y,z, 3) 1 One w/ a Five,x,x,y,z or, 4) 1 One w/ pair Fives,x,y,z. Your 4 of Kind # is inflated - you counted 4 of a Kind w/ a Pair as 4 of Kind instead of as 3 Pair. Except for 4 Ones w/ pair a person would take it as 3 Pair(more points & rolling all). Your 3 Pair # - I don't get it. Your 3 of a Kind # appears to count Double 3 of a Kinds twice.

6 dice probabilities:

6 of Kind=6/46,656

5 of Kind=180/46,656

Lg. Straight=720/46,656

4 of Kind=1875/46,656 consist of:

4 Ones=375

4 Other#=300 each

3 Pair=2175

3 of Kind=14,700/46,656 consist of:

Double 3 of Kind=300

Other 3 of Kind=14,400

Ordinary Rolls{1(s) &/or 5(s) only}=25,920/46,656 consist of:

2 Ones/2 Fives=1080

2 Ones/ 1 Five=3600

2 Ones=2520

1 One=3600

1 One/1 Five=5400

1 One/2 Fives=3600

2 Fives=2520

1 Five=3600

Zilch=1080/46,656

Also of note for those who carp about the CPU cheating:

the odds of Zilch w/6 dice is 1080/46,656 (about 2.3%). The odds of scoring all 6 dice is 3,876/46,656 (about 8.3%, a one in 12 shot, 3 1/2 times more common than Zilch), not very rare.

When rolling 5 dice:

Zilch=600/7,776

Score All=236/7,776

When rolling 4 dice:

Zilch=204/1,296

Score All=52/1,296

When rolling 3 dice:

Zilch=60/216

Score All=12/216

When rolling 2 dice:

Zilch=16/36

Score All=4/36

Unfortunatly, although I (more likely we) would like it this way, it is not in any way based on luck. It is a computer program, so there must be a loop, somewhere, sometime. Either a loop or a cause effect relationship. The loop would mean it would choose any spot on its predetermined sequence and go from there, until a predesignated event occurs (reaching the end of the loop, new game, new session, etc.). At which point it will choose a different spot, either predetermined or based on user interaction, to start again. No computer program is completely random. A cause-effect would be the linear equation mentioned earlier. It will give large bonuses for playing poorly and visa-versa, much like casino video slots do. This in turn will show that either the game will tip in balence of a poor or neutral player, or will repeat it's sequence. I should mention that I feel so strongly about this issue that I created this account for the sole pupose of the discussion.

Btw, I would buy the iPhone version of this if you make it... if I had an iPhone.

http://www.welovemacs.com/One Stop Store for iphone, Bluetooth Product, imac memory,iPOD Accessories, video cards, networking, software and so on.http://www.memoryx.net/ provides easy way to find any type of memory, like -

computer memory, apple memory, compaq memory,flash memory. You can make best deal out of it.Not sure it IS in fact random when "straights" (1-6 in one roll) are EXTREMELY COMMON and sometimes come one after the other. That just doesn't happen in the real world. And when it does, it happens seldom, not every other game. I'd like to see someone record some rolls and give it a proper analysis. Are you using random.org? Because if you aren't, it isn't random.

online casino is a big game.many people contribute your money.it is a big gambling.

Online casino bonus

this blog is very informative and helpful.and his post very nice.

botox

Many institutions limit access to their online information. Making this information available will be an asset to all.

Custom Research Papers

Thank you for this post. I am new to your blog and get really very nice. I will keep visiting your blog.Great detailed information.

asian escorts London

Great article, I agree completely

http://www.eatcity.co.uk

I'll admit that there were games where, try as it might, the realist was rolling dead and couldn't catch a break. These games do happen. My reason for giving up on this stupid game is because of how often stupid luck hits the realist. Getting three blackjacks in a rowis blind luck, hitting on 20 three times in three hands and getting 21 every time is stupid luck. I had played about a hundred games using its strategy, in those hundred games its highest roll was (seriously) 7500, where mine never went beyond 4000. Also, it is nearly impossibly to earn the no-zilch badge, I still haven't accomplished that feat.

almost a believable lie. would be more believable if the easiest computer didnt get 2000+ points on every roll and all i ever get is a 1 or 5

Post a Comment