--- title: "Horserace" id: 70795 type: "computer_media" slug: "horserace" url: "http://localhost/computer_media/horserace/" markdown_url: "http://localhost/computer_media/horserace.md" published_at: "2026-08-23T15:08:10+00:00" modified_at: "2026-08-23T17:58:51+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "Place your bets on six horses with randomly assigned odds, watch them race across the screen, and see if your punter's bankroll survives the meeting." 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 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Paul Stanley" slug: "paul-stanley" taxonomy: "indiv" url: "http://localhost/indiv/paul-stanley/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_type: "Program" programmers: - name: "Paul Stanley" slug: "paul-stanley" taxonomy: "indiv" url: "http://localhost/indiv/paul-stanley/" download_url: "https://archive.org/download/timex-sinclair-software-archive/Horserace%20%28198x%29%28Stanley%2C%20Paul%29%28TS2068%29%28UK%29%28Program%29.zip" tsrun_member: "Horserace (198x)(Stanley, Paul)(TS2068)(UK)(Program).tap" mediadate: "198x" media_type_tags: "Game" --- # Horserace Horserace is a multi-player betting simulation in which one to several “punters” wager money on one of six horses across a configurable number of races. Each horse’s odds are randomly assigned as powers of two (1:1 through 32:1) using the expression `2↑(INT(RND*6))`, and the race itself is animated on screen with a UDG-defined horse character moving across the display. Advancement probability decreases as the odds improve, so higher-odds horses move more slowly on average. A photo-finish routine handles ties by randomly selecting a winner from up to four finishing horses, and players who run out of money can either be eliminated or receive a $50 bailout. *** ### Program Structure The program is organized into a main flow section and several subroutines accessed via `GO SUB` or direct `GO TO`. The high-level flow is: 1. Lines 1–10: Initialization, title screen (`GO SUB 7000`), and UDG setup (`GO SUB 9000`). 2. Lines 20–120: Per-race setup — draw the track, then call betting (`GO SUB 1999`) and race start (`GO SUB 1000`). 3. Lines 1000–1095: The race loop, finish detection, photo-finish logic, and winner announcement. 4. Lines 1100–1150: Per-punter payoff/loss accounting and feedback. 5. Lines 1999–2050: Betting input subroutine (also decrements the race counter). 6. Lines 6000–6040: End-of-meeting summary and restart. 7. Lines 7000–7020: Title screen display. 8. Lines 8000–8050: Bankruptcy handler — offer elimination or $50 bailout. 9. Lines 9000–9999: UDG definition via `READ`/`POKE` into `USR "a"`. ### UDG Horse Character Line `9000` defines UDG “A” by poking eight bytes read from a `DATA` statement into the address returned by `USR "a"`. The data includes both decimal and `BIN` literals, creating a small horse silhouette that is then printed throughout the race using `INK c` to color each horse distinctly. The UDG is referenced in the source as `[UDG-A]`. ### Odds and Movement Probability Each horse’s odds `f(c)` are assigned as `2↑(INT(RND*6))`, giving values from 1 to 32 in powers of two. The race movement logic on line `1005` uses a chain of Boolean expressions to advance a horse by one position per iteration based on its odds: | Odds value f(c) | Advance probability | | --- | --- | | 1 | 0.80 | | 2 | 0.77 | | 4 | 0.74 | | 8 | 0.71 | | 16 | 0.68 | | 32 | 0.65 | In Spectrum BASIC, boolean expressions evaluate to 1 (true) or 0 (false), so the sum of six boolean terms on line `1005` neatly selects exactly one probability branch based on `f(c)` while adding 0 for all non-matching terms. ### Skipping Bankrupt Punters Lines `1101`, `2031`, and `6015` use a compact but unusual idiom to skip over punters whose balance is zero. The pattern is: `IF p(r)=0 THEN LET r=r+1: GO TO (1101 AND rwinner THEN GO TO 1125 1120 CLS :PRINT AT 10,4;"Well done punter ";r;" !"'"Your horse won and you now have $";p(r):PAUSE 0:GO TO 1130 1125 CLS :PRINT AT 10,4;"Bad luck punter ";r;" !"'"Your horse did not win,and so you now have $";p(r):PAUSE 0 1130 NEXT r 1150 GO TO 20 1999 LET races=races-1:IF races=-1 THEN GO TO 6000 2000 DIM f(6):FOR c=1 TO 6:LET f(c)=2↑(INT (RND*6)):NEXT c 2020 PRINT "The tipsters reckon the betting:" 2025 FOR c=1 TO 6:PRINT INK c; PAPER (7 AND c<4)+(0 AND c>3); AT 2*c,2;"HORSE ";c;" ";f(c);":1" 2029 NEXT c 2030 DIM e(a):DIM b(a):FOR f=1 TO a 2031 IF p(f)=0 THEN LET f=f+1:GO TO (2031 AND fp(f) THEN GO TO 2033 2035 PRINT '"On which horse is this to placed?" 2036 INPUT e(f) 2037 IF e(f)<1 OR e(f)>6 THEN GO TO 2036 2038 PRINT AT 17,0;" " 2039 PRINT AT 19,0;" " 2040 NEXT f 2050 CLS :RETURN 6000 PRINT "THE MEETING IS NOW FINISHED" 6010 FOR f=1 TO a 6015 IF p(f)=0 THEN LET f=f+1:GO TO (6015 AND f