Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int findOre (List<Grid> G, robot myRobot)
- {
- int index = -404; //stands for 404 - has not found any ore
- double distance = 30*30 + 15*15+1; //just a number, so my program thinks it's the biggest distance ever
- for(int i = 0; i < G.Count(); i++)
- {
- if (G[i].status != "?" && G[i].status != "0")
- {
- double newDistance = Math.Pow(myRobot.x - G[i].x,2) + Math.Pow(myRobot.y - G[i].y,2);
- if( newDistance < distance)
- {
- distance = newDistance;
- index = i;
- }
- }
- }
- return index;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement