2 deleted 105 characters in body
source | link

Charcoal, 277277 255 bytes

F¹¹⊞υS≔⮌Eυκθ≔Eυ⟦⟧η≔Eυ⁰δW⊖Lθ«≔⊟θι≔‽⁶ε⊞§ηιε≔⎇⁼ε⁴⁺²‽³⁼L§ηι³⁰ε¿ε§≔διε⊞θι¿⊖Lθ¿⁼¬﹪ΣEηLκ⁶¬εF⟦⊟θ⊟θ⟧⊞θκ»≔EηΣ⭆ι§120406λζ”|⁴B\[⎇⁻℅↧T\`⁵·5KMK⟲M≦»→´⁶_⭆∨R▷↥l⁹KG…≦”F¹¹«◨§υι⁷◨⭆§ηι§12≔E¹¹⟦⟦⟧⁰S⟧θ≔⮌θηW⊖Lη«≔⊟ηι≔‽12.4/6κ³²§⪪”6ζ⊞υζ⊞§ι⁰ζ≔⎇⁼ζ/⁺²‽³⁼³⁰L§ι⁰ζ¿ζ§≔ι¹ζ⊞ηι¿⊖Lη¿⁼¬﹪Lυ⁶¬εF⟦⊟η⊟η⟧⊞ηκ»”|⁴B\[⎇⁻℅↧T`⁵·5KMK⟲M≦»→´⁶_⭆∨R▷↥l⁹KG…≦”Fθ«◨⊟ι⁷◨Σ§ι⁰¦³²§⪪”(3⪪⪫⧴πZJL:∨XI±URD↗Σ9⟦FZ∕↖l⪪”⁷§δι◧I§ζι⁶⸿⸿»”|QºWPD⟧zNφ[v?Π'vG”◧IΣζ²⁸J±¹±¹FE¹³⁻²⁷⊗ι«B⁵⁵ιB⁴⁹ι¿‹ι²⁷«B³⁹ιB⁸ι∨XI±URD↗Σ9⟦FZ∕↖l⪪”⁷⊟ι◧IΣE⊟ιΣκ⁶⸿⸿»”|QºWPD⟧zNφ[v?Π'vG”◧IΣEυΣι²⁸J±¹±¹FE¹³⁻²⁷⊗ι«B⁵⁵ιB⁴⁹ι¿‹ι²⁷«B³⁹ιB⁸ι

Try it online!Try it online! Link is to verbose version of code. Explanation:

F¹¹⊞υS≔E¹¹⟦⟦⟧⁰S⟧θ

Read in the 11 names. (Inputinput is flexible: JSON, space separated, or newline separated. 6 bytes could be saved) and create an array q of 11 batters, represented by requiring a double nested JSON format.their balls (as an array), status (as an integer) and name.

≔⮌Eυκθ≔⮌θη

Create an array q holdinga reversed copy of the numbersbatters 10..0h. This represents the batters that are not out. The last two elements are the off and current batters.

≔Eυ⟦⟧η

Create an array h holding the batter's balls.

≔Eυ⁰δ

Create an array d representing the batter's status.

W⊖Lθ«W⊖Lη«

Repeat while there are at least two batters available.

≔⊟θι≔⊟ηι

Extract the current batter to i.

≔‽⁶ε≔‽12.4/6ζ

Generate a random ball in ez.

⊞υζ

Add it to the overall list of balls using the predefined empty list (0-indexed)u.

⊞§ηιε⊞§ι⁰ζ

Add it to the current batter's balls.

≔⎇⁼ε⁵⁺²‽³⁼L§ηι³⁰ε≔⎇⁼ζ/⁺²‽³⁼³⁰L§ι⁰ζ

If the ball is a 5/, then generate a random status 2..4, otherwise if this is the batter's 30th ball then set the status to 1 otherwise 0.

¿ε§≔διε⊞θι¿ζ§≔ι¹ζ⊞ηι

If the batter is out then store the batter's status otherwise put the batter back in to bat.

¿⊖Lθ¿⁼¬﹪ΣEηLκ⁶¬ε¿⊖Lθ¿⁼¬﹪ΣEηLκ⁶¬ζ

If there are at least two batters left, and the batter was out xor 6 balls have been played, then...

F⟦⊟θ⊟θ⟧⊞θκ»F⟦⊟η⊟η⟧⊞ηκ»

...take the off and current batters and put them back in reverse order.

≔EηΣ⭆ι§120406λζ

Map each ball to its score and take the total for each batter in array z.

”|⁴B\[⎇⁻℅↧T`⁵·5KMK⟲M≦»→´⁶_⭆∨R▷↥l⁹KG…≦”

Print the header.

F¹¹«Fθ«

Loop over the batters.

◨§υι⁷◨⊟ι⁷

Print the batter's name.

◨⭆§ηι§12.4/6κ³²◨Σ§ι⁰¦³²

Print the batter's balls.

§⪪”(3⪪⪫⧴πZJL:∨XI±URD↗Σ9⟦FZ∕↖l⪪”⁷§δι∨XI±URD↗Σ9⟦FZ∕↖l⪪”⁷⊟ι

Print the batter's status by indexing into the string Not OutRetiredBowled Caught LBW split into substrings of length 7.

◧I§ζι⁶◧IΣE⊟ιΣκ⁶

Print the batter's score.

⸿⸿»

Move to the start of the next line but one.

”|QºWPD⟧zNφ[v?Π'vG”◧IΣζ²⁸”|QºWPD⟧zNφ[v?Π'vG”◧IΣEυΣι²⁸

Print the total.

J±¹±¹FE¹³⁻²⁷⊗ι«B⁵⁵ιB⁴⁹ι¿‹ι²⁷«B³⁹ιB⁸ι

Draw boxes around everything.

Charcoal, 277 bytes

F¹¹⊞υS≔⮌Eυκθ≔Eυ⟦⟧η≔Eυ⁰δW⊖Lθ«≔⊟θι≔‽⁶ε⊞§ηιε≔⎇⁼ε⁴⁺²‽³⁼L§ηι³⁰ε¿ε§≔διε⊞θι¿⊖Lθ¿⁼¬﹪ΣEηLκ⁶¬εF⟦⊟θ⊟θ⟧⊞θκ»≔EηΣ⭆ι§120406λζ”|⁴B\[⎇⁻℅↧T\`⁵·5KMK⟲M≦»→´⁶_⭆∨R▷↥l⁹KG…≦”F¹¹«◨§υι⁷◨⭆§ηι§12.4/6κ³²§⪪”(3⪪⪫⧴πZJL:∨XI±URD↗Σ9⟦FZ∕↖l⪪”⁷§δι◧I§ζι⁶⸿⸿»”|QºWPD⟧zNφ[v?Π'vG”◧IΣζ²⁸J±¹±¹FE¹³⁻²⁷⊗ι«B⁵⁵ιB⁴⁹ι¿‹ι²⁷«B³⁹ιB⁸ι

Try it online! Link is to verbose version of code. Explanation:

F¹¹⊞υS

Read in the 11 names. (Input is flexible: JSON, space separated, or newline separated. 6 bytes could be saved by requiring a double nested JSON format.)

≔⮌Eυκθ

Create an array q holding the numbers 10..0. This represents the batters. The last two elements are the off and current batters.

≔Eυ⟦⟧η

Create an array h holding the batter's balls.

≔Eυ⁰δ

Create an array d representing the batter's status.

W⊖Lθ«

Repeat while there are at least two batters available.

≔⊟θι

Extract the current batter.

≔‽⁶ε

Generate a random ball in e (0-indexed).

⊞§ηιε

Add it to the current batter's balls.

≔⎇⁼ε⁵⁺²‽³⁼L§ηι³⁰ε

If the ball is a 5, then generate a random status 2..4, otherwise if this is the batter's 30th ball then set the status to 1 otherwise 0.

¿ε§≔διε⊞θι

If the batter is out then store the batter's status otherwise put the batter back in to bat.

¿⊖Lθ¿⁼¬﹪ΣEηLκ⁶¬ε

If there are at least two batters left, and the batter was out xor 6 balls have been played, then...

F⟦⊟θ⊟θ⟧⊞θκ»

...take the off and current batters and put them back in reverse order.

≔EηΣ⭆ι§120406λζ

Map each ball to its score and take the total for each batter in array z.

”|⁴B\[⎇⁻℅↧T`⁵·5KMK⟲M≦»→´⁶_⭆∨R▷↥l⁹KG…≦”

Print the header.

F¹¹«

Loop over the batters.

◨§υι⁷

Print the batter's name.

◨⭆§ηι§12.4/6κ³²

Print the batter's balls.

§⪪”(3⪪⪫⧴πZJL:∨XI±URD↗Σ9⟦FZ∕↖l⪪”⁷§δι

Print the batter's status by indexing into the string Not OutRetiredBowled Caught LBW split into substrings of length 7.

◧I§ζι⁶

Print the batter's score.

⸿⸿»

Move to the start of the next line but one.

”|QºWPD⟧zNφ[v?Π'vG”◧IΣζ²⁸

Print the total.

J±¹±¹FE¹³⁻²⁷⊗ι«B⁵⁵ιB⁴⁹ι¿‹ι²⁷«B³⁹ιB⁸ι

Draw boxes around everything.

Charcoal, 277 255 bytes

≔E¹¹⟦⟦⟧⁰S⟧θ≔⮌θηW⊖Lη«≔⊟ηι≔‽12.4/6ζ⊞υζ⊞§ι⁰ζ≔⎇⁼ζ/⁺²‽³⁼³⁰L§ι⁰ζ¿ζ§≔ι¹ζ⊞ηι¿⊖Lη¿⁼¬﹪Lυ⁶¬εF⟦⊟η⊟η⟧⊞ηκ»”|⁴B\[⎇⁻℅↧T`⁵·5KMK⟲M≦»→´⁶_⭆∨R▷↥l⁹KG…≦”Fθ«◨⊟ι⁷◨Σ§ι⁰¦³²§⪪”(3⪪⪫⧴πZJL:∨XI±URD↗Σ9⟦FZ∕↖l⪪”⁷⊟ι◧IΣE⊟ιΣκ⁶⸿⸿»”|QºWPD⟧zNφ[v?Π'vG”◧IΣEυΣι²⁸J±¹±¹FE¹³⁻²⁷⊗ι«B⁵⁵ιB⁴⁹ι¿‹ι²⁷«B³⁹ιB⁸ι

Try it online! Link is to verbose version of code. Explanation:

≔E¹¹⟦⟦⟧⁰S⟧θ

Read in the 11 names (input is flexible: JSON, space separated, or newline separated) and create an array q of 11 batters, represented by their balls (as an array), status (as an integer) and name.

≔⮌θη

Create a reversed copy of the batters h. This represents the batters that are not out. The last two elements are the off and current batters.

W⊖Lη«

Repeat while there are at least two batters available.

≔⊟ηι

Extract the current batter to i.

≔‽12.4/6ζ

Generate a random ball in z.

⊞υζ

Add it to the overall list of balls using the predefined empty list u.

⊞§ι⁰ζ

Add it to the current batter's balls.

≔⎇⁼ζ/⁺²‽³⁼³⁰L§ι⁰ζ

If the ball is a /, then generate a random status 2..4, otherwise if this is the batter's 30th ball then set the status to 1 otherwise 0.

¿ζ§≔ι¹ζ⊞ηι

If the batter is out then store the batter's status otherwise put the batter back in to bat.

¿⊖Lθ¿⁼¬﹪ΣEηLκ⁶¬ζ

If there are at least two batters left, and the batter was out xor 6 balls have been played, then...

F⟦⊟η⊟η⟧⊞ηκ»

...take the off and current batters and put them back in reverse order.

”|⁴B\[⎇⁻℅↧T`⁵·5KMK⟲M≦»→´⁶_⭆∨R▷↥l⁹KG…≦”

Print the header.

Fθ«

Loop over the batters.

◨⊟ι⁷

Print the batter's name.

◨Σ§ι⁰¦³²

Print the batter's balls.

§⪪”(3⪪⪫⧴πZJL:∨XI±URD↗Σ9⟦FZ∕↖l⪪”⁷⊟ι

Print the batter's status by indexing into the string Not OutRetiredBowled Caught LBW split into substrings of length 7.

◧IΣE⊟ιΣκ⁶

Print the batter's score.

⸿⸿»

Move to the start of the next line but one.

”|QºWPD⟧zNφ[v?Π'vG”◧IΣEυΣι²⁸

Print the total.

J±¹±¹FE¹³⁻²⁷⊗ι«B⁵⁵ιB⁴⁹ι¿‹ι²⁷«B³⁹ιB⁸ι

Draw boxes around everything.

1
source | link

Charcoal, 277 bytes

F¹¹⊞υS≔⮌Eυκθ≔Eυ⟦⟧η≔Eυ⁰δW⊖Lθ«≔⊟θι≔‽⁶ε⊞§ηιε≔⎇⁼ε⁴⁺²‽³⁼L§ηι³⁰ε¿ε§≔διε⊞θι¿⊖Lθ¿⁼¬﹪ΣEηLκ⁶¬εF⟦⊟θ⊟θ⟧⊞θκ»≔EηΣ⭆ι§120406λζ”|⁴B\[⎇⁻℅↧T\`⁵·5KMK⟲M≦»→´⁶_⭆∨R▷↥l⁹KG…≦”F¹¹«◨§υι⁷◨⭆§ηι§12.4/6κ³²§⪪”(3⪪⪫⧴πZJL:∨XI±URD↗Σ9⟦FZ∕↖l⪪”⁷§δι◧I§ζι⁶⸿⸿»”|QºWPD⟧zNφ[v?Π'vG”◧IΣζ²⁸J±¹±¹FE¹³⁻²⁷⊗ι«B⁵⁵ιB⁴⁹ι¿‹ι²⁷«B³⁹ιB⁸ι

Try it online! Link is to verbose version of code. Explanation:

F¹¹⊞υS

Read in the 11 names. (Input is flexible: JSON, space separated, or newline separated. 6 bytes could be saved by requiring a double nested JSON format.)

≔⮌Eυκθ

Create an array q holding the numbers 10..0. This represents the batters. The last two elements are the off and current batters.

≔Eυ⟦⟧η

Create an array h holding the batter's balls.

≔Eυ⁰δ

Create an array d representing the batter's status.

W⊖Lθ«

Repeat while there are at least two batters available.

≔⊟θι

Extract the current batter.

≔‽⁶ε

Generate a random ball in e (0-indexed).

⊞§ηιε

Add it to the current batter's balls.

≔⎇⁼ε⁵⁺²‽³⁼L§ηι³⁰ε

If the ball is a 5, then generate a random status 2..4, otherwise if this is the batter's 30th ball then set the status to 1 otherwise 0.

¿ε§≔διε⊞θι

If the batter is out then store the batter's status otherwise put the batter back in to bat.

¿⊖Lθ¿⁼¬﹪ΣEηLκ⁶¬ε

If there are at least two batters left, and the batter was out xor 6 balls have been played, then...

F⟦⊟θ⊟θ⟧⊞θκ»

...take the off and current batters and put them back in reverse order.

≔EηΣ⭆ι§120406λζ

Map each ball to its score and take the total for each batter in array z.

”|⁴B\[⎇⁻℅↧T`⁵·5KMK⟲M≦»→´⁶_⭆∨R▷↥l⁹KG…≦”

Print the header.

F¹¹«

Loop over the batters.

◨§υι⁷

Print the batter's name.

◨⭆§ηι§12.4/6κ³²

Print the batter's balls.

§⪪”(3⪪⪫⧴πZJL:∨XI±URD↗Σ9⟦FZ∕↖l⪪”⁷§δι

Print the batter's status by indexing into the string Not OutRetiredBowled Caught LBW split into substrings of length 7.

◧I§ζι⁶

Print the batter's score.

⸿⸿»

Move to the start of the next line but one.

”|QºWPD⟧zNφ[v?Π'vG”◧IΣζ²⁸

Print the total.

J±¹±¹FE¹³⁻²⁷⊗ι«B⁵⁵ιB⁴⁹ι¿‹ι²⁷«B³⁹ιB⁸ι

Draw boxes around everything.