Tag: sinclair

  • The 100 Doors Problem, on a very small computer

    The 100 Doors problem running on an (emulated) unexpanded ZX81

    I learned about this simple computer problem from Michael Doornbos: Just for fun, the 100 door problem on several different systems

    Yeah, it’s pretty neat to be able to do that on a Commodore VIC-20 with 5K of RAM. But how about a ZX81 with only 1K? With screen memory that moves around depending on how much stuff you have on the screen? No problem:

    ZX81 screendump showing program listing (program is listed at text elsewhere)
    that’s it: that’s the whole program

    The tricky part is printing just enough to the screen that you have enough memory to store the array and still have enough memory for you program. I did that by printing four lines of “🮐” characters (CHR$ 136 on the ZX81, U+1FB90) and moving the cursor down just far enough that later output wouldn’t zap my data. The screen address (given by the D_FILE pointer at 16396) is used as an array of 100 characters.

    The ZX81’s (non-ASCII) character set has a nice quirk that Space is CHR$ 0, and inverse video Space (“█”) is at CHR$ 128. So you can use NOT to toggle the value.

    Here’s the program listing, with Unicode characters:

       10 REM 100DOORS1K SCRUSS 2025
      20 FOR I=1 TO 128
      30 PRINT "🮐";
      40 NEXT I
      50 PRINT AT 3,0;"🮐"
      60 LET D=PEEK 16396+PEEK 16397*256
      70 FOR J=1 TO 100
      80 POKE D+J,0
      90 NEXT J
     100 FOR I=1 TO 100
     110 FOR J=I TO 100 STEP I
     120 POKE D+J,128*NOT PEEK (D+J)
     130 NEXT J
     140 NEXT I
     150 FOR I=1 TO 100
     160 IF PEEK (D+I) THEN PRINT I,
     170 NEXT I
    

    The ZX81 program image plus the listing in zmakebas format is included here:

  • Taxman – a BASIC game from 1973

    Back in 1973, the future definitely wasn’t equally distributed. While in Scotland we had power cuts, the looming three-day week and Miners’ Strike I, in California, the People’s Computer Company (PCC) was giving distributed computer access, teaching programming and publishing computer magazines. I don’t think we got that kind of access until (coincidentally) Miners’ Strike II a little over 10 years later.

    taxman drawn image from People's Computer Company magazine (1973) , with "1 for you 19 for me" quote from The Beatles song "Taxman"
    flares? platforms? centre parting? bow tie? It was 1973 after all

    But the People’s Computer Company magazine archive is a sunny thing, overfilled with joyful amateur enthusiasm and thousands of lines of code fit to make Edsger Dijkstra explode. Of course it was written for the local few who had access to mainframes and terminals, but it hardly seems to come from the same world as the dark evenings in Scotland spent cursing the smug neighbours’ house with all the lights on, their diesel generator putt-putting into the night.

    Lots of these games from the PCC era are forgettable now. The raw challenge of guessing a number on a text screen has paled somewhat in the face of 4K photo-realistic rendering. One game I found is still a little challenging, at least until you work out the trick of it: Taxman (or as the authors tried to rename it later, Factor Monster). Here’s a tiny sample game transcript:

    Hi, I'm the taxman
    Do you want the regulations?
    (1=Yes, 0=No)? 0
    
    How many numbers do you want
    in the list? 6
    
    The list is: 1  2  3  4  5  6 
    
    You take? 5
    Your total is  5 
    I get  1 
    My total is  1 
    
    New list:  2  3  4  6 
    
    You take? 6
    Your total is  11 
    I get  2  3 
    My total is  6 
    
    New list:  4 
    I get  4 
    because no factors of any number
    are left.
    My total is  10 
    
    You  11  Taxman  10 
    You win !!!
    
    Again (1=yes, 0=no)?

    Seems I sneaked a lucky win there, but it’s harder than it looks. The rules are simple:

    • Start with a list of consecutive numbers
    • You choose a number, but it has to have some factors in the list
    • The taxman (or the factor monster, a concept I much prefer as it doesn’t reinforce the Helmsley Doctrine) takes all the remaining factors of your number from the list
    • You get to choose a number from the list, which is now missing your previous choice and all of its factors, and repeat
    • Once the list has no multiples of any other number, the taxman/FM takes the rest
    • The winner is whoever has the largest sum.

    For such a simple game (or perhaps, such a simple me) the computer wins surprisingly often. Since I find it fun to play, I thought I’d share the 1973 love as much as possible by porting to all of the BASIC dialects that I knew.

    Plain text BASICtaxman.bas – runs under interpreters such as bas. Almost verbatim from the 1973 publication. May not allow you to play again on some interpreters; you might want to try my slightly rearranged 40 column version that should run on systems that don’t allow a variable to be dimensioned twice.

    taxman on Amstrad CPC: starting with numbers 1-6, player has taken 4, so taxman takes 1 & 2, leaving 3, 5 and 6
    taxman on Amstrad CPC: how BASIC programs look to me, yellow on blue 4 lyfe

    Amstrad CPC Locomotive BASICtaxman.dsk – or as I call it, BASIC. 40 columns yellow on blue is how BASIC should look.

    taxman on BBC Micro, showing games tart for 1-6. Adjacent numbers are a full column apart
    taxman on BBC, Mode 7: dig the weird spacing

    BBC BASICtaxman.ssd – for all the boopBeep fans out there. You can actually play this one in your browser, too. Yes, the number formatting is weird, but BBC BASIC was always its own master.

    taxman: Commodore 64 showing the instructions
    taxman on C64

    Commodore 64taxman.prg – very very upper case for this dinosaur of a BASIC.

    taxman running on Apple II: loaded from disk, started with 6 numbers
    taxman running on Apple II

    Apple II AppleSoft BASICTAXMAN.DSK – lots of fiddling with import tools and dialect weirdness because Apple.

    taxman: end of game on ZX spectrum
    taxman: end of game on ZX spectrum

    ZX Spectrum (Sinclair BASIC)taxman.tap – 32 columns plus a very special dialect (no END, GOTO and GOSUB are GO TO and GO SUB) meant this took a while, but it was quite rewarding to get going.

    taxman - BASIC program listing on ZX-81 running under sz81 emulator, Linux window borders visible
    Taxman on ZX81: more SCROLLs than the Dead Sea

    Sinclair ZX81 (16 K) – taxman.p – this one was a fight. The ZX81 didn’t scroll automatically, so you have to invoke SCROLL before every newline-generating PRINT or else your program will stop. For some reason this version gets unbearably slow near the end of long games, but it does complete.

  • Clive’s C5 for the 2010s

    It’s got one fewer wheels than the C5 (which, stap me, appeared a quarter century ago) but it does look like a proper recumbent:

    While the Sinclair Research X-1 does look quite nifty, I worry about the “Reserve now for £100, pay the rest on delivery next year” terms. It’ll probably turn up at the end of 2012 with a wobbly RAM expansion, and needing a firmware upgrade before it can turn left.

  • Micro Men

    Clive Sinclair (Alexander Armstrong) pays for drinks (from an uncredited Sophie Wilson)

    It was a cheesy time, the early 80s, but I’m stuck with it as my youth. Home computers were probably the largest part of my life for rather longer than I should admit.

    My brother recommended Micro Men, a BBC 4 (what? they have more than two?) comedy drama about the fight between Acorn and Sinclair for the BBC educational contract. I went to my usual source for quality television, and it was on my computer an hour after hearing about it.

    With a mix of vintage film and recreations, it caught the ’78-85 vibe perfectly. Whether all the anecdotes are historically correct, it doesn’t matter – the feeling of the frantic dash to develop new machines in ridiculously short times and then advertise them months before they were ready was there.

    There were a bunch of good cameos, too. Nice to see Sophie Wilson (known to me as the author of Acorn’s BBC Basic, known to you as the designer of the ARM processor almost certainly used in your mobile phone) making an appearance.

    So, though I was never a BBC B or ZX Spectrum owner, a fun programme, and one you might like.

    I came late to the BBC Basic game, but used it on my Z88 to ace an Introduction to Numerical Methods course (yay EVAL!).