home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / pascal / P_ROBOTS.ZIP / P-ROBT21.ZOO / d.pr < prev    next >
Encoding:
Text File  |  1989-10-31  |  2.2 KB  |  67 lines

  1. (**************************************************************************)
  2. (*                             W A R N I N G                              *)
  3. (*                                                                        *)
  4. (*  This Robot has NOT been designed to take advantage of the advanced    *)
  5. (*  features of P-ROBOTS, such as, Shields, Fuel, Teams or Obstructions.  *)
  6. (**************************************************************************)
  7.  
  8. {Bob Sifniades}
  9.  
  10. {Strategy: Keep moving clock-wise around the periphery of the square in order
  11. to avoid being shot. Scan clock-wise to keep a lock on targets. Works well
  12. against any opponent that can't hit a moving target. Works very well against
  13. non-moving opponents. Works less well on opponents that move and hit
  14. moving targets. This goes for quantity of shots, not quality.}
  15.  
  16.   PROCEDURE D;
  17.  
  18.   VAR range, angle, goodangle : Integer;
  19.  
  20.  
  21.     PROCEDURE shoot;
  22.     BEGIN
  23.       range := SCAN(angle, 10);
  24.       IF range = 0 THEN
  25.         REPEAT
  26.           angle := angle-20;
  27.           range := SCAN(angle, 10);
  28.         UNTIL range <> 0;
  29.       {range >= 62 guarantees won't shoot self if firing ahead and going}
  30.       {at full speed}
  31.       IF (range >= 62) THEN
  32.         {50/50 chance of firing <angle-5> which hits still targets very well,}
  33.         {and <angle-5> thru <angle-20>, which tries to hit moving targets}  
  34.         CANNON(angle-5-Random(1)*Random(15), range);
  35.     END;
  36.  
  37.  
  38.  
  39.     {kludgey driver that gets me where I want to go}
  40.     PROCEDURE Move(x1, y1, x2, y2 : Integer); {x1,y1 is 1st dest; x2,y2 is next dest}
  41.     VAR heading, I : Integer;
  42.     BEGIN 
  43.       heading := Angle_To(x1, y1);
  44.       WHILE (distance(loc_x, loc_y, x1, y1)) >= 200 DO 
  45.         BEGIN
  46.           DRIVE(heading, 100);
  47.           shoot;
  48.         END;
  49.       DRIVE(heading, 40);
  50.       WHILE speed > 40 DO
  51.         shoot;
  52.       heading := Angle_To(x2, y2);
  53.       DRIVE(heading, 100);
  54.     END;                          {move}
  55.  
  56.  
  57.   BEGIN
  58.     angle := 10;
  59.     goodangle := -1;
  60.     REPEAT
  61.       Move(950, 100, 100, 50);
  62.       Move(100, 50, 50, 900);
  63.       Move(50, 900, 900, 950);
  64.       Move(900, 950, 950, 100);
  65.     UNTIL DEAD OR WINNER;
  66.   END;
  67.