Jump to content

Recommended Posts

Hi there,

 

I have a football prediction website I am trying to create The rules are (usually calculated in Excel)...

 

Scoring Rules

1. Each correctly predicted exact score will win a total of 25 points.

2. Each correctly predicted result ( either win, lose, or draw) will win 10 points. NOTE: exact scorers do NOT receive additional 10 points.

3. A single point (IE 1 point) will be deducted for each goal scored over or under the total goals predicted. Therefore, accuracy of total number of goals predicted will affect the scores.

 

I am trying to do the equivalent in PHP and so far I have got...

 

function add_parameters($one, $two, $three, $four)

{

global $sum;

if ($one==$two && $three==$four)  //correctly predicted score - Rule 1

$sum+=25;

elseif ($one==$three && $two==$four)  //both draw so 10 points  - Rule 2

$sum+=10;

elseif ($one>$three && $two>$four)  //both win so 10 points - Rule 2

$sum+=10;

elseif ($one<$three && $two<$four)  //both lose so 10 points - Rule 2

$sum+=10;

 

}

 

Does anyone know how I might do rule/score 3 where the difference between numbers is important? And can anyone see any probs with what I have so far?

 

Some examples below of how scores should be...

 

NOTE: A result of Millwall 4-1 west h*m is used in all the examples below:

Example #1: if a 0-0 result was predicted, then 5 points will be deducted.

Example #2: if any 1-0 result was predicted, then 4 points will be deducted.

Example #3: if any 2-0 result or 1-1 draw was predicted, then 3 points will be deducted.

Example #4 if any 3-0, 2-1 or 4-3 result was predicted then 2 points will be deducted.

Example #5 if a 3-1, 5-1, 4-0 or 6-0 result or a 2-2 or 3-3 draw was predicted then 1 point will be deducted.

Example #6 if a 3-2 or 5-0 result was predicted (or God forbid a 1-4 win by west h*m) then NO points will be deducted.

 

The function might make more sense with these variables...

 

function add_parameters($score_home, $prediction_home, $score_away, $prediction_away)

{

global $sum;

if ($score_home==$prediction_home && $score_away==$prediction_away)  //correctly predicted score - Rule 1

$sum+=25;

elseif ($score_home==$score_away && $prediction_home==$prediction_away)  //both draw so 10 points  - Rule 2

$sum+=10;

elseif ($score_home>$score_away && $prediction_home > $prediction_away)  //both win so 10 points - Rule 2

$sum+=10;

elseif ($score_home<$three && $prediction_home < $prediction_away)  //both lose so 10 points - Rule 2

$sum+=10;

 

}

try

<?php
function add_parameters($score_home, $prediction_home, $score_away, $prediction_away)
{
    global $sum;
    if ($score_home==$prediction_home && $score_away==$prediction_away)  //correctly predicted score - Rule 1
    $sum+=25;
     elseif ($score_home==$score_away && $prediction_home==$prediction_away)  //both draw so 10 points  - Rule 2
    $sum+=10;
     elseif ($score_home>$score_away && $prediction_home > $prediction_away)  //both win so 10 points - Rule 2
    $sum+=10;
     elseif ($score_home<$three && $prediction_home < $prediction_away)  //both lose so 10 points - Rule 2
    $sum+=10;

    // add this
    $sum -= abs (($prediction_home + $prediction_away) - ($score_home + $score_away));
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.