--- title: "Geiger Counter" id: 57521 type: "computer_media" slug: "geiger-counter" url: "http://localhost/computer_media/geiger-counter/" markdown_url: "http://localhost/computer_media/geiger-counter.md" published_at: "2024-10-05T21:24:32+00:00" modified_at: "2026-03-30T21:17:29+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/276_GC.png" excerpt: "Navigate a 10×10 grid hunting hidden plutonium using a Geiger counter proximity formula — can you find it in the fewest moves?" 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: 56737 title: "Timex Sinclair Public Domain Library Tape 1006" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1006/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/276_GC.png" media_type_tags: "Game, Software" --- # Geiger Counter This program implements a grid-based treasure-hunt game where the player searches for hidden plutonium on a 10×10 grid. A random target position is set at lines 20–30, and the player navigates a cursor around the grid using keys 5, 6, 7, and 8, with a simulated “Geiger counter” reading at line 290 giving a proximity hint calculated as ABS(B-D)*7.29+C+A. The score counter S tracks the number of moves taken, and success triggers a congratulatory message before automatically restarting via RUN at line 950. Inverse-video characters are used throughout for the grid cells and cursor marker. *** ## Program Analysis ### Program Structure The program divides into four logical phases: 1. **Initialisation (lines 10–50):** Score reset, random target coordinates generated, screen cleared. 2. **Grid drawing (lines 90–130):** Nested `FOR` loops paint a 10×10 field of inverse-space characters. 3. **Game loop (lines 140–300):** Cursor placed, moved by key input, boundary-clamped, proximity hint printed, repeat. 4. **Win sequence (lines 900–980):** Victory message, pause, CLS, and RUN to restart. ### Grid and Coordinate System The playfield occupies screen rows 1–10 and columns 1–10, drawn with `PRINT AT Y,X;"% "` — an inverse-video space pair that fills each cell. The cursor is shown as an inverse `X` (line 170, `"%X"`) and erased to an inverse `+` (line 190, `"%+"`) before the next position is drawn. The target column `A` is chosen in the range 2–9 and target row `B` in the range 1–9, ensuring it always falls within the visible grid. ### Movement and Input Handling Key detection uses five consecutive `IF INKEY$=` checks (lines 200–235). Because each is a separate statement rather than `ELSE IF`, all five are evaluated every iteration regardless of which key is pressed. The mapping follows the conventional ZX layout: | Key | Action | | --- | --- | | `7` | Move up (C−1) | | `6` | Move down (C+1) | | `5` | Move left (D−1) | | `8` | Move right (D+1) | | `S` | Stop / break out | Boundary clamping at lines 240–270 keeps `C` and `D` in the range 1–10 after any move. ### Proximity (“Geiger Counter”) Formula The hint displayed at line 290 is `ABS(B-D)*7.29+C+A`. This is an asymmetric distance measure: vertical separation is heavily weighted by the factor 7.29, while horizontal separation has no multiplier. Notably, the formula adds the absolute target coordinates `A` and `C` (the current cursor row) rather than their difference, which means the reading does not approach zero as the cursor nears the target — it approaches `A+B` (roughly 3–17) rather than 0. This gives a relative rather than absolute proximity indicator. ### Score Tracking The variable `S` is incremented at line 175 on every iteration of the main loop, including the initial placement before any key is pressed. The pause at line 180 (`PAUSE 40`, approximately 1.6 seconds at 50 Hz) paces each turn. The win screen at line 900 reports `S` as the number of tries. ### Notable Techniques and Anomalies - Lines 40 and 50 are bare `PRINT` statements that output blank lines, providing a rough screen clear at the top without a full `CLS`. - Line 960 (`CLEAR`) and line 980 (`RUN`) are unreachable dead code; after the win sequence the program branches to line 950 (`RUN`), which restarts immediately. - The `SAVE "1027%6"` at line 970 uses an inverse-video digit in the filename, which acts as an auto-run flag on save. - Using `PRINT AT C,D` with `C` as the row and `D` as the column is unconventional naming (one might expect row=R, col=C), which could cause confusion when reading the proximity formula where both `C` and `A` are row values. - The erasing step at line 190 prints an inverse `+` rather than restoring the original grid cell character (inverse space), leaving a visible trail of `+` marks showing the player’s path — an intentional or incidental feature that aids navigation. ## Source Code ``` 10 LET S=0 20 LET A=2+INT (RND*8) 30 LET B=1+INT (RND*9) 40 PRINT 50 PRINT 90 FOR X=1 TO 10 100 FOR Y=1 TO 10 110 PRINT AT Y,X;"% "; 120 NEXT Y 130 NEXT X 140 LET C=1 150 LET D=1 170 PRINT AT C,D;"%X" 175 LET S=S+1 180 PAUSE 40 190 PRINT AT C,D;"%+" 200 IF INKEY$="7" THEN LET C=C-1 210 IF INKEY$="5" THEN LET D=D-1 220 IF INKEY$="6" THEN LET C=C+1 230 IF INKEY$="8" THEN LET D=D+1 235 IF INKEY$="S" THEN STOP 240 IF C<1 THEN LET C=1 250 IF C>10 THEN LET C=10 260 IF D<1 THEN LET D=1 270 IF D>10 THEN LET D=10 280 IF A=C AND B=D THEN GOTO 900 290 PRINT AT 11,0;"GEIGER COUNTER READS ";ABS (B-D)*7.29+C+A 300 GOTO 170 900 PRINT AT 13,3;"YOU FOUND THE PLUTONIUM"," IN ";S;" TRIES" 910 PRINT AT 11,0;" " 920 PRINT AT C,D;"%P" 930 PAUSE 500 940 CLS 950 RUN 960 CLEAR 970 SAVE "1027%6" 980 RUN ```