You are not logged in. · Eastern Time: Monday, December 23, 2024 9:51:27 AM
Football Pool
Monday Night Algorithm

Monday Night Scoring Algorithm

For the absurdly curious ...

The genuine taken-straight-from-the-program code is shown below, complete with whimsical comments.

Back



function float_max(x, y) {

// Returns larger number for max float.

return (x > y ? x : y);
}

function sqr(x) {

// Returns x**2

return (x * x);
}

function rand(num) {

// Returns a random number between 1 and the number passed in.

return Math.floor(Math.random() * num) + 1;
}

/***************************************************************************
* MondayCurrent(p1, p2, a1, a2): This algorithm is all magic, handed down *
* from time immemorial. The idea is basically to award the Monday night *
* score based on a standard distance formula, but modified to take *
* football stuff into account. In particular, (1) a higher score is *
* awarded if you get the point spread right; and (2) the "generosity" *
* of the score increases as the actual score of the game gets higher *
* under the belief that it's harder to accurately predict a high-scoring *
* game than a low-scoring game. *
**************************************************************************/

function MondayCurrent(p1, p2, a1, a2) {

Half = 21.0;
Alpha = 1.6;
BAT0 = 3.9;
BSlope = 0.048;

Points_For_Closeness = 80.0;
Bonus_For_Picking_Winner = 20.0;
Bonus_For_Picking_Tie = 40.0;

b1 = float_max(1.1, BAT0 - BSlope*(a1));
b2 = float_max(1.1, BAT0 - BSlope*(a2));

// Compute distance -- a modified 2-norm.

d1sq = sqr(p1-a1);
d2sq = sqr(p2-a2);

rsq = d1sq + d2sq;
dist = Math.sqrt(rsq + (sqr((p1-p2)-(a1-a2))));

// Compute the base -- a weighted average of the bases calculated from
// the actual score.


if(rsq == 0.0) {
s = (a1 == a2 ? 120.0 : 100.0);
}
else {
base = ( (rsq < 0.5) ? 2.0 : ( d1sq*b1 + d2sq*b2 ) / rsq );

s = Math.pow(base, ( - Math.pow((dist/Half), Alpha) )) * Points_For_Closeness;
if ( (a1 == a2) && (p1 == p2) ) s = s + Bonus_For_Picking_Tie;
if ( ((a1 > a2) && (p1 > p2))
||
((a1 < a2) && (p1 < p2)) ) s = s + Bonus_For_Picking_Winner;
}
return parseInt(s);
}

// Used for Median Score calculation function
// the actual score.

function SortNumeric(a, b) {
return ((+a > +b) ? 1 : ((+a < +b) ? -1 : 0));
}

function SortVBArray(arrVBArray) {
return arrVBArray.toArray().sort(SortNumeric).join('x');
}
 

Back

 

Monday Night Algorithm
For help, contact FBP Commissioner.