Cricket is a sport that, more than most, needs dry weather, yet it was invented in a rainy country and is played in several others. Moreover, unlike, say, baseball, it is a time-limited game, meaning that losing time to rain can affect a match profoundly.

In the oldest form of the sport, this is a problem that takes care of itself, since a rain-interrupted match can simply end with neither team winning. But in the newer (only half a century old!) format of limited overs cricket, that cannot happen, and the need therefore arises of settling rain-affected matches in a way that is fair to both teams, even if the burden of disruption has been uneven.

Until quite recently, this was generally done pretty crudely. But starting in the late 1990s, various more-sophisticated algorithms have been proposed. The one that is used almost universally is the Duckworth–Lewis method, which is based on the idea of resources.

In limited overs cricket, each team bats just once. A team's turn at batting (its innings) is over either when it has faced a certain preset number of balls (a bit like pitches in baseball) or when ten of its batsmen are out. The team therefore has two kinds of resources that it can convert into scoring: the number of balls yet to face and the number of batsmen in reserve. The Duckworth–Lewis method involves placing a numerical value on all possible combinations of these resources.

By convention, balls are divided into sets of six, called overs. The number of batsmen out so far, out of ten, is called the number of wickets fallen. The Duckworth–Lewis method uses a table to assign a numerical value based on the number of overs (and parts of an over) yet to face and the number of wickets fallen.

If the match is uninterrupted by rain, things are straightforward: whichever team scores more runs wins. This is what usually happens.

But if rain interrupts either of the innings (or both), the method is invoked. A calculation is made of the resources at the time of suspension and at the time of resumption (the number of wickets fallen does not change, but the number of overs will be reduced according to the time lost). The difference, the resources lost, is subtracted from the resources at the start of the innings to yield the resources available to the team. There are two such "resources available" figures, one for each team, conventionally expressed as percentages:

and

.

Suppose Team 1 scores

runs. If (as usually happens)

, then Team 2’s target,

, is given by

, where

is the floor function (or greatest integer function).

If

, a different formula is used, namely

.

(In the Demonstration code, I have added 1.001 instead of 1 inside

Floor to correct for problems arising from rounding error.)

In this Demonstration, a fairly sparse Duckworth–Lewis table is used, and

Interpolation fills in the gaps. Each resource percentage depends on two arguments:

overs and

wickets. A separate interpolation is carried out for each value of wickets: each should ideally be monotonic in overs, and interpolation orders have been chosen empirically to make this as close to true as possible in all cases.

You can interactively set both teams’ scores (given in runs and wickets fallen), as well as allowing either team's innings, or both, to be interrupted: after a certain number of overs, for a certain number of overs, and with a certain number of wickets having fallen at the time of interruption.

You can see a simulated cricket scoreboard (Snapshot 1), or view a graphical illustration of how either team's resource figures are arrived at (Snapshot 2); you can also see the calculation of Team 2's scoring target based on these resource figures (Snapshot 3). All four of these displays—the scoreboard, the two resource diagrams, and the calculation—change interactively when you use the

controls.

*Disclaimer: this demonstration is for illustrative purposes only; it uses values associated with international matches, and should not be used for settling amateur cricket matches. It is an implementation of the public-domain Standard Edition of the Duckworth–Lewis method, rather than the proprietary Professional Edition; targets given may therefore differ slightly from the official values.*