Go to Post Rules arent built around robots. Robots are built around the rules. - dodar [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 11-04-2008, 17:51
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]: Team Scoring Data Function

Here is the completed function I have been working on. It asks for 4 parameters.
  • $teamnumber: Any FIRST assigned team number.
  • $year: Any year TheBlueAlliance has data for (2006-present currently).
  • $highscore: Any number you'd like. (explained below)
  • $average: Set to TRUE or FALSE DEFAULT = TRUE(averaged score based on match score and total matches played, or just total points scored for the team's alliance in matches they've played in.)

This function serves two purposes. Basically it outputs an array of data ("score" and "bigmatches").
"Score" is (like said above) Averaged score over the year, or total points scored.
"bigmatches" takes the number set as $highscore and looks at all matches the team has played in. If the teams alliance in each match has a score higher than $highscore the counter goes up 1.

Here's the code:
PHP Code:
function getScoreData($teamnumber$year$highscore$average true)
  {
      
$competitions = array();
      
$matches = array();
      
$post_comps = array();
      
$attendance = array();
      
$bigmatches 0;
      
$event_weeks = array("Pre-Ship""Week 1""Week 2""Week 3""Week 4""Week 5""Week 6");
      
$score 0;
      
$events make_array(get_events(null$yearnull));
      foreach (
$events as $event) {
          if (
in_array($event["week"], $event_weeks)) {
              
$attendance make_array(get_attendance($event["eventid"], $teamnumber));
              if (
count($attendance) > 0) {
                  
$competitions[] = $event["eventid"];
              }
          } else {
              
$post_comps[] = $event["eventid"];
          }
      }
      foreach (
$competitions as $compID) {
          
$matches[] = make_array(get_matches($teamnumber$compID));
      }
      
$record make_array(get_official_record($teamnumbernull$year));
      foreach (
$matches as $match) {
          foreach (
$match as $match) {
              
$matchid $match["matchid"];
              if (
$match["red1"] == $teamnumber || $match["red2"] == $teamnumber || $match["red3"] == $teamnumber) {
                  
$alliance "red";
              } else {
                  
$alliance "blue";
              }
              if (
$alliance == "red") {
                  
$score += $match["redscore"];
                      if(
$match["redscore"] >= $highscore){
                        
$bigmatches++;
                    }
              } else {
                  
$score += $match["bluescore"];
                      if(
$match["bluescore"] >= $highscore){
                        
$bigmatches++;
                    }
              }
          }
      }
      if (
$average) {
          
$average_score round($score $record[0]["sum"], 0);
      } else {
          
$average_score $score;
      }
      
$data = array('score' => $average_score'bigmatches' => $bigmatches);
      return 
$data;
  } 
Here is an example of hows this would work.
PHP Code:
$var getScoreData(330200750); 
echo 
'Average score is:'.$var["score"].'<br />';
echo 
'Matches Over 50 points:'.$var["bigmatches"].'<br />'
Would return,
Average score is: 72
Matches Over 50 points: 22

I will be setting up a live test version on our website sometime soon. Feel free to use it in your own TBA applications.

Thanks to everyone who helped me find those pesky bugs, and help solve them too
Reply With Quote
 


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]: TBA API ActiveX Control Shadow503 The Blue Alliance 2 10-04-2008 08:59
[TBA]: Issues with TBA API FRANK(WGH) The Blue Alliance 7 17-03-2008 11:39
[TBA] Sumbit your Robot Photos on TBA lynca Robot Showcase 0 11-03-2008 13:25
[TBA] TBA Presents... Soldering and Multimeter Tutorials Greg Marra General Forum 0 27-01-2007 20:15
Scoring function in C mgreene Programming 7 12-01-2007 02:36


All times are GMT -5. The time now is 03:43.

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