Alien Lure

This file is part of and Timex Sinclair Public Domain Library Tape 1003. Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Game

Alien Lure is a grid-based strategy game in which the player manoeuvres a piece (the “lure,” displayed as an asterisk) around a 5×9 sub-grid to attract and trap alien ships. Two player pieces and three alien pieces move simultaneously on rows 17–21, with column positions constrained to even values (0, 2, 4, 6, 8). The aliens use a simple probabilistic AI governed by RND comparisons to chase the player’s lure position. A second “gun” mode (G=2) fires a separate marker at an adjacent cell, destroying any alien it hits for 100 or 200 points, while extra lives are awarded every 3000 points. Skill level A (Amateur) or P (Professional) affects alien movement decisions at certain board positions.


Program Analysis

Program Structure

The program is organised into several functional blocks:

  1. Lines 1–22: Initialisation — skill level input, high score display, score and lives setup.
  2. Lines 40–170: Game variable initialisation — player position (U, V), two player-ship positions (X,Y and A,B), three alien positions (C,D; E,F; GG,HH), and a gun-sight position (HX,HY).
  3. Lines 195–770: Main game loop — draws all pieces, then cycles through each entity by saving its coordinates into M,N, calling the AI movement subroutine at 2000, then jumping through the dispatch mechanism at 6000.
  4. Lines 2003–2420: Movement/AI subroutine — reads keys 1/2 for mode switching, computes RND-driven alien movement, detects player capture.
  5. Lines 2430–3040: Player movement subroutine — handles keys 5/6/7/8, enforces grid constraints, manages the gun sight (mode 2), and checks for collisions.
  6. Lines 6000–6060: Collision and scoring dispatch — checks whether the moved entity coincides with any other entity, awards points, and routes back to the correct continuation line via the variable W.
  7. Lines 7000–7040: Life-loss handler — decrements SO, pauses, clears screen, restarts round if lives remain.
  8. Lines 8000–8200: Game-over sequence — scrolls screen, updates high score, prints “GAME OVER” message, returns to line 2 for a new game.

Movement and Dispatch Mechanism

Rather than using a large IF–THEN chain or ON–GOTO, the program uses a computed-return technique. Before each AI subroutine call, the variable W is set to the line number that should execute after the entity’s position has been applied (e.g. LET W=345 before the first entity, LET W=410 for the second, and so on). The dispatch at line 6000 then either jumps to W (on collision) or to W-10 (normal movement). This means each entity’s “write-back and redraw” lines are exactly 10 lines apart from the corresponding “no collision” target — a deliberate and compact layout strategy.

Grid Constraints

All entities are restricted to a sub-grid spanning rows 17–21 and columns 0–8, but column movement is further constrained to even values only (0, 2, 4, 6, 8), and row movement to odd rows within 17–21. The conditions like V=0 OR V=2 OR V=4 OR V=6 OR V=8 and U=17 OR U=19 OR U=21 appear repeatedly in both the player movement and alien AI subroutines to enforce this checkerboard-style grid.

Alien AI

The alien movement subroutine (lines 2003–2420) uses two random values R and Z generated by RND. The basic strategy is: if certain board conditions are met (edge proximity, Professional skill level, parity of column), the alien moves vertically toward the lure’s row; otherwise it moves horizontally toward the lure’s column. The threshold 0.5 vs 0.7 for Z biases movement in one direction, producing slightly asymmetric drift. Skill level P enables additional directional biasing at lines 2090, 2120, and 2122.

Dual-Mode Gun System

Pressing key 2 switches to gun mode (G=2); key 1 reverts to lure mode. In gun mode (subroutine from line 2590), the lure’s current position is used as the origin, and one of the directional keys fires a marker O to an adjacent cell stored in HX,HY. The dispatch at line 6005 checks whether any alien occupies the gun-sight cell and awards points. A base hit scores 100; if the entity was the first player ship (Q=141), an additional 100 is awarded (lines 6020–6035), giving 200 total. After a hit, HX is reset to 15 (off the playfield) at line 6050.

Scoring and Extra Lives

Score is displayed live at column 21 of row 18. Extra lives are granted at line 6044 using the condition S/3000 = INT(S/3000) — every exact multiple of 3000 points — with a second clause (S-100)/3000 = INT((S-100)/3000) to catch the case where the score was at 2900 before a 100-point hit, preventing a missed boundary.

Notable Bugs and Anomalies

  • Line 2520 — Missing key check: The condition reads IF INKEY$<>"5" AND V>0 … but the intent is clearly IF INKEY$="5". As written, pressing any key other than 5 can decrement V, making left-movement behaviour erratic.
  • Line 2600 — Typo in condition: UL21 is almost certainly a typo for U=21, causing the condition to evaluate differently than intended and potentially breaking rightward gun movement.
  • Line 3000 — Missing OR operator: The condition HX=A AND HY=BWHX=C appears to be a truncated/corrupted expression — BWHX is not a valid variable; this should read HY=B OR HX=C. This would prevent correct detection of gun hits on the second player ship and first alien.
  • Line 2560 — Variable O vs 0: The condition V=O uses what appears to be the letter O rather than the digit 0. If O is not initialised, this evaluates as 0 anyway on ZX BASIC (unset numeric variables default to 0), so it is effectively harmless but is a readability issue.

Variable Summary

VariableRole
U, VPlayer lure row, column
X, YFirst player ship row, column
A, BSecond player ship row, column
C, DAlien 1 row, column
E, FAlien 2 row, column
GG, HHAlien 3 row, column
HX, HYGun sight row, column
M, NTemporary working position for current entity
WDispatch target line number
GGun mode (1=lure, 2=gun)
QCHR$ code for scoring display (141 or 189)
SCurrent score
SOSpare men (lives)
BESTHigh score (persists across games)
R, ZRandom values for alien AI decisions
A$Skill level (“A” or “P”)

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10122 – 10175.

Related Products

Related Articles

A game which links the bugbaiting type of program with a battle against alien invaders has been produced by Sanath...

Related Content

Image Gallery

Alien Lure

Source Code

   1 REM ALIEN LURE
   2 LET BEST=0
   3 PRINT "SKILL LEVEL? A=AMATEUR/P=PROFESSIONAL"
   4 INPUT A$
   5 CLS 
  10 LET SO=2
  15 LET S=0
  20 PRINT """HOLED UP"""
  21 PRINT AT 14,15;"LEVEL:";A$
  22 PRINT AT 16,10;"HIGH SCORE: ";BEST
  23 PRINT AT 18,0;"     YOUR SCORE:";S
  30 PRINT AT 20,0;"      SPARE MEN:";SO
  40 LET X=17
  50 LET Y=0
  60 LET A=17
  70 LET B=8
  80 LET U=21
  90 LET V=4
 100 LET G=1
 110 LET HX=15
 120 LET HY=0
 130 LET C=17
 140 LET D=4
 150 LET E=19
 160 LET F=2
 165 LET GG=19
 170 LET HH=6
 195 PRINT AT U,V;"*"
 200 PRINT AT X,Y;"$"
 210 PRINT AT A,B;"$"
 220 PRINT AT C,D;"X"
 230 PRINT AT E,F;"X"
 240 PRINT AT GG,HH;"X"
 300 LET Q=141
 305 LET M=X
 310 LET N=Y
 320 GOSUB 2000
 322 LET W=345
 325 GOTO 6000
 335 LET X=M
 340 LET Y=N
 345 PRINT AT X,Y;"$"
 347 GOSUB 2430
 350 LET M=A
 360 LET N=B
 370 GOSUB 2000
 375 LET W=410
 380 GOTO 6000
 400 LET B=N
 405 LET A=M
 410 PRINT AT A,B;"$"
 415 GOSUB 2430
 417 LET Q=189
 420 LET M=C
 440 LET N=D
 460 GOSUB 2000
 470 LET W=510
 475 GOTO 6000
 500 LET D=N
 505 LET C=M
 510 PRINT AT C,D;"X"
 515 GOSUB 2430
 520 LET M=E
 540 LET N=F
 560 GOSUB 2000
 570 LET W=610
 580 GOTO 6000
 600 LET F=N
 605 LET E=M
 610 PRINT AT E,F;"X"
 615 GOSUB 2430
 620 LET M=GG
 640 LET N=HH
 660 GOSUB 2000
 670 LET W=710
 680 GOTO 6000
 700 LET HH=N
 705 LET GG=M
 710 PRINT AT GG,HH;"X"
 720 GOSUB 2430
 770 GOTO 300
\n2003 IF INKEY$="1" THEN LET G=1
\n2004 IF INKEY$="2" THEN LET G=2
\n2005 LET R=RND
\n2010 LET Z=RND
\n2020 PRINT AT M,N;" "
\n2090 IF M=18 OR M=20 OR N=V AND A$="P" AND (N=0 OR N=2 OR N=4 OR N=6 OR N=8) THEN GOTO 2120
\n2100 IF R<=.5 OR M=U OR N=1 OR N=3 OR N=5 OR N=7 THEN GOTO 2300
\n2120 IF M=21 OR U<M AND A$="P" THEN LET Z=.7
\n2122 IF M=17 OR U>M AND A$="P" THEN LET Z=.5
\n2125 IF Z<=.5 THEN LET M=M+1
\n2140 IF Z>.5 THEN LET M=M-1
\n2160 GOTO 2340
\n2300 IF N=0 OR N<V THEN LET Z=.5
\n2305 IF N=8 OR N>V THEN LET Z=.7
\n2310 IF Z<=.5 THEN LET N=N+1
\n2320 IF Z>.5 AND N>0 THEN LET N=N-1
\n2340 IF M=U AND N=V THEN GOTO 7000
\n2400 IF INKEY$="2" THEN LET G=2
\n2410 IF INKEY$="1" THEN LET G=1
\n2420 RETURN 
\n2430 IF INKEY$<>"5" AND INKEY$<>"6" AND INKEY$<>"7" AND INKEY$<>"8" THEN RETURN 
\n2440 IF G=2 THEN GOTO 2590
\n2450 PRINT AT U,V;" "
\n2520 IF INKEY$<>"5" AND V>0 AND (U=17 OR U=19 OR U=21) THEN LET V=V-1
\n2540 IF INKEY$="8" AND V<8 AND (U=17 OR U=19 OR U=21) THEN LET V=V+1
\n2560 IF INKEY$="6" AND U<21 AND (V=O OR V=2 OR V=4 OR V=6 OR V=8) THEN LET U=U+1
\n2580 IF INKEY$="7" AND U>17 AND (V=0 OR V=2 OR V=4 OR V=6 OR V=8) THEN LET U=U-1
\n2585 GOTO 3005
\n2590 PRINT AT HX,HY;" "
\n2597 IF INKEY$="5" AND V>0 AND (U=21 OR U=19 OR U=17) THEN GOTO 2700
\n2600 IF INKEY$="8" AND V<8 AND (UL21 OR U=19 OR U=17) THEN GOTO 2750
\n2620 IF INKEY$="6" AND U<21 AND (V=0 OR V=2 OR V=4 OR V=6 OR V=8) THEN GOTO 2800
\n2640 IF INKEY$="7" AND U>17 AND (V=0 OR V=2 OR V=4 OR V=6 OR V=8) THEN GOTO 2850
\n2660 GOTO 3005
\n2700 LET HX=U
\n2710 LET HY=V-1
\n2720 GOTO 3000
\n2750 LET HX=U
\n2760 LET HY=V+1
\n2770 GOTO 3000
\n2800 LET HX=U+1
\n2810 LET HY=V
\n2820 GOTO 3000
\n2850 LET HX=U-1
\n2860 LET HY=V
\n3000 IF HX=X AND HY=Y OR HX=A AND HY=BWHX=C AND HY=D OR HX=E AND HY=F OR HX=GG AND HY=HH THEN LET HX=15
\n3003 IF HX<>15 THEN PRINT AT HX,HY;"O"
\n3020 IF HX=U AND HY=V OR U=X AND V=Y OR U=A AND V=B OR U=C AND V=D OR U=E AND V=F OR U=GG AND V=HH THEN GOTO 7000
\n3030 PRINT AT U,V;"*"
\n3040 RETURN 
\n6000 IF M=X AND N=Y OR M=A AND N=B OR M=C AND N=D OR M=E AND N=F OR M=GG AND N=HH THEN GOTO W
\n6005 IF M=HX AND N=HY THEN GOTO 6020
\n6010 GOTO W-10
\n6020 IF Q=141 THEN LET S=S+100
\n6035 LET S=S+100
\n6040 PRINT AT M,N;CHR$ Q
\n6044 IF S/3000=INT (S/3000) OR       (S-100)/3000=INT ((S-100)/3000) THEN LET SO=SO+1
\n6045 PRINT AT 18,21;S
\n6047 PRINT AT 20,21;SO
\n6050 LET HX=15
\n6060 GOTO W-10
\n7000 PRINT AT U,V;"*"
\n7010 LET SO=SO-1
\n7030 PAUSE 100
\n7032 IF SO=-1 THEN GOTO 8000
\n7035 CLS 
\n7040 GOTO 20
\n8000 FOR N=0 TO 21
\n8010 SCROLL 
\n8020 NEXT N
\n8030 IF S>BEST THEN LET BEST=S
\n8040 PRINT AT 0,0;"GAME OVER, ALL YOUR MEN ARE DEAD"
\n8050 GOTO 2
\n8100 SAVE "1013%6"
\n8200 RUN 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top