# T20 Cricket Simulator

  • What: This is a model and simulation engine I built to predict the outcome of T20 cricket matches.
  • When: 2020

# About

This model/simulator is a bottom-up, probabilistic approach to machine learning. Instead of trying to predict match results based on historical data, I trained a neural-network model to predict the outcome of individual balls and then built a custom Monte Carlo simulation engine to generate tens of thousands of possible games. For this project, I used data on 677291 balls bowled in 3651 T20 matches involving 2255 players.

# Deep Dive

I wrote a technical deep dive on this project for Towards Data Science which you can read HERE (opens new window).

# Example

This is an example of a single simulation of a match between the Sydney Sixers and the Brisbane Heat.

The Brisbane Heat have won the toss!
Sydney Sixers will bat first. Brisbane Heat to bowl.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1ST INNINGS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MJ Swepson to bowl. 0/0 after 0.
	4 to JL Denly!
JK Lalor to bowl. 0/4 after 1.
	4 to J Avendano!
	4 to J Avendano!
Mujeeb Ur Rahman to bowl. 0/12 after 2.
	4 to JL Denly!
	6 to JL Denly!
JL Pattinson to bowl. 0/23 after 3.
	WICKET! JL Denly out, bowled JL Pattinson.
	WICKET! MC Henriques out, bowled JL Pattinson.
	6 to DP Hughes!
BCJ Cutting to bowl. 2/31 after 4.
	WICKET! J Avendano out, bowled BCJ Cutting.
MJ Swepson to bowl. 3/34 after 5.
JL Pattinson to bowl. 3/36 after 6.
Mujeeb Ur Rahman to bowl. 3/38 after 7.
	4 to JC Silk!
BCJ Cutting to bowl. 3/46 after 8.
Mujeeb Ur Rahman to bowl. 3/52 after 9.
	4 to JC Silk!
BCJ Cutting to bowl. 3/60 after 10.
	WICKET! JC Silk out, bowled BCJ Cutting.
JK Lalor to bowl. 4/63 after 11.
MJ Swepson to bowl. 4/68 after 12.
JK Lalor to bowl. 4/74 after 13.
	4 to DP Hughes!
JL Pattinson to bowl. 4/82 after 14.
	6 to JR Philippe!
	6 to JR Philippe!
MJ Swepson to bowl. 4/96 after 15.
	4 to JR Philippe!
JK Lalor to bowl. 4/106 after 16.
	4 to JR Philippe!
MJ Swepson to bowl. 4/114 after 17.
	WICKET! JR Philippe out, bowled MJ Swepson.
BCJ Cutting to bowl. 5/118 after 18.
	6 to DP Hughes!
	4 to TK Curran!
Mujeeb Ur Rahman to bowl. 5/132 after 19.
	6 to TK Curran!

Final Score: 5/144 off 20.
The Brisbane Heat are going in to bat. Sydney Sixers to bowl.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2ND INNINGS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BJ Dwarshuis to bowl. 0/0 after 0.
	4 to M Bryant!
	4 to M Bryant!
TK Curran to bowl. 0/8 after 1.
BAD Manenti to bowl. 0/9 after 2.
	WICKET! M Bryant out, bowled BAD Manenti.
BJ Dwarshuis to bowl. 1/13 after 3.
	4 to SD Heazlett!
	4 to SD Heazlett!
MC Henriques to bowl. 1/25 after 4.
	WICKET! SD Heazlett out, bowled MC Henriques.
	4 to BB McCullum!
	4 to BB McCullum!
	WICKET! BB McCullum out, bowled MC Henriques.
SA Abbott to bowl. 3/34 after 5.
	4 to JA Burns!
BAD Manenti to bowl. 3/41 after 6.
	4 to JA Burns!
TK Curran to bowl. 3/46 after 7.
	6 to JA Burns!
BJ Dwarshuis to bowl. 3/57 after 8.
	4 to CA Lynn!
	4 to CA Lynn!
	6 to CA Lynn!
	WICKET! JA Burns out, bowled BJ Dwarshuis.
SNJ O'Keefe to bowl. 4/72 after 9.
	WICKET! CA Lynn out, bowled SNJ O'Keefe.
BJ Dwarshuis to bowl. 5/76 after 10.
	4 to BCJ Cutting!
SA Abbott to bowl. 5/83 after 11.
	WICKET! BCJ Cutting out, bowled SA Abbott.
TK Curran to bowl. 6/87 after 12.
	6 to JL Pattinson!
	4 to JJ Peirson!
	6 to JL Pattinson!
BJ Dwarshuis to bowl. 6/105 after 13.
	6 to JL Pattinson!
	6 to JL Pattinson!
BAD Manenti to bowl. 6/123 after 14.
	4 to JL Pattinson!
TK Curran to bowl. 6/129 after 15.
	6 to JL Pattinson!
	WICKET! JJ Peirson out, bowled TK Curran.
MC Henriques to bowl. 7/137 after 16.
	4 to JL Pattinson!

Final Score: 7/145 off 17.

~~~~~~~~~~~~~~~~~~~~
Brisbane Heat WIN!
~~~~~~~~~~~~~~~~~~~~