Esempio n. 1
0
 public int waves_over(double x, double y) {
   int current_waves = 0;
   for (WaveModel wave : surf_bum) {
     // System.out.println("Evaluating distance");
     double distance_early = Brain.distance(wave.early_origin_x, wave.early_origin_y, x, y);
     double distance_late = Brain.distance(wave.late_origin_x, wave.late_origin_y, x, y);
     // System.out.println("early distance "+distance_early+" <= "+wave.early_radius);
     // System.out.println("late distance  "+distance_late+" >= "+wave.late_radius);
     if (distance_early >= wave.early_radius && distance_late <= wave.late_radius) {
       current_waves++;
       // System.out.println("waves overlap "+current_waves);
     }
   }
   return current_waves;
 }
Esempio n. 2
0
 public void process() {
   // super.process();
   // run the default process first, so that it will always generate some movement
   // then update all of the waves to the most up to date time and location
   check_surf();
   // System.out.println(" tracking "+surf_bum.size()+" waves");
   long current_time = robot.getTime();
   for (int i = 0; i < surf_bum.size(); i++) {
     update(surf_bum.get(i), current_time);
   }
   if (robot.getTurnRemainingRadians() <= .01) {
     double[] output = inner_points_test(long_points_test());
     double desired_math_heading = Math.atan2(robot.getY() - output[1], robot.getX() - output[0]);
     System.out.println("desired math = " + desired_math_heading);
     double desired_heading = (-desired_math_heading + Math.PI / 2);
     double current_heading = robot.getHeadingRadians();
     moveEndTheta = (desired_heading - current_heading) % (2 * Math.PI);
     System.out.println("move End Theta = " + moveEndTheta);
     moveEndDistance = Brain.distance(output[0], output[1], robot.getX(), robot.getY());
   }
   // TODO IDEAPAD
   /*
    * The robot should test 32 points at radius of 50 around itself, and evaluate
    * 	based on the waves washing over that point.
    * 	This uses a similar function to below, with distance from current heading being good
    * 	divided by the number of waves washing over
    *  	f: (1-cos(delta angle)/2*(waves+1)
    *
    * The bearing to that point is stored.
    * Then randomly generate 8 points at random that are at less than 50 units away
    *  , and rate them based on how close they are in bearing to the first point
    *  (cos of delta bearing) and wave crossings (sum of waves washing over) for a
    *  	f: cos(bearing_50-bearing_8)/(num of waves+1).
    *
    * 	Use a move to point function to move to the interior point
    * 	with the highest rating
    *
    * 	TODO implement this first. It shouldn't be to hard,
    *  //DONE create a function that takes a point and counts wave overlap
    *  //DONE Then create a function that generates outer points, tests and returns the
    *  	optimal outer point bearing
    *  //DONE From there, use a different function to generate random inner points (8<=d<50),
    *  	choose the best one, and then output the point to move to.
    *  //DONE displaying all wave data, appears to be functioning
    *  TODO display movement data
    */
   // TODO Improvements
   /*
    * Filter our waves that are not from shootings (recharge time, etc)
    * Other sources:
    * 		Walls
    * 		Self-bullet contacts
    * 		Other bullet contacts
    * 		Ramming
    *
    * Stay away from other robots
    * 		robot size ~= 40, move speed 8
    * 		needs 5++ turns to get out of it's own way
    * 		bullets travel at max 20
    * 		have the robot try to avoid being closer than 140-160 from other robots
    * 		This gives "reaction time" to wave of 7-8 turns
    */
 }