I was looking at the Bowling Game kata (kata being a repetitive coding task favored by Software Craftsmanship types) recently and kept getting distracted by the rules of the game of bowling. At the risk of sounding ignorant I thought the score was simply the sum of all the pins you knock down, again and again. That's all Wii Sports taught me on the topic, but turns out there are other rules and I'm just coming out with it, they make no sense.
What game has a more rational set of unambiguous rules? Why cricket of course.
The cricket game kata
I thus propose an alternate approach to this kata by substituting the rules of scoring Cricket, or as many of them as the exercise calls for. If you get to awarding a 5 run penalty under Law 43 let me know and I will buy you a doughnut.
The scoring rules could be kept to a set around the same size as the Bowling Game kata:
- 6 legal deliveries allowed per over.
- Runs are scored for the striking batsman each time the batsmen cross and make the crease at the other end.
- 1 run awarded as extras for each No Ball or Wide.
- Runs scored are counted against the bowler delivering them.
- 4 or 6 runs are scored for the striking batsman for each boundary.
That should do it, at least for the purpose of the Bowling Game kata.
I'm a bit busy to hash out code on this version right now - as Bob says in his oft' cited post introducing this kata "Move slowly and deliberately. DO NOT RUSH". I'm afraid that rules me out this afternoon, more news to follow...