15
Preface
As I was shooting an archery 900 round earlier today (10 ends at 6 arrows an end, and 10 ends at 3 arrows an end, for a total of 90 arrows and a maximum score of 900), I thought of this challenge.
In archery (assuming that you are shooting on a FITA supplied target face [the piece of paper that you shoot at]), for each arrow you can claim a maximum score of 10. The target face contains 10 or 11 rings of decreasing diameter, nested inside one another. From the inner ring outward, these are counted from 10 points, to one point (and in the case of 11 rings, there is a secondary innermost ring that counts as 'X', which scores as 10 but is used in tie breaking cases as the higher value). Observe:
Of course, I am referring to the FITA Metric scoring, as seen in the above illustration. If you look closely, you may observe the innermost ring, which is a faded dotted line, whose score is not marked. That is the 'X' that I was referring to, but you will not have to pay heed to that unless competing for the bonus.
Challenge
Create a function (or full program, if the language doesn't support functions), that receives a perfectly square image as input (or image filename, if need be), containing some number of green (HEX #00FF00, RGB(0, 255, 0)) dots of some size, and returns the score. The image may contain data other than the green dots, but the green will always be the exact same shade.
You may imagine that the square image represents the target face, with the outermost ring touching at 4 points (top center, bottom center, right center, left center). The represented target face will always be of the same proportion, with all of the rings having a width of exactly 1/20th of the input target image's width. As an example, given an input image of input dimensions 400px by 400px, you may assume that each ring has an inner width of 20px, as illustrated below:
Clarifications
- If touching two seperate rings, the higher of the two rings is counted
- You do not have to automatically account for misses or the 'x' case, unless trying for the bonus
- You may assume that no green circles are overlapping
- You may also assume that no other pixels of that shade of green are in the image
- The image will either be in a PNG, JPEG or PPM format (your choice)
- External image processing libraries are allowed, if authored before the posting of this question
- You may assume that all green circles on one target will have the same diameter
- If shooting (hah) for the overlapping circles bonus, you may assume that at least one circle in the image does not have another overlapping
- Standard loopholes are disallowed
Test cases
The following two cases should each score 52 (or in the case of bonuses, 52 with 1 'x' and 1 miss):
And this last test case should score 25:
Bonus
- -25 bytes if you also return the number of misses (outside any of the rings) as well
- -30 bytes if you also return the amount of Xs (assume that the innermost x is 3/100ths of the width of the image, and 10 is then 2/100ths of the width of the image. The 1-9 proportions remain unchanged)
- -35% byte count if you account for overlapping circles
This is code golf, so the least bytes wins. Have fun!
"30 ends at 3 arrows an end, for a total of 30 arrows"? Shouldn't that be 90 arrows? – DavidC – 2014-12-29T03:48:44.260
@DavidCarraher I realized that right as I posted. Corrected – globby – 2014-12-29T03:50:54.343
What image formats can we use? PNG? PPM? Our own custom format? (I would assume the first two but not the third, but just for clarification.) – Doorknob – 2014-12-29T04:26:37.297
Let's say just JPEG or PNG for simplicity @Doorknob冰 – globby – 2014-12-29T04:32:51.630
Hmm... that might make it difficult for languages without built-in image manipulation libraries. Could we get PPM support too?
– Doorknob – 2014-12-29T04:34:03.043@Doorknob冰 sure. External libraries are permitted within reason, as long as created pre-posting of the question – globby – 2014-12-29T04:36:34.187
1I think the hardest bonus is the one with the least reward. – Justin – 2014-12-29T09:12:57.470
"The least reward" is relative. The overlapping circles you mean? – globby – 2014-12-29T15:09:30.980
@Quincunx Is the new reward more on par? – globby – 2014-12-29T15:34:22.683
I think overlapping circles bonus is impossible. Even assuming that is no perfect overlap (2 hits in exactly the same pixel) an input with a single hit may be interpreted as very many hits of a smaller diameter that happen to be arranged in a circle. – nutki – 2014-12-31T10:19:08.740
@nutki I could add a clarification that there will always be one perfect hit that isn't overlapping, which they could use as a reference for the diameter – globby – 2014-12-31T17:28:16.533