Go to Post Our robot name is currently "Subject to Change". - JesseK [more]
Home
Go Back   Chief Delphi > Other > FIRST-related Organizations > The Blue Alliance
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-04-2008, 14:15
SamC SamC is offline
.
AKA: Sam Couch
FRC #0103 (Cybersonics)
Team Role: Programmer
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Philadelphia, PA
Posts: 583
SamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond reputeSamC has a reputation beyond repute
[TBA]: Total Points Put up by team and year

I wrote a simple function using the API to get the averaged or unaveraged points scored by teams and year.
(Excessive unnecessary comments...)
PHP Code:
function getScore($teamnumber$year$average FALSE)
{
    
$competitions = array(); //Contains TBA assigned "eventid"'s for events attended by team X
    
$score 0//Initialization of $score. Not sure it's entirely neccisary
    
$events make_array(get_events(NULL$yearNULL)); //Assigns array of events that occured in designated $year to $events
    
foreach ($events as $event){ //breakdown of each $event within $events
        
if($event["week"] < 90){ //If event is NOT champs OR off-season
            
$attendance make_array(get_attendance($event["eventid"], $teamnumber)); //Lookup of $teamnumber within the $event
            
if(count($attendance) > 0//If the array has data
            
{
                
$competitions[] = $event["eventid"]; //Add eventid to array of competitions attended
            
}
        }
        else{ 
//Otherwise
           //Do nothing
        
}
    }
    foreach(
$competitions as $compID){ //Breakdown of each $compID (eventid) withing $competitions
        
$matches make_array(get_matches($teamnumber$compID)); //lookup matched for each team at the event
    
}
    
$record make_array(get_official_record($teamnumber$year)); //official record of team by $year
    
foreach ($matches as $match){ //breakdown of $match in $matches
        
$matchid $match["matchid"]; //assigns matchid to a variable
        
if($match["red1"] == $teamnumber || $match["red2"] == $teamnumber || $match["red3"] == $teamnumber){ //determines if the team is on the red alliance
            
$alliance "red"//Assigns alliance variable an alliance name
        
}
        else{ 
//if they weren't red
            
$alliance "blue"//must be blue
        
}
        if(
$alliance == "red"){ //If alliance is RED
            
$score += $match["redscore"]; //add redscore for specific match to the total score
        
}
        else{ 
//If alliance is blue
            
$score += $match["bluescore"]; //add bluescore for specific match to the total score
        
}
    }
    if(
$average){ //if parameter $average is set to TRUE
    
$average_score round($score/count($matches), 0); //round the amount of the total score over total matches in question
    
}
    else{ 
//If parameter $average is set to FALSE [DEFAULT]
    
$average_score $score//$average_score is the total score
    
}
    return 
$average_score//output $average_score

When i call it as getScore(330, 2007); or getScore(330, 2007, TRUE); (or even 2006 instead of 2007) and It outputs a score. The score doesn't match up with my manual calculation (2007 unaveraged should be 3,000+ and only returns around 870). If I change the year to 2008 however, it returns 0 (or if I remove the $score initialization line, outputs nothing). Someone suggested that maybe its trying to grab data from 2008 champs and therefore throwing off the data. However, I figured since no matches were listed for champs it most likely wasn't the issue. Nonetheless I added the check for which "week" the events were in, if (week < 90){

Any ideas how to resolve this issue?
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[TBA]: Schedules and TBA API proegssilb The Blue Alliance 3 09-03-2008 15:55
[TBA] TBA Presents... Soldering and Multimeter Tutorials Greg Marra General Forum 0 27-01-2007 20:15
pic: YMTC: 150 points or 100 points? CD47-Bot Extra Discussion 4 25-03-2004 01:53
put and get Robert Hafner Programming 4 10-02-2004 10:58
Awards and points... Ian W. Rules/Strategy 4 24-03-2002 13:30


All times are GMT -5. The time now is 19:44.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi