Hello everyone,
Ok, well I am faced with the challenge of creating a scouting program for my robotics team so we could keep a track of how other teams do at competitions to compare and contrast their designs. I have 95% of the program done, it reads and adds info into an XML file with a team element for each team's data. It retrieves that information from the XML and displays it into a DataGridView component. The variables/values for each Team element are as follows:
Balls Scored
balls Blocked
Balls Hit Into Offensive Area
Penalties
Contribution
To calculate the best robot in the fields of defense and mid-field are easy, just find the number with the largest values for blocked and hit into offensive area respecitively. Calculating the best robot for offense is the difficult part for me. Here is my current code for calculating best teams.
private String[] getBestTeams() {
String[] bestTeams = new String[3];
string bestDef = "";
string bestMid = "";
string bestOff = "";
int highDef = 0;
int highMid = 0;
for (int i = 0; i < numofteams; i++)
{
if (Convert.ToInt32(scoutGrid.Rows[i].Cells[AfterNode.Blocked].Value) > highDef)
{
highDef = Convert.ToInt32(scoutGrid.Rows[i].Cells[AfterNode.Blocked].Value);
bestDef = scoutGrid.Rows[i].Cells[AfterNode.Team].Value.ToString();
}
if (Convert.ToInt32(scoutGrid.Rows[i].Cells[AfterNode.Moved].Value) > highMid)
{
highMid = Convert.ToInt32(scoutGrid.Rows[i].Cells[AfterNode.Moved].Value);
bestMid = scoutGrid.Rows[i].Cells[AfterNode.Team].Value.ToString();
}
}
bestTeams[0] = bestDef;
bestTeams[1] = bestMid;
bestTeams[2] = bestOff;
return bestTeams;
}
As you can see, it iterates through every row of the DataGridView (Rows) and then The corresponding Cells. I made a class with specific indexes for each cell pertaining to the value it holds, specifically:
AfterNode.Team
AfterNode.Scored
AfterNode.Blocked
AfterNode.Moved
AfterNode.Penalties
AfterNode.Contribution
My question is, how would I calculate the best offensive team, the team that has the highest balls scored, the highest contribution and the lowest number of penalties. Obviously the same robot has very little chances of matching all 3 fields. So how would I go about doing this. Thank you!