Click here to Skip to main content
Licence CPOL
First Posted 23 Jun 2009
Views 18,141
Downloads 287
Bookmarked 21 times

Duckworth Lewis Calculator for Windows Mobile

By | 23 Jun 2009 | Article
A Duckworth Lewis calculator for Windows Moblie and .NET 3.5.

Introduction

This is an interpretation of the Duckworth Lewis method of calculating rain-affected Cricket scores.

Background

The formula for this code is credited to David Holland on the Active State website: http://code.activestate.com/recipes/334728/. I have interpreted this into C# and for use in the Windows Mobile.

For some reason, the ICC will not publish the exact formula; instead they release a set of inaccurate lookup tables that do not match the actual DL targets set in First Class Cricket. For this reason, the formula here will need some tweaking as updates are made. But it is a start, and follows the principles of the DL method.

Using the code

//Array of constants

double[,] dlewisdict1 = { { 293.8, 241.93, 217.21, 173.32, 142.84, 102.94, 81.705, 
                            51.471, 26.708, 17.995 }, { 0.033468, 0.043685, 0.044921, 
                            0.059491, 0.071912, 0.10011, 0.12843, 
                            0.21507, 0.41548, 0.26668 } };

//Get the number of Wickets lost
int wicksremain = 10 - (int)InnsWicks2nd.Value;
int wicksremain2 = 10 - (int)InnsWicks1st.Value;

double w = dlewisdict1[1, wicksremain] * (double)innOvers2nd.Value;
double v = dlewisdict1[1, wicksremain] * (double)innOvers1st.Value;

double d1 = 1-System.Math.Exp(-v);
d1 = d1 * dlewisdict1[0, 0];
double d = 1-System.Math.Exp(-w);
d = d * dlewisdict1[0, wicksremain];
double x = ((d1 / 235) * 100);
double y = ((d / 235) * 100);
d = ((double)innScore1st.Value / x) * y;
d = Math.Round(d);
textBox1.Text = d.ToString();

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

trxStudio

Software Developer (Senior)
TRx Studio Limited
United Kingdom United Kingdom

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralGood job! PinmemberSergioQ213:11 6 Sep '10  
JokeAshes PinmemberGavinSV11:47 24 Jun '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120528.1 | Last Updated 23 Jun 2009
Article Copyright 2009 by trxStudio
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid