Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //GRID CLASS
- public class Grid
- {
- public int x { get; set; }
- public int y { get; set; }
- public string status { get; set; }
- public int hole { get; set; }
- public Grid ()
- {
- status = "?";
- }
- }
- //ROBOT CLASS
- public class robot
- {
- public int x { get; set; }
- public int y { get; set; }
- public int item {get; set;}
- public int id {get; set;}
- public robot (int _x, int _y, int _item)
- {
- x = _x;
- y = _y;
- item = _item;
- }
- }
- 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;
- }
- //Methods for basic robot-functions //Basic functions for easier testing and programming
- public static void move(int x, int y) => Console.WriteLine("MOVE {0} {1}",x,y);
- public static void dig(int x, int y) => Console.WriteLine("DIG {0} {1}",x,y);
- public static void request(string x) => Console.WriteLine("REQUEST {0}",x);
- public static void wait() => Console.WriteLine("WAIT");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement