Dice Cricket is a game I was introduced to as a child and have used as a way to pass time for years since. I couldn't find a Wikipedia page so I'll explain the rules below.
Dice Cricket Rules
Premise
Dice Cricket is a game similar to scoring a game of cricket as you watch it but rather than watching and recording the result, you are rolling a die and recording the result.
The results are recorded in a table as displayed at the bottom.
Display
Dice Cricket uses a specific display to show all the information happening.
The table has 11 rows. Each row represents a batter. The layout of the row is explained below.
+------+------------------------------+---------+-----+
| Name | Runs | How Out |Score|
+------+------------------------------+---------+-----+
- Name: The name must be a string made up entirely of letters, upper or lower case
- Runs: A batter can face 30 balls. Each ball can be one of
1 2 4 6 . /
. This will be explained in more detail below - How Out: The way the batter was out. Can be any of
Bowled, LBW (Leg Before Wicket), Caught, Retired or Not Out
- Score: The sum of all numbers in
Runs
How the Game Works
In a game, there are always 2 batters out on the pitch. The first player is by default the current batter and the second in the "off" batter.
A game is made up of "balls": each ball in a cricket match is represented by a dice roll. Each roll does a different command:
- 1,2,4 and 6 make the batter score that much. If 1 is rolled, the current batter becomes the "off" batter and the "off" batter becomes the current
- 3 is a "dot ball", meaning that nothing happens. It is represented in the
Runs
section as a.
and scores 0. A0
may not be used to represent it. - 5 is a wicket. If 5 is rolled, the current batter is "out", This means that a
/
is added to the runs and from then on, the batter cannot score anymore runs. The batter is then swapped with the next batter who has not batted. TheHow Out
section is a random choice of the possible ways to get out:Bowled, LBW, Caught
Example for a wicket (this is just for clarity, this isn't how its outputted)
player a is on 4,6,2,6,4
player b is on 6,4,2,6,6
player c hasn't batted
player a is current batter
WICKET!!!
player a is on 4,6,2,6,4,/
player b in on 6,4,2,6,6
player c is on NOTHING
player c is current batter
Every 6 balls, the two batters switch; the current batter becomes the "off" batter and the "off" batter becomes the current batter
If the Runs
section is filled (30 balls), the batter is out and the How Out
section is set to Retired
. A /
isn't placed at the end of the Runs
box.
Actual Challenge (yes all that was rules of the game)
Your challenge is to output a completed table (like the example at the end), given a list of names. The contents of the output should contain only the table and/or leading or trailing whitespace.
Rules
- Standard loopholes are disallowed
- All 11 players should have something in the
Runs
section. - Only 1 player can be
Not Out
. Every other non-retired player should be out of a choice of[Bowled, LBW, Caught]
- The names can be any length between 1 and 6 that matches the regex
A-Za-z
- The final line in the table should be the total line (see example)
- You don't have to align the text in the table in any way, but the row and column separators must be aligned.
Example
Input:
['Fred', 'Sonya', 'David', 'Ben', 'Cody', 'Hazel', 'Nina', 'Kim', 'Cath', 'Lena', 'Will']
Output:
+------+------------------------------+---------+-----+
| Name | Runs | How Out |Total|
+------+------------------------------+---------+-----+
|Fred |.662/ | Caught | 14 |
+------+------------------------------+---------+-----+
|Sonya |1164/ | Caught | 12 |
+------+------------------------------+---------+-----+
|David |/ | LBW | 0 |
+------+------------------------------+---------+-----+
|Ben |424/ | LBW | 10 |
+------+------------------------------+---------+-----+
|Cody |62/ | Bowled | 8 |
+------+------------------------------+---------+-----+
|Hazel |/ | LBW | 0 |
+------+------------------------------+---------+-----+
|Nina |161.6226166..44261442/ | Caught | 64 |
+------+------------------------------+---------+-----+
|Kim |11/ | Caught | 2 |
+------+------------------------------+---------+-----+
|Cath |6.21/ | LBW | 9 |
+------+------------------------------+---------+-----+
|Lena |/ | Bowled | 0 |
+------+------------------------------+---------+-----+
|Will |2 | Not Out | 2 |
+------+------------------------------+---------+-----+
| Total Runs | 121 |
+-----------------------------------------------+-----+