Saturday, July 7, 2012

Calculation of the optimal darts strategy


In the game of darts, players throw darts at a board to score points.
The circular board has a 'bulls-eye' in the center and 20 slices
called sections, numbered 1 to 20, radiating out from the bulls-eye.
The board is also divided into concentric rings.  The bulls-eye has
two rings: an outer 'single' ring and an inner 'double' ring.  Each
section is divided into 4 rings: starting at the center we have a
thick single ring, a thin triple ring, another thick single ring, and
a thin double ring.  A ring/section combination is called a 'target';
they have names like 'S20', 'D20' and 'T20' for single, double, and
triple 20, respectively; these score 20, 40, and 60 points. The
bulls-eyes are named 'SB' and 'DB', worth 25 and 50 points
respectively.

There are several variants of darts play; in the game called '501',
each player throws three darts per turn, adding up points until they
total exactly 501. However, the final dart must be in a double ring.


Often there are several ways to achieve a total.  You must return a
shortest possible list.

It was tasked to create a program to solve this problem. I used Python  and Google Application Engine for this. First of all I've defined shortest way to win from each point of the game. For example , your current score is 170 and the program calculates that the shortest way to win is T20,T20 and DB (bull-eye)  . But real darts players have different accuracy. I've used the simple test for the player's accuracy. He should hit bull-eye 100 times and calculate his correct hits. The program recalculates this value in Gaussian deviation and defines probability of hitting each target on the darts board. After that the program shows optimal targets for a next turn. If  your accuracy more than 50% the program show the shortest way to win, but if you're not a such experienced player  the program will recommend  a more likely way to achieve the win.
I've implemented the optimal strategy algorithm in the small web application in GAE. You can see it here Darts Strategy  I think it will work on Android and iPhone too.