Darts Scoring Algorithm

The following diagram explains how a dart is allocated a score in a game of darts.

To calculate the score of an arrow based on its (x,y) coordinates we will use two calculations:

  • The distance of the arrow from the centre of the target,
  • The angle matching the arrow position.

Calculating the distance

To calculate the distance of the arrow from the centre of the target, we will use the Pythagora’s Theorem:
You can review this blog post where we have used a similar approach to calculate the score of an arrow in a game of archery.

We will then be able to use this distance to check where the arrow landed:

  • Bull’s Eyes (Red inner circle)
  • Bull (Green inner circle)
  • On target (Black or white zones)
  • On the triple ring
  • On the double ring
  • Outside of the target

To do so you will need the dimensions of the target (in pixels). These are given on the diagram below:

Calculating the angle

To calculate the angle we will use the trigonometric formulas (SOCATOA):

Using the following angles your program can then figure out the score for the arrow:

Complete the code

Check the code below used to display the dartboard and to throw an arrow by generating random (x,y) coordinates.

Complete the code to calculate both the distance and the angle of the arrow based on the (x,y) coordinates of the arrow. Use this information to find out the actual score of the arrow.

Extension Task

Adapt your code so that the computer throws three darts. Your script should then calculate the total score of the three darts.


The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 4.2 / 5. Vote count: 20

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,