home *** CD-ROM | disk | FTP | other *** search
- (**************************************************************************)
- (* W A R N I N G *)
- (* *)
- (* This Robot has NOT been designed to take advantage of the advanced *)
- (* features of P-ROBOTS, such as, Shields, Fuel, Teams or Obstructions. *)
- (**************************************************************************)
-
- PROCEDURE PITBULL;
- {
- T.J.Lyman
- PROBOTS simulation for individual robot competition
-
- This robot is designed primarily to be fast and to keep moving, to
- quickly scan for an enemy and fire, then move before the enemy can
- detect it. It is constantly moving in a clockwise direction in a
- circle of radius 400 (roughly) around the center point of the arena.
- Each new target point to which it travels is 80 degrees clockwise
- on the circle from the previous point. This minimizes the amount of
- times the robot needs to slow down to turn but also prevents it from
- staying in the same direction for too long, thus becoming trackable
- by another robot.
-
- The robot performs only two or three scan operations in any given
- pass through its main loop. It checks in two scan directions for the
- enemy: the last scan direction calculated in the last pass through
- loop plus the last scan direction it found an enemy at. If it finds
- the enemy, it quickly does another search of scan width plus or minus
- 5 degrees to zero in on the enemy position. Based on geometric
- calculations this should land the shell within 40 spaces of the point
- at which the enemy was sighted (of course, the enemy could have moved)
- if the enemy is within 450 spaces. More searches to test for other
- possible enemy positions, e.g. 20 degrees removed from the last known
- x,y coordinates were tested but not included in the program since
- they slowed the robot down. The same was true for zeroing in closer
- on the enemy angle. If the enemy was also on the move, zeroing
- in closer was not too effective.
-
- It then fires two cannon shots: one directly at where it thinks the
- enemy is and a second shot in the same direction but 100 space further
- out. This is to account for the robot and its enemy both being in
- motion. The enemy could have moved in any direction since being seen.
- A spot 100 spaces out was chosen since it was easy and quick to
- calculate and seemed to have the added advantage of being effective
- when the enemy was close to a wall. Logic was also tested to detect
- the enemy's direction and speed but was not included in the program
- because it slowed it down. A total of two shots is fired since only
- two shells can be in the air at the same time.
-
- If the enemy is found in a new scan direction, its x,y coordinates
- are calculated and saved. If the enemy is not found in either of the
- two scan directions, it sets a new scan direction 20 clockwise from the
- current one. The scan direction seemed to be more effective when
- moving in the same direction as the robot. Since this robot moves
- clockwise around the circle, its scan direction also moves clockwise.
-
- PITBULL is able to shed logic by building protections inherently into
- its algorithm. Its circular motion never brings it close enough to
- the walls to check for hitting the wall or firing at close range
- toward the wall. Since it is constantly on the run, it does not check
- itself for damage. It also takes a calculated risk that it will not
- fire its cannon within a range of 40 spaces at its enemy. It is
- willing to take the trade in damage. Minimal use is also made of
- subroutines to avoid any unnecessary overhead. Thus some small pieces
- of logic are duplicated in a few places.
-
- PITBULL is a general purpose robot but designed primarily to compete
- against robots that are constantly moving. It will not be as effective
- as other possible robots at finding and destroying a stationary target.
- It is, however, relentless. It keeps coming back, which is how it got
- its name.
- }
- VAR
- xe, ye, scandir, scandist, movedir : Integer;
-
- PROCEDURE GOTO(x, y : Integer);
- BEGIN ;
- {
- Record the direction to the next point on the circle. Keep moving
- in that direction at speed 100 until within 200 spaces of the
- target point.
-
- }
- movedir := Angle_To(x, y);
- WHILE (distance(loc_x, loc_y, x, y) > 200) DO
- BEGIN
- DRIVE(movedir, 100);
- {
- Scan in direction set in last pass through the program. If the
- enemy is found, zero in within 5 degrees, fire two shells and
- record the enemy's x,y coordinates. If the enemy is not found,
- then scan in the direction of the last recorded enemy x,y
- coordinates. If the enemy is found here, zero in and fire.
- If the enemy is not found in either scan direction, advance the
- scan 20 degrees clockwise for the next pass through the program.
- }
- scandist := SCAN(scandir, 10);
- IF scandist <> 0
- THEN
- BEGIN
- IF SCAN((scandir+5) MOD 360, 5) <> 0
- THEN
- BEGIN
- CANNON((scandir+5) MOD 360, scandist);
- CANNON((scandir+5) MOD 360, scandist+100);
- END
- ELSE
- BEGIN
- CANNON((scandir+355) MOD 360, scandist);
- CANNON((scandir+355) MOD 360, scandist+100);
- END;
- xe := loc_x+Round(scandist*Cos(scandir));
- ye := loc_y+Round(scandist*Sin(scandir));
- END
- ELSE
- BEGIN
- scandist := SCAN(Angle_To(xe, ye), 10);
- IF scandist <> 0
- THEN
- BEGIN
- scandir := Angle_To(xe, ye);
- IF SCAN((scandir+5) MOD 360, 5) <> 0
- THEN
- BEGIN
- CANNON((scandir+5) MOD 360, scandist);
- CANNON((scandir+5) MOD 360, scandist+100);
- END
- ELSE
- BEGIN
- CANNON((scandir+355) MOD 360, scandist);
- CANNON((scandir+355) MOD 360, scandist+100);
- END;
- END
- ELSE scandir := (scandir+340) MOD 360;
- END;
- END;
- {
- Robot is now within 200 spaces of target point. Enter slow down
- command and exit loop to calculate a new target point.
- }
- DRIVE(movedir, 0);
- END;
-
- BEGIN ;
- {
- Move initially to the closest point on the circle of radius 400
- from the center point. Set initial scan and enemy position
- coordinates to the center point.
- }
- movedir := (Angle_To(500, 500)+180) MOD 360;
- scandir := Angle_To(500, 500);
- xe := 500;
- ye := 500;
- scandist := 200;
- {
- Set a target point on the circle based on the move direction
- calculated the last time through. When the next point is reached
- calculate a new point 80 degrees clockwise from the previous and
- repeat the loop. Keep repeating the process until one of the robots
- has been destroyed.
- }
- REPEAT
- GOTO(500+Round(400.0*Cos(movedir)), 500+Round(400.0*Sin(movedir)));
- movedir := (movedir+280) MOD 360;
- UNTIL DEAD OR WINNER;
-
- END;
-