'; $showLogo = false; //a little security never hurt anyone... much $robotName = str_replace ('"', '', $_REQUEST['name']); $robotGame = str_replace ('"', '', $_REQUEST['game']); if($robotGame == '') $robotGame = 'roborumble'; if($robotName == '') $showLogo = true; $boturl = "http://rumble.fervir.com/rumble/RatingDetails?game=$robotGame&name=$robotName&compare=false"; $boturl = str_replace(' ','%20', $boturl); //create the image $graph = @imagecreatetruecolor(600, 600) or die("Cannot Initialize new GD image stream"); imageantialias($graph, true); $white = imagecolorallocate($graph, 255, 255, 255); $black = imagecolorallocate($graph, 0, 0, 0); imagefill($graph, 0, 0, $white); //do stuff here if($showLogo) { echo ''; $color = imagecolorallocate($graph, 240, 50, 0); //Border for($z=100; $z<500; $z+=8) { imagefilledellipse($graph, $z, 100, 8, 8, $color); imagefilledellipse($graph, $z, 252, 8, 8, $color); if($z<250) { imagefilledellipse($graph, 100, $z, 8, 8, $color); imagefilledellipse($graph, 492, $z, 8, 8, $color); } } //L imagecolordeallocate($graph, $color); $color = imagecolorallocate($graph, 150, 100, 200); for($z=130; $z<230; $z+=8) { imagefilledellipse($graph, 140, $z, 8, 8, $color); } for($z=140; $z<200; $z+=8) { imagefilledellipse($graph, $z, 226, 8, 8, $color); } //R, neat huh imagecolordeallocate($graph, $color); $color = imagecolorallocate($graph, 200, 100, 200); for($z=130; $z<230; $z+=8) { imagefilledellipse($graph, 244, $z, 8, 8, $color); if($z<=178) imagefilledellipse($graph, 324, $z, 8, 8, $color); if($z<210) { imagefilledellipse($graph, $z+114, 130, 8, 8, $color); imagefilledellipse($graph, $z+114, 178, 8, 8, $color); } if($z<186) imagefilledellipse($graph, $z+138, $z+48, 8, 8, $color); } //for($z=140; $z<200; $z+=8) { imagefilledellipse($graph, $z, 226, 8, 8, $color); } //P imagecolordeallocate($graph, $color); $color = imagecolorallocate($graph, 250, 100, 200); for($z=130; $z<230; $z+=8) { imagefilledellipse($graph, 380, $z, 8, 8, $color); if($z<=178) imagefilledellipse($graph, 460, $z, 8, 8, $color); if($z<=210) { imagefilledellipse($graph, $z+250, 130, 8, 8, $color); imagefilledellipse($graph, $z+250, 178, 8, 8, $color); } } //Text imagestring($graph, 5, 230, 80, "L.R.P.D.G.S.", $black); imagestring($graph, 4, 200, 260, "Linear Regression Plot", $black); imagestring($graph, 4, 196, 274, "Dynamic Graphing System", $black); imagestring($graph, 1, 120, 580, "Original LRP by Kawagi Rebuilt by Nfwu DGS and PHP by Chase", $black); } else { //if were not showing the logo, then we must be actually graphing, weee! $inputData = file_get_contents($boturl); //we already have the name from above ya? No need to get it again then huh. $tempPos = strpos($inputData,'

CURRENT RATING = ')+21; $currentRating = substr($inputData, $tempPos, strpos($inputData, '

')-$tempPos); $tempPos = strpos($inputData,'

It has participated in ')+26; $numberOfBattles = substr($inputData, $tempPos, strpos($inputData, ' battles. Last one hold')-$tempPos); $arrayPos = 0; $numberOfOpponents = 0; $extremeProblemBots = 0; $extremeUnproblemBots = 0; $arrayData = explode('', $inputData); $Sx=0; $Sy=0; $Sxy=0; $Sxx=0; $color = imagecolorallocate($graph, 0,0,0); $lastValue = ''; foreach($arrayData as $value) { //echo strpos($value, 'enemy'); if(strpos($value, 'RATING DETAILS') == false && strpos($value, 'ProblemBot Index') == false) { $value = str_replace('', '|', $value); $value = str_replace('', '|', $value); $value = str_replace('', '|', $value); $value = str_replace('', '', $value); $value = str_replace("\r\n", '|', $value); $data = explode("|", $value); $xpos = round($data[4]*6); $ypos = round(300-10*$data[5]); if ($ypos <= 0){ $extremeUnproblemBots++; echo 'Extreme Unproblem Bot: '.$data[0].' Actual: '.$data[1].' Expected: '.$data[4].' PBI:'.$data[5].'
'; } if ($ypos >= 600){ $extremeProblemBots++; echo 'Extreme Problem Bot: '.$data[0].' Actual: '.$data[1].' Expected: '.$data[4].' PBI:'.$data[5].'
'; } //I know we place them as 8, but 6 has a closer fit to the actually displayed circles //echo ''; $imagemap .= '\'Opponent:'; $Sx += $xpos; $Sy += $ypos; $Sxy += $xpos*$ypos; $Sxx += $xpos*$xpos; $red = $data[1]-48; if($red < 0) $red = 0; $red = 255-$red*255/52; //$green = -1*($data[1]-52); $green = 52-$data[1]; if ($green<0) $green=0; $green = 255-$green*255/52; imagecolordeallocate($graph, $color); $color = imagecolorallocate($graph, $red, $green, 0); imagefilledellipse($graph, $xpos-4, $ypos-4, 8, 8, $color); $numberOfOpponents++; $lastValue = $value; } } $tempPos = strpos($lastValue,'

Specialization Index = ')+29; $specialIndex = substr($lastValue, $tempPos, strpos($lastValue, '

')-$tempPos); $tempPos = strpos($lastValue,'

Momentum = ')+17; $momentum = substr($lastValue, $tempPos, strpos($lastValue, '

Expected')-$tempPos-10); $Beta = ($Sxy*$numberOfOpponents-$Sx*$Sy)/($Sxx*$numberOfOpponents-$Sx*$Sx); $Alpha = ($Sy - $Beta*$Sx)/$numberOfOpponents; imagestring($graph, 2, 5, 5, $robotName.' in '.$robotGame, $black); imagestring($graph, 2, 5, 20, 'Rating: '.$currentRating, $black); imagestring($graph, 2, 5, 35, 'Battles: '.$numberOfBattles, $black); imagestring($graph, 2, 5, 50, 'Opponents: '.$numberOfOpponents, $black); imagestring($graph, 2, 5, 65, 'Specialization: '.$specialIndex, $black); imagestring($graph, 2, 5, 80, 'Momentum: '.$momentum, $black); imagestring($graph, 2, 5, 305, "0% ", $black); imagestring($graph, 2, 570, 305, "100%", $black); imagestring($graph, 2, 305, 5, "+30 ", $black); imagestring($graph, 2, 305, 580, "-30 ", $black); imagestring($graph, 2, 5, 535, $extremeUnproblemBots.' extremely unproblemistic bots.', $black); imagestring($graph, 2, 5, 550, $extremeProblemBots.' extremely problemistic bots.', $black); imagestring($graph, 2, 5, 565, 'X Axis is the Expected Score. (0% to 100%)', $black); imagestring($graph, 2, 5, 580, 'Y Axis is the ProblemBot Index (-30 to +30)', $black); imageline($graph,0,300,600,300,$black); imageline($graph,300,0,300,600,$black); imageline($graph,0,$Alpha,600,$Alpha+$Beta*600, imagecolorallocate($graph, 0, 0, 255)); } //dispay the image //header("Content-type: image/gif"); $tempname = urldecode("./lrp/".$robotName.".gif"); //Just in case - security is a pinch. imagegif($graph, $tempname); imagedestroy($graph); //end the map and display the image echo $imagemap; echo ''; echo '

'; ?>