Dan Becker's Games Site

The Gaming Challenge 2001

The Gaming Challenge 2001 is a record of the games played by several enthusiastic board gamers to play "a game a day" in the year 2001. We all reported our games and goaded each other to exceed the "dreaded black line", the line that signifies playing one game per day. Many of us were successful in reaching this goal. Some exceeded it. In the end we all had a fun time watching who played many games during the year. Here is a list of the games played and a graph of the rate at which we played.

Latest Results

"Hearts" ); // Get a list of player ids and names. $sql = "SELECT PlayerNames.playerid AS PlayerID, PlayerNames.name AS PlayerName FROM PlayerNames WHERE ( name IN ( $playerIn )) ORDER BY name"; $sqlResults = sqlQuery( $sql, false ); while ( $data = mysql_fetch_array( $sqlResults, MYSQL_ASSOC )) { $playerNames[] = $data[ "PlayerName" ]; $playerIDs[] = $data[ "PlayerID" ]; $playerLookup[ $data[ "PlayerID" ] ] = $data[ "PlayerName" ]; } // while // printArray( $playerNames ); // DEBUG // printArray( $playerIDs ); // DEBUG // $today = getdate( time() ); $today = getdate( mktime( 0,0,0, 12,31,2001 ) ); // $todayStr = date( "Y/m/d" ); $todayStr = date( "Y/m/d", mktime( 0,0,0, 12,31,2001 ) ); // $firstStr = date( "Y/m/d", mktime( 0,0,0, 01,01,$today[ "year" ] ) ); $firstStr = date( "Y/m/d", mktime( 0,0,0, 01,01,2001 ) ); // $todayStr = date( "2001/01/15" ); // use this for interim results. $dayOfYear = $today[ "yday" ] + 1; // $lastDay = getdate( mktime( 0,0,0, 12,31,$today[ "year" ] ) ); $lastDay = getdate( mktime( 0,0,0, 12,31,2001 ) ); $daysInYear = $lastDay[ "yday" ] + 1; // echo "DEBUG: The last day of the year is $daysInYear.
\n"; //DEBUG $ordinal = $dayOfYear % 10; $suffix = "th"; switch ($ordinal) { case 1: $suffix = "st"; break; case 2: $suffix = "nd"; break; case 3: $suffix = "rd"; break; } // switch echo "

Following are results from $firstStr until $todayStr.
"; // echo "Today is the $dayOfYear$suffix day of the challenge.
\n"; // Notice. This SQL gets more games than just ones by challenge players. // However, the games are filtered out when scrolling through the results. // This is less effort than searching for playerIDs in solo and team scores. $sql = "SELECT Plays.date AS Date, GameNames.name AS GameName, Scores.playerids AS PlayerIDs FROM Plays, Scores, GameNames WHERE ( Plays.date >= '$firstStr' ) AND ( Plays.date <= '$todayStr' ) && ( Plays.playid = Scores.playid ) && ( Plays.gameid = GameNames.gameid ) ORDER BY GameNames.name"; // echo "DEBUG: sql=\"$sql\".
\n"; //DEBUG $sqlResults = sqlQuery( $sql, false ); // echo "There are " . mysql_num_rows( $sqlResults ) . " rows in the table.
\n"; // showResults( $sqlResults ); // DEBUG // The games array is a two dimension array as such // $games[ "Acquire" ][ "Dan" ] = 2; // $games[ "Acquire" ][ "Fred" ] = 8; // $games[ "Acquire" ][ "Total" ] = 10; // $games[ "Big City" ][ "Dan" ] = 5; // $games[ "Big City"" ][ "Total" ] = 5; $games = array(); // Add a row for the totals $totalKey = "Total"; $gameData = array(); // Add a key for each player. for ( $i = 0; $i < sizeof ( $playerNames ); $i++ ) $gameData[ $playerNames[ $i ] ] = 0; $gameData[ $totalKey ] = 0; $games[ $totalKey ] = $gameData; mysql_data_seek( $sqlResults, 0 ); while ( $data = mysql_fetch_array( $sqlResults, MYSQL_ASSOC )) { // if ( $rowNum < 1 ) { printArray( $data ); } // DEBUG $basicKey = $data[ "GameName" ]; $teamIDs = $data[ "PlayerIDs" ]; $team = explode( "+", $teamIDs ); // echo "DEBUG: Examining game $basicKey for playerIDs=$playerIDs.
\n"; // DEBUG for ( $playeri = 0; $playeri < count( $team ); $playeri++ ) { $playerID = $team[ $playeri ]; // Check that this playerID is a player in the Challenge. if ( isInInt( $playerIDs, $playerID ) ) { $playerName = $playerLookup[ $playerID ]; if ( empty( $games[ $basicKey ] ) ) { $gameData = array(); // Add a key for each player. for ( $i = 0; $i < sizeof ( $playerNames ); $i++ ) $gameData[ $playerNames[ $i ] ] = 0; $gameData[ "Total" ] = 0; $games[ $basicKey ] = $gameData; } $filter = $filters[ $playerName ]; if (( strlen( $filter ) < 1 ) || ( false == strstr( $filter, $basicKey )) ) { // the game is not filtered $games[ $basicKey ][ "Total" ] += 1; $games[ $basicKey ][ $playerName ] += 1; $games[ $totalKey ][ "Total" ] += 1; $games[ $totalKey ][ $playerName ] += 1; } else { // the game has been filtered $games[ $basicKey ][ $playerName ] = "*"; } } // if player in challenge } // for each team player } // while // printArray( $games ); // DEBUG // Echo data table with title. $colWidth = 60; $negativeColor = "#800000"; // maroon $metTheGoalColor = "#339900"; $mostPlaysColor = "#FF9933"; // light orange $mostPlaysHighlightMin = 3; // lower highlighting threshhold echo "\n"; echo "\n"; echo "\n"; for ( $i = 0; $i < sizeof ( $playerNames ); $i++ ) { echo " \n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; for ( $i = 0; $i < sizeof ( $playerNames ); $i++ ) { $behindSchedule = $games[ $totalKey ][ $playerNames[ $i ] ] < $dayOfYear; $metTheGoal = $games[ $totalKey ][ $playerNames[ $i ] ] >= $daysInYear; echo " \n"; } echo "\n"; // Show details of plays if requested. if ( isset( $details ) ) { // Echo game plays data. while ( list ( $key, $value ) = each( $games )) { if ( 0 != strcmp( $key, $totalKey )) { echo "\n"; echo ""; // For each player. // First find max game plays. $sumMax = 0; $maxCount = 0; while ( list ( $name, $sum ) = each( $value )) { if (( $sum >= $sumMax ) && ( $maxCount < sizeof( $playerNames ))) $sumMax = $sum; $maxCount++; // This count avoids making the total highlighted. } reset( $value ); // Spit out each player's play total. $maxCount = 0; while ( list ( $name, $sum ) = each( $value )) { if (( $sum >= $sumMax ) && ( $sum >= $mostPlaysHighlightMin ) && ( $maxCount < sizeof( $playerNames ))) echo ""; else echo ""; $maxCount++; // This count avoids making the total highlighted. } // while echo "\n"; } // if } // while echo "\n"; echo "\n"; for ( $i = 0; $i < sizeof ( $playerNames ); $i++ ) { echo " \n"; } // for echo "\n"; echo "\n"; echo "\n"; echo "\n"; for ( $i = 0; $i < sizeof ( $playerNames ); $i++ ) { $behindSchedule = $games[ $totalKey ][ $playerNames[ $i ] ] <= $dayOfYear; $metTheGoal = $games[ $totalKey ][ $playerNames[ $i ] ] >= $daysInYear; echo " \n"; } echo "\n"; } // if details echo "
Player"; echo $playerNames[ $i ]; echo "Total
Game Plays"; if ( $behindSchedule == true ) echo ""; if ( $metTheGoal == true ) echo ""; echo $games[ $totalKey ][ $playerNames[ $i ] ]; if ( $behindSchedule || $metTheGoal ) echo ""; echo "" . $games[ $totalKey ][ "Total" ] . "
$key$sum$sum
Player"; echo $playerNames[ $i ]; echo "Total
Totals"; if ( $behindSchedule == true ) echo ""; if ( $metTheGoal == true ) echo ""; echo $games[ $totalKey ][ $playerNames[ $i ] ]; if ( $behindSchedule || $metTheGoal ) echo ""; echo "" . $games[ $totalKey ][ "Total" ] . "
\n"; if ( isset( $details )) { if ( sizeof( $filters ) > 0 ) echo "
* = the player has elected to filter these games from the count
\n"; echo "
Collapse game play table details.
\n"; } else { echo "
Expand game play table details.
\n"; } echo "

Progress Chart

"; require( "../../php/drawColor.php" ); require( "../../php/drawShape.php" ); require( "../../php/drawGraph.php" ); // Form table into a two dimensional array as such: // date DOY # # # // $games[ 0 ] = { "2001/01/09", 9, 2, 4, 5 } // $games[ 1 ] = { "2001/01/10", 10, 4, 6, 5 } // $games[ 2 ] = { "2001/01/13", 13, 4, 8, 6 } // $games[ 3 ] = { "2001/01/18", 13, 4, 9, 6 } $games = array(); // First populate with dummy data. for ( $i = 0; $i < $dayOfYear; $i++ ) { $curDate = date( "Y-m-d", mktime( 0,0,0, 01, $i + 1,$today[ "year" ] ) ); $curDOY = dayOfYear( $curDate ); $gameData = array(); $gameData[] = $curDate; $gameData[] = $curDOY; for ( $j = 0; $j < sizeof( $playerNames ); $j++ ) $gameData[] = 0; $games[ $curDate ] = $gameData; } // printArray( $games ); $lookup = array(); for ( $i = 0; $i < sizeof( $playerNames ); $i++ ) { $key = $playerNames[ $i ]; $lookup[ $key ] = $i + 2; } // Fill game record with game data mysql_data_seek( $sqlResults, 0 ); while ( $data = mysql_fetch_array( $sqlResults, MYSQL_ASSOC )) { $date = $data[ "Date" ]; $game = $data[ "GameName" ]; $teamIDs = $data[ "PlayerIDs" ]; $team = explode( "+", $teamIDs ); // echo "DEBUG: There are " . count( $team ) . " players on team.
\n"; // DEBUG for ( $playeri = 0; $playeri < count( $team ); $playeri++ ) { $playerID = $team[ $playeri ]; // Check that this playerID is a player in the Challenge. if ( isInInt( $playerIDs, $playerID ) ) { $playerName = $playerLookup[ $playerID ]; $index = $lookup[ $playerName ]; $gameData = $games[ $date ]; // Don't forget filtering. $filter = $filters[ $player ]; if (( strlen( $filter ) < 1 ) || ( false == strstr( $filter, $game )) ) { $gameData[ $index ] += 1; } $games[ $date ] = $gameData; } // if playerID in challenge } // for each team player } // while // printArray( $games ); //DEBUG reset( $games ); // date DOY # # # // $games[ 0 ] = { "2001/01/09", 9, 2, 4, 5 } // Change game count to accumulated data. while( list( $date, $data ) = each( $games )) { if ( sizeof( $prevData ) > 1 ) { for ( $i = 0; $i < sizeof( $playerNames ); $i++ ) { $data[ $i + 2 ] += $prevData[ $i + 2 ]; } } $games[ $date ] = $data; $prevData = $data; } if ( isset( $relative ) ) { reset( $games ); // Change game count relative to day of year. while( list( $date, $data ) = each( $games )) { for ( $i = 0; $i < sizeof( $playerNames ); $i++ ) { $data[ $i + 2 ] -= $data[ 1 ]; } $data[ 1 ] = 0; $games[ $date ] = $data; } } // printArray( $games ); // DEBUG $width = 700; $height = 500; $fileName = "challenge2001.png"; $insets = array( 20, 20, 20, 20 ); // bottom, left, right, top // echo "DEBUG: inset b/l/r/t=" . $insets[ bottom ] ."/". $insets[ left ] ."/". $insets[ right ] ."/". $insets[ top ] . ".
\n"; $legendLineH = 16; $playersPerLegendLine = 5; $titleH = 32; $graph = imageCreate( $width, $height ); allocateColors( $graph ); allocateColorValue( $graph, "goal", 0x33, 0x99, 0x00 ); imageFill( $graph, $width, $height, $white ); // Graph the given data $n = sizeof( $games ); // echo "DEBUG: sizeof data=" . $n . ".
\n"; if ( $n > 1 ) { $colors = array( $black, $lime, $red, $magenta, $cyan, $slateblue, $green, $gold, $maroon, $yellow ); $seriesNames = array(); $seriesNames[] = "One-a-day"; for ( $i = 0; $i < sizeof( $playerNames ); $i++ ) $seriesNames[] = $playerNames[ $i ]; // insets are b,l,r,t $legendLines = floor( sizeof( $seriesNames ) / ($playersPerLegendLine+1) ) + 1; // echo "DEBUG: legendLines=$legendLines.
\n"; // DEBUG $reg = array( $insets[ left ], $height - $insets[ top ] - ( $legendLines * $legendLineH ) + $legendLineH/2, $width - $insets[ left ] - $insets[ right ], ($legendLines * $legendLineH )); // x, y, width, height printLegend( $graph, $seriesNames, $colors, $reg, $black, 4 ); $reg = array( $insets[ left ], $insets[ top ], $width - $insets[ left ] - $insets[ right ], $height - $insets[ bottom ] - $insets[ bottom ] - $insets[ top ] - ( $legendLines * $legendLineH )); // x, y, width, height imageRectangle( $graph, $reg[ X ], $reg[ Y ], $reg[ X ] + $reg[ W ], $reg[ Y ] + $reg[ H ], $black ); // x1,y1,x2,y2 // Find min and max Y. $minY = 0; $maxY = -1000; reset( $games ); while( list( $date, $data ) = each( $games )) { $seriesN = sizeof( $data ); for ( $y = 1; $y < $seriesN; $y++ ) { if ( $data[ $y ] < $minY ) $minY = $data[ $y ]; if ( $data[ $y ] > $maxY ) $maxY = $data[ $y ]; } } // Round max to nearest 5, while ( 0 != ( $maxY % 5 )) $maxY++; while ( 0 != ( $minY % 5 )) $minY--; // echo "DEBUG: minY=$minY, maxY=" . $maxY . ".
\n"; //DEBUG // Find min and max date. $minDate = "3000/01/01"; $maxDate = "0000/00/00"; reset( $games ); while( list( $date, $data ) = each( $games )) { $cmp = datecmp( $date, $minDate ); if ($cmp < 0) $minDate = $date; $cmp = datecmp( $date, $maxDate ); if ($cmp > 0) $maxDate = $date; } $minDOY = dayOfYear( $minDate ); $maxDOY = dayOfYear( $maxDate ); $rangeDOY = $maxDOY - $minDOY; $weeks = ceil(($maxDOY - $minDOY) / 7); if ( $weeks > 10 ) $weeks = 10; // echo "DEBUG: maxDate=$maxDate ($maxDOY), minDate=$minDate ($minDOY).
\n"; //DEBUG printYAxes( $graph, $reg, $minY, $maxY, 5, $black, 3, true,true, true ); // min, max, n, color, font, ticks, lines, labels printXAxes( $graph, $reg, $minDate, $maxDate, $weeks, $blue, 3, true,false,true ); // min, max, n, color, font, ticks, lines, labels // Make a horizontal line for the goal. if ( $maxY >= $daysInYear ) { // echo "DEBUG: maxY=$maxY, daysInYear=$daysInYear.
\n"; //DEBUG $color = $goal; $x1 = $reg[ X ]; $y1 = $reg[ Y ] + $reg[ H ] - $reg[ H ] * ( ($daysInYear - $minY) / ($maxY - $minY) ); $x2 = $reg[ X ] + $reg[ W ]; $y2 = $y1; // echo "DEBUG: x1=$x1, y1=$y1, x2=$x2, y2=$y2.
\n"; //DEBUG imageDashedLine( $graph, $x1, $y1, $x2, $y2, $color ); } // if // graph each point reset( $games ); while( list( $xDate, $data ) = each( $games )) { $xDOY = dayOfYear( $xDate ); if ( $prevDOY > 0 ) { $seriesN = sizeof( $data ) - 1; for ( $y = 0; $y < $seriesN; $y++ ) { // if ( $y == 0 ) echo "DEBUG: x/y $i =$xDOY/$yData.
\n"; //DEBUG $color = $colors[ $y ]; $curVal = $data[ $y + 1 ]; $x2 = $reg[ X ] + $reg[ W ] * ( ($xDOY - $minDOY) / $rangeDOY ); $y2 = $reg[ Y ] + $reg[ H ] - $reg[ H ] * ( ($curVal - $minY) / ($maxY - $minY) ); $preVal = $previousData[ $y + 1 ]; $x1 = $reg[ X ] + $reg[ W ] * ( ($prevDOY - $minDOY) / $rangeDOY ); $y1 = $reg[ Y ] + $reg[ H ] - $reg[ H ] * ( ($preVal - $minY) / ($maxY - $minY) ); imageLine( $graph, $x1, $y1, $x2, $y2, $color ); imageLine( $graph, $x1, $y1 + 1, $x2, $y2 + 1, $color ); } // for each series point } $previousData = $data; $prevDOY = $xDOY; } // for each data point // insets are b,l,r,t $reg = array( $insets[ left ], $insets[ top ], $width - $insets[ left ] - $insets[ right ], $titleH ); // x, y, width, height printCenteredText( $graph, "Game Plays versus Date", $reg, $black, 8 ); } // n points > 0 // Spit out to file // imageGIF( $graph, $fileName ); imagePNG( $graph, $fileName ); echo "

"; if ( isset( $relative)) { if ( sizeof( $filters ) > 0 ) echo "Show graph game plays as absolute values.
\n"; } else { echo "Show graph game plays relative to the day of year.
\n"; } echo " Note: If the chart is not updating properly, hit the shift-refresh/shift-reload button on your browser.

Also have a look at:
The Gaming Challenge 2001
The Gaming Challenge 2003

"; include( "../../navbar.html" ); include( "../../php/stats.phtml" ); echo "
\n"; echo "Last Modification: " . getSelfModTime() . ".\n"; // Looks like usec not supported on system. // $beginUsec = $beginTime[ "sec" ] * 1000 + $beginTime[ "usec" ]; // $endTime = getTimeOfDay(); // $endUsec = $endTime[ "sec" ] * 1000 + $endTime[ "usec" ]; // $elapsedUsec = $endUsec - $beginUsec; // echo "Exec time: " . floor( $elapsedUsec / 1000 ) . "." . floor( $elapsedUsec % 1000 ) . "s.\n"; ?>