--- title: "Space Station" id: 57414 type: "computer_media" slug: "space-station" url: "http://localhost/computer_media/space-station/" markdown_url: "http://localhost/computer_media/space-station.md" published_at: "2024-10-05T12:49:49+00:00" modified_at: "2026-04-03T07:58:31+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/215_SpSt.png" excerpt: "Manage oxygen, food, and credits aboard a threatened space station where alien raiders and dwindling supplies spell doom in this turn-based resource sim." 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/" indiv: - name: "Tim Hartnell" slug: "tim-hartnell" taxonomy: "indiv" url: "http://localhost/indiv/tim-hartnell/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" - name: "Resource Management" slug: "resource-management" taxonomy: "genre" url: "http://localhost/type/resource-management/" media_contents: - id: 56736 title: "Timex Sinclair Public Domain Library Tape 1005" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1005/" media_type: "Program" programmers: - name: "Tim Hartnell" slug: "tim-hartnell" taxonomy: "indiv" url: "http://localhost/indiv/tim-hartnell/" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/215_SpSt.png" media_type_tags: "Game, Resource Management" --- # Space Station Space Station is a turn-based resource management simulation in which the player governs a space station, balancing oxygen, food, and money across multiple years. Each turn the player trades artefacts for cash, purchases food and oxygen, and then endures random population growth, maintenance costs, and occasional alien or rogue-human attacks that deplete resources and colonists. The initialisation subroutine at line 3000 randomises starting values for population, cash, food, oxygen costs, and per-person needs, giving each playthrough different economic conditions. A random attack event (subroutine 7000), triggered with roughly a 1-in-5 chance each year, subtracts casualties, oxygen, food, and repair costs. The game ends with looping PRINT statements when any critical resource is exhausted or the population collapses. *** ## Program Analysis ### Program Structure The program is divided into several functional blocks: - **Lines 0–50:** Setup, initialisation call, and year-loop entry point. - **Lines 50–700:** Status report subroutine, including warning checks, resource display, and a decorative block-graphics line (lines 610–650). - **Lines 710–2050:** Main game turn — artefact trading, food purchase, oxygen purchase, event roll, resource accounting, and loop-back. - **Lines 3010–3115:** Initialisation subroutine — randomises all starting parameters. - **Lines 7010–7100:** Attack event subroutine — describes attackers, computes casualties and damage. - **Lines 8010–8560:** Termination handlers for each losing condition (oxygen, food, cash, population). ### Initialisation and Randomisation The subroutine starting at line 3010 (called via `GOSUB 3000` — targeting a non-existent line, so execution falls through to 3010) randomises every economic parameter. Notable expressions include: - `CASH=7*(700+INT(RND*800+1))/INT(RND*3+1)` — divides by 1, 2, or 3, producing a wide cash range. - `OXY=2000-INT(RND*1500)+1` — oxygen can start as low as ~502 units, creating immediately tight starts. - `ARTPAY=30*INT(RND*ARTCOST)+1` — artefact pay scales with artefact cost but can be as low as 1 if `RND` rounds to 0. ### Population Growth Formula Line 30 computes annual population change: `FOLK=INT FOLK+FOLK/INT(((RND*18)+1)+2)-FOLK/INT(((RND*15)+1)+3)` This adds a birth fraction (population divided by a random integer 3–20) and subtracts a death fraction (population divided by a random integer 4–18). Because birth and death divisors overlap in range, population can grow, shrink, or stay stable each year in a biologically plausible but unpredictable way. ### Main Turn Loop The turn sequence follows this order each year: 1. Increment `YEAR` (line 20). 2. Compute population change (line 30). 3. Display status and process player inputs for artefacts, food, and oxygen (lines 710–880). 4. Roll for attack event — `IF INT(RND*5)+1=2 THEN GOSUB 7000` — approximately 20% chance (line 900). 5. Deduct food consumption, maintenance, oxygen purchase cost, and net oxygen (lines 2005–2040). 6. `GOTO 20` to restart the year cycle. ### Resource Accounting Anomaly Line 805 reads `LET FOOD=FOOD+C*FOODCOST` when it should logically read `FOOD=FOOD+C`. Multiplying units purchased by cost per unit and adding that to food stock means buying food inflates food stocks proportionally to price rather than quantity — a clear bug. The player pays correctly (line 810 subtracts `C*FOODCOST` from cash) but receives far more food units than intended when `FOODCOST` is greater than 1. ### Attack Subroutine Subroutine 7000 picks one of six named attacker types (lines 7014–7019), then computes: - `Z=1+(FOLK/INT(RND*15+1)+1)` — casualties as a function of population (line 7030). - `ZZ` — cash damage, £251–500 (line 7050). - `ZZZ` — oxygen loss, 1–300 units (line 7065). - `ZZZZ=INT(RND*300*1)` — food loss, 0–299 units (line 7066). The multiplication by 1 is redundant. Note that line 7066 uses `*1` instead of `+1`, so food loss can be 0 (unlike the other damage values which use `+1` to guarantee a minimum of 1). ### Losing Conditions and Terminal Loops Each game-over handler (lines 8010, 8100, 8200, 8500) prints a message and then loops forever with a `GOTO` back to its own `PRINT` statement, producing a repeating display. This is a common idiom for terminal game-over screens. The string `A$="THE STATION IS DEAD"` is set at line 3015 and prepended to every death message. ### Low Population Path Lines 97–100 handle near-extinction. If population drops below 2, the player is offered three choices at line 8310: instant death, a lingering death (which simply returns to the game loop via `GOTO 20`), or waiting for new colonists. The colonist option (line 8386) uses a 1-in-5 chance (`NC=INT(5*RND)+1`): only if `NC=1` are population and cash boosted. The `CTR` counter (line 8391) tracks how many times this path has been taken; line 98 checks `CTR=1` to trigger extinction on a second consecutive near-zero population. ### Decorative Block Graphics Lines 610–650 (inside the status subroutine) print a full row of 32 identical characters chosen randomly from the block-graphics range (CHR$ 128–159 plus a few extra, since `INT(RND*11)+1+128` yields 129–139). This provides a simple visual separator between status screens. ### Key Variables | Variable | Meaning | | --- | --- | | `FOLK` | Current population | | `CASH` | Treasury balance | | `OXY` | Oxygen units in stock | | `FOOD` | Food units in stock | | `OXYNEED` | Oxygen consumed per person per year | | `FOODNEED` | Food consumed per person per year | | `OXYCOST` | Cost per oxygen unit | | `FOODCOST` | Cost per food unit | | `ARTCOST` | Oxygen used per artefact produced | | `ARTPAY` | Cash earned per artefact traded | | `REPAIR` | Annual maintenance charge | | `YEAR` | Current simulation year | | `CTR` | Count of near-extinction events | ## Source Code ``` 0 REM "SPACE STATION" TIM HARTNELL 2 FAST 3 RAND 4 CLS 5 LET CTR=0 10 GOSUB 3000 20 LET YEAR=YEAR+1 30 LET FOLK=INT FOLK+FOLK/INT (((RND*18)+1)+2)-FOLK/INT (((RND*15)+1)+3) 40 GOTO 710 50 PRINT "COMPUTER REPORT:" 60 PRINT 70 IF OXYOXY THEN PRINT "NOT ENOUGH OXYGEN" 740 IF B*ARTCOST>OXY THEN GOTO 720 745 LET CASH=CASH+B*ARTPAY 750 LET OXY=OXY-B*ARTCOST 755 CLS 760 GOSUB 50 762 PRINT "FOOD COSTS £";FOODCOST;" PER UNIT" 763 PRINT "EACH PERSON NEEDS ";FOODNEED;" UNITS" 764 PRINT "(£";FOODCOST*FOODNEED;" EACH, £";(INT (FOLK*FOODCOST*FOODNEED)*10)/10;" FOR STATION)" 766 PRINT "THIS WILL LAST ";(INT (FOOD/(FOODNEED*FOLK)*10)/10);" YEARS AT THE PRESENT POPULATION" 770 PRINT "HOW MUCH FOOD WILL YOU BUY?" 780 INPUT C 790 IF C*FOODCOST>CASH THEN PRINT "NOT ENOUGH MONEY" 800 IF C*FOODCOST>CASH THEN GOTO 780 805 LET FOOD=FOOD+C*FOODCOST 810 LET CASH=CASH-C*FOODCOST 820 CLS 830 GOSUB 50 850 PRINT "HOW MUCH OXYGEN WILL YOU BUY?" 855 PRINT "(CURRENT STOCKS WILL LAST FOR ";(INT (OXY/(OXYNEED*FOLK)*10)/10);" YEARS AT THE PRESENT POPULATION)" 860 INPUT D 870 IF D*OXYCOST>CASH THEN PRINT "NOT ENOUGH MONEY" 880 IF D*OXYCOST>CASH THEN GOTO 860 890 CLS 900 IF INT (RND*5)+1=2 THEN GOSUB 7000 2005 LET FOOD=FOOD-FOLK*FOODNEED 2030 LET CASH=CASH-REPAIR-D*OXYCOST 2040 LET OXY=OXY+D-FOLK*OXYNEED 2050 GOTO 20 3010 LET YEAR=0 3015 LET A$="THE STATION IS DEAD" 3020 LET FOLK=INT (80+INT (RND*40)+1) 3030 LET CASH=7*(700+INT (RND*800+1))/INT (RND*3+1) 3040 LET FOODCOST=INT (RND*7+1) 3050 LET ARTCOST=1+INT (RND*3)+1 3055 LET FOOD=2000+INT (RND*500)+1 3060 LET OXY=2000-INT (RND*1500)+1 3070 LET OXYCOST=INT (RND*7)+1 3080 LET ARTPAY=30*INT (RND*ARTCOST)+1 3090 LET REPAIR=200+INT (RND*400+1) 3100 LET FOODNEED=1+INT (RND*5+1) 3105 LET OXYNEED=2+INT (RND*3+1) 3115 RETURN 7010 CLS 7012 LET J=INT (RND*6+1) 7013 PRINT "THE STATION WAS ATTACKED BY" 7014 IF J=1 THEN PRINT "A FLEET OF SYRIAN SHIPS" 7015 IF J=2 THEN PRINT "RENEGADE EARTHLINGS" 7016 IF J=3 THEN PRINT "MARTIAN SPACE PILOTS" 7017 IF J=4 THEN PRINT "VYRILLIEX OUTWORLDERS" 7018 IF J=5 THEN PRINT "A LONE SHIP, APPARENTLY UNDER",,"ROBOT CONTROL" 7019 IF J=6 THEN PRINT "A PARRALEXIAN ESCORT VESSEL" 7020 PRINT 7025 PRINT 7027 PRINT 7030 LET Z=1+(FOLK/INT (RND*15+1)+1) 7040 PRINT "THERE WERE ";INT Z;" PEOPLE KILLED" 7045 PRINT 7050 LET ZZ=250+INT (RND*250+1) 7060 PRINT "DAMAGE WAS £";ZZ 7062 PRINT 7065 LET ZZZ=INT (RND*300+1) 7066 LET ZZZZ=INT (RND*300*1) 7067 PRINT "AND FOOD STOCKS HAVE FALLEN",,"BY ";ZZZZ 7069 LET FOOD=FOOD-ZZZZ 7070 LET FOLK=FOLK-Z 7075 LET OXY=OXY-ZZZ 7080 LET CASH=CASH-ZZ 7085 PRINT 7090 PRINT ,,"PRESS " 7092 INPUT U$ 7095 CLS 7100 RETURN 8010 PRINT A$ 8020 PRINT "YOU RAN OUT OF OXYGEN IN YEAR ";YEAR 8040 GOTO 8020 8100 PRINT A$ 8110 PRINT "FOOD SUPPLIES WERE EXHAUSTED IN YEAR ";YEAR 8120 GOTO 8100 8200 PRINT A$ 8210 PRINT "THE TREASURY RAN DRY IN YEAR ";YEAR 8220 GOTO 8210 8310 PRINT "YOUR POPULATION HAS FALLEN" 8320 PRINT "TO ";INT (FOLK);". DO YOU WANT TO" 8330 PRINT "COMMIT SUICIDE PAINLESSLY" 8340 PRINT "NOW (1), AWAIT A SAD AND" 8350 PRINT "LINGERING DEATH (2), OR" 8355 PRINT "WAIT AND HOPE FOR NEW COLONISTS" 8356 PRINT "(3)?" 8360 INPUT B 8365 CLS 8366 PRINT "I HOPE YOU HAVE CHOSEN WELL" 8367 FOR H=1 TO 50 8368 NEXT H 8370 IF B=1 THEN GOTO 8400 8384 IF B=2 THEN GOTO 8395 8386 IF B=3 THEN LET NC=INT (5*RND)+1 8387 IF NC=1 THEN LET FOLK=FOLK+INT (RND*26+1) 8388 IF NC=1 THEN LET CASH=CASH+INT (RND*300+1) 8389 IF NC>1 THEN GOTO 8390 8391 LET CTR=CTR+1 8395 GOTO 20 8400 PRINT A$ 8401 PRINT "YOU MADE IT TO YEAR ";YEAR+1 8402 PRINT "GOODBYE" 8410 GOTO 8402 8500 PRINT A$ 8510 PRINT "ALL COLONISTS HAVE DIED" 8520 PRINT "YOU MADE IT TO YEAR ";YEAR+1 8530 GOTO 8402 8550 STOP 8560 REM RAND USR 14336 8570 REM SAVE "SPASTA.B1" 8575 SAVE "1021%5" 8580 RUN ```