home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Hack-Phreak Scene Programs
/
cleanhpvac.zip
/
cleanhpvac
/
P_ROBO31.ZIP
/
HIDNSEEK.PR
< prev
next >
Wrap
Text File
|
1989-10-31
|
4KB
|
93 lines
(**************************************************************************)
(* 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. *)
(**************************************************************************)
{ Pascal Robot "HIDNSEEK.PR" Don Lefebvre
Strategy: This robot has two modes: a "hunting" mode in which it
pursues the opponent robot, and a "sparing" mode in which
it circles the opponent robot. At game start, the opponent
is found and scanned twice. If it is approaching then it
is assumed to be a hunter and the sparing mode is used,
otherwise the hunting mode is used.
Hunting: - Use range to determine whether opponent is advancing
or receding and adjust range accordingly, then shoot.
- Move directly at the opponent at spped proportional
to range (slows at close range).
Sparing: - Move at right angles to advancing hunter robot.
- Shoot without adjusting range.
}
PROCEDURE hidnseek;
CONST
check = 3; { wait time for checking opponent }
tol = 20; { tolerance for checking advancing opp. }
ang_adj = 95; { offset from heading for sparing robot }
adv_A = 0.85; { undershoot if opponent is advancing }
rec_A = 1.22; { overshhot if opponent is receding }
VAR
cnt : Integer; { number of cycles since last check }
switch : Integer; { flag indicating robot mode in effect }
head : Integer; { heading toward opponent robot }
range : Integer; { uncorrected range reported by scan }
old_rng : Integer; { range from previous scan }
corr_rng : Real; { range corrected for opponent's move }
rng1 : Integer; { save first range check }
hd1 : Integer; { save first heading check }
BEGIN
switch := 2; { initialize variables }
cnt := 0;
REPEAT
range := SCAN(head, 10); { check old position }
IF (range = 0) THEN BEGIN
head := head-30; { back up scan a bit }
REPEAT
head := head+20;
range := SCAN(head, 10);
UNTIL (range <> 0); { scan until find opp.}
END;
CASE switch OF
0 : BEGIN { "sparing" mode }
CANNON(head, range);
IF ((Abs(loc_x-500) > 400) OR (Abs(loc_y-500) > 400))
THEN DRIVE(Angle_To(500, 500), 100)
ELSE DRIVE((head+ang_adj) MOD 360, 100);
END;
1 : BEGIN { "hunting" mode }
IF (range < old_rng)
THEN corr_rng := range*adv_A
ELSE corr_rng := range*rec_A;
CANNON(head+4, corr_rng);
old_rng := range;
CANNON(head-4, corr_rng);
DRIVE(head, range DIV 2);
END;
2 : BEGIN { first range check }
CANNON(head, range);
cnt := cnt+1;
IF (cnt > check) THEN BEGIN
rng1 := range;
hd1 := head;
switch := 3;
END;
END;
3 : BEGIN { second range check }
IF ((range-rng1 < -tol) AND (Abs(head-hd1) < 10))
THEN switch := 0
ELSE switch := 1;
END;
END;
UNTIL DEAD OR WINNER;
END;