--- title: "Alien Lure" id: 57246 type: "computer_media" slug: "alien-lure" url: "http://localhost/computer_media/alien-lure/" markdown_url: "http://localhost/computer_media/alien-lure.md" published_at: "2024-10-04T07:14:46+00:00" modified_at: "2026-04-03T07:58:41+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/136_AL.png" excerpt: "A cunning grid-based alien-trapping game where probabilistic enemy AI and a dual-mode gun make every move a calculated risk — can you top the high score?" category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_contents: - id: 56734 title: "Timex Sinclair Public Domain Library Tape 1003" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1003/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/136_AL.png" article_media: - id: 8657 title: "Alien Lure" type: "article" url: "http://localhost/article/alien-lure/" media_type_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 | Variable | Role | | --- | --- | | `U`, `V` | Player lure row, column | | `X`, `Y` | First player ship row, column | | `A`, `B` | Second player ship row, column | | `C`, `D` | Alien 1 row, column | | `E`, `F` | Alien 2 row, column | | `GG`, `HH` | Alien 3 row, column | | `HX`, `HY` | Gun sight row, column | | `M`, `N` | Temporary working position for current entity | | `W` | Dispatch target line number | | `G` | Gun mode (1=lure, 2=gun) | | `Q` | CHR$ code for scoring display (141 or 189) | | `S` | Current score | | `SO` | Spare men (lives) | | `BEST` | High score (persists across games) | | `R`, `Z` | Random values for alien AI decisions | | `A$` | Skill level (“A” or “P”) | ## 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 2003 IF INKEY$="1" THEN LET G=1 2004 IF INKEY$="2" THEN LET G=2 2005 LET R=RND 2010 LET Z=RND 2020 PRINT AT M,N;" " 2090 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 2100 IF R<=.5 OR M=U OR N=1 OR N=3 OR N=5 OR N=7 THEN GOTO 2300 2120 IF M=21 OR UM AND A$="P" THEN LET Z=.5 2125 IF Z<=.5 THEN LET M=M+1 2140 IF Z>.5 THEN LET M=M-1 2160 GOTO 2340 2300 IF N=0 OR NV THEN LET Z=.7 2310 IF Z<=.5 THEN LET N=N+1 2320 IF Z>.5 AND N>0 THEN LET N=N-1 2340 IF M=U AND N=V THEN GOTO 7000 2400 IF INKEY$="2" THEN LET G=2 2410 IF INKEY$="1" THEN LET G=1 2420 RETURN 2430 IF INKEY$<>"5" AND INKEY$<>"6" AND INKEY$<>"7" AND INKEY$<>"8" THEN RETURN 2440 IF G=2 THEN GOTO 2590 2450 PRINT AT U,V;" " 2520 IF INKEY$<>"5" AND V>0 AND (U=17 OR U=19 OR U=21) THEN LET V=V-1 2540 IF INKEY$="8" AND V<8 AND (U=17 OR U=19 OR U=21) THEN LET V=V+1 2560 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 2580 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 2585 GOTO 3005 2590 PRINT AT HX,HY;" " 2597 IF INKEY$="5" AND V>0 AND (U=21 OR U=19 OR U=17) THEN GOTO 2700 2600 IF INKEY$="8" AND V<8 AND (UL21 OR U=19 OR U=17) THEN GOTO 2750 2620 IF INKEY$="6" AND U<21 AND (V=0 OR V=2 OR V=4 OR V=6 OR V=8) THEN GOTO 2800 2640 IF INKEY$="7" AND U>17 AND (V=0 OR V=2 OR V=4 OR V=6 OR V=8) THEN GOTO 2850 2660 GOTO 3005 2700 LET HX=U 2710 LET HY=V-1 2720 GOTO 3000 2750 LET HX=U 2760 LET HY=V+1 2770 GOTO 3000 2800 LET HX=U+1 2810 LET HY=V 2820 GOTO 3000 2850 LET HX=U-1 2860 LET HY=V 3000 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 3003 IF HX<>15 THEN PRINT AT HX,HY;"O" 3020 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 3030 PRINT AT U,V;"*" 3040 RETURN 6000 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 6005 IF M=HX AND N=HY THEN GOTO 6020 6010 GOTO W-10 6020 IF Q=141 THEN LET S=S+100 6035 LET S=S+100 6040 PRINT AT M,N;CHR$ Q 6044 IF S/3000=INT (S/3000) OR (S-100)/3000=INT ((S-100)/3000) THEN LET SO=SO+1 6045 PRINT AT 18,21;S 6047 PRINT AT 20,21;SO 6050 LET HX=15 6060 GOTO W-10 7000 PRINT AT U,V;"*" 7010 LET SO=SO-1 7030 PAUSE 100 7032 IF SO=-1 THEN GOTO 8000 7035 CLS 7040 GOTO 20 8000 FOR N=0 TO 21 8010 SCROLL 8020 NEXT N 8030 IF S>BEST THEN LET BEST=S 8040 PRINT AT 0,0;"GAME OVER, ALL YOUR MEN ARE DEAD" 8050 GOTO 2 8100 SAVE "1013%6" 8200 RUN ```