Lotto Genius

Latest code (7/15/09) change will expand the selection of Mega Balls where we can use numbers that have been picked more often in the past.  The previous model was limited to those numbers that had not been selected at all.  In 10 draws, the mega-ball was limited to 5 numbers; each pick was reused twice.  This clearly limited the ability to hit.

Latest code (1/17/09) change will allow numbers to appear multiple times. This is by design because I noticed a pattern where I’d get three numbers right but always in different rows. This will allow all numbers to appear on a single row. The downside is it may reduce the hit frequency.  Time will tell.

Latest code (9/7/10) changed this page to use the same logic being used within the iPhone app version.

Latest code (3/28/12) added a check to make sure that pick has not won previously. I’m not sure that’s really possible but hey, why not.

Latest code (3/23/13) because I updated WordPress, it freaked out at my code and doesn’t like functions. So now, this is one monolithic PHP loop. ICK!

Latest code (12/16/13) updated to use the new gameplay. “Players may pick six numbers from two separate pools of numbers – five different numbers from 1 to 75 and one number from 1 to 15.” I also had to update the cron job that crawls the winning numbers website.

tag
$Result = ““;

if (isset($_REQUEST[“picks”]))
$picks = $_REQUEST[“picks”];
else
$picks = 5;

echo “

“;

// Get each draw based on the parameter
for ($x=0; $x<$picks; $x++) { echo "

“;

$Repeat = ” “;
$count = 0;

// while ($Repeat){

// $Draw = GetSingleDraw(“”);

// RJL 3/23/13
// should be a function
// Determine how many rows of history we have
$sql = “SELECT COUNT(*) R FROM LottoHistory”;
$rowsCount = @mysql_query($sql);

// Handle the errors
if (!$rowsCount) {
$message = ‘Invalid query: ‘ . mysql_error() . “\n”;
$message .= ‘Whole query: ‘ . $sql;
die($message);
}
else
{
$rows = mysql_fetch_assoc($rowsCount);
}

// Calculate the frequency variable using the Rows Count
// Because there are 6 entries for each Date, we divide by 5
// Then take age % of those
// Then round it to a whole number
if ($_REQUEST[“age”])
$a = $_REQUEST[“age”];
else
$a = 100;

$age = $rows[“R”];
$age = $age * ($a * .01);
$age = round($age);
// echo “
rows =>” . $rows[“R”] . “<=
“;
// echo “
age =>” . $age . “<=
“;

if (isset($_REQUEST[“sample”]))
$sample = $_REQUEST[“sample”];
else
$sample = 20;

// Get the Kicker
$sql = “SELECT * FROM “;
$sql = $sql . “(SELECT * FROM “;
$sql = $sql . “(SELECT Draw, COUNT(Draw) AS Draws, (YEAR(MIN(Date)) & ‘-‘ & MONTH(MIN(Date)) & ‘-‘ & DAY(MIN(Date))) AS Last_Draw FROM “;
$sql = $sql . “(select an.draw, lh.date as Date, an.kicker from AvailableNumbers an “;
$sql = $sql . “left join LottoHistory lh on an.draw = lh.draw and lh.kicker = 1 “;
$sql = $sql . “where an.kicker=1) as f “;
$sql = $sql . “GROUP BY Draw) AS d “;
$sql = $sql . “ORDER BY d.Draw, d.Last_Draw DESC LIMIT ” . $age . “) AS e “;
$sql = $sql . “ORDER BY RAND() LIMIT ” . $sample;

// echo $sql;

// Save the result for later
$kicker = @mysql_query($sql);

// Handle the errors
if (!$kicker) {
$message = ‘Invalid query: ‘ . mysql_error() . “\n”;
$message .= ‘Whole query: ‘ . $sql;
die($message);
}
else
{
$kick = mysql_fetch_assoc($kicker);
}

// Get the Draws
$sql = “SELECT Draw, Draws, Last_Draw “;
$sql = $sql . “FROM (SELECT Draw, Draws, Last_Draw “;
$sql = $sql . “FROM (SELECT Draw, COUNT(Draw) AS Draws, YEAR(MIN(Date)) & ‘-‘ & MONTH(MIN(Date)) & ‘-‘ & DAY(MIN(Date)) AS Last_Draw “;
$sql = $sql . “FROM (SELECT an.Draw, COUNT(lh.Draw) AS Draws, lh.Date, lh.Kicker “;
$sql = $sql . “FROM AvailableNumbers AS an LEFT OUTER JOIN “;
$sql = $sql . ” LottoHistory AS lh ON an.Draw = lh.Draw “;
$sql = $sql . “GROUP BY an.Draw, lh.Date, lh.Kicker) AS c “;
$sql = $sql . “WHERE (Kicker = 0) OR “;
$sql = $sql . “(Kicker IS NULL) “;
$sql = $sql . “GROUP BY Draw) AS d “;
$sql = $sql . “ORDER BY Draws, Last_Draw DESC LIMIT ” . $age . “) AS e “;
$sql = $sql . “ORDER BY RAND() LIMIT ” . $sample;

// echo $sql;

// Save the Result
$result = @mysql_query($sql);

// Handle Errors
if (!$result) {
$message = ‘Invalid query: ‘ . mysql_error() . “\n”;
$message .= ‘Whole query: ‘ . $sql;
die($message);
}

$Pick=””;
// Process the results
for ($p=0; $p<5; $p++) { $row = mysql_fetch_assoc($result); $Pick = $Pick . $row['Draw'] . "-"; } $Draw = $Pick . $kick['Draw']; // End should be function // $Draw = "9-19-34-44-51-24"; // RJL - Commented all this out // $Repeat = IsDuplicatePick($Draw); // //// var_dump($Repeat); // $count = $count + 1 ; // if ($count > 5) {
// break;
// }
// }

// echo “DRAW=”;
// var_dump($Draw);
// echo “

“;

$B = explode(“-“,$Draw);

// echo “B=”;
// var_dump($B);
// echo “

“;

$Ball[0] = $B[0];
$Ball[1] = $B[1];
$Ball[2] = $B[2];
$Ball[3] = $B[3];
$Ball[4] = $B[4];
sort($Ball, SORT_NUMERIC);

// echo “Ball=”;
// var_dump($Ball);
// echo “

“;

for ($y=0; $y<5; $y++) { echo "

“;
}

echo “

“;
echo “
“;

}

echo “

“;
echo $Ball[$y];
echo “
“;

echo $B[5];
echo “

“;

?>

Refresh the page to see new picks

We have the Lotto Genius on the following platforms too.

Windows Mobile:
lottogenius-windows

Android:
lottogeniusandroid

iPhone:
lottogenius-iphone

Leave a Reply

Your email address will not be published. Required fields are marked *