Blog

Scheme Record to RecordType

So, in "classic" Scheme (up to R5RS), there were no structs/records/classes. You could fake them with a Vector and writing all the accessor methods by hand, but it sucked.

SRFI-9 added a very minimalist record type with a lot of repetition, and no inheritance, though at least SRFI-17 fixed setters.

R6RS (as implemented in Chez Scheme) added a much more powerful system with inheritance and constructor methods, but half the Scheme community hates nice things and voted it down. There's a half-assed reimplementation of R6RS in SRFI-99 and sequels, but it still doesn't have read/write mechanisms. R7RS still only ships with SRFI-9 built in. Unbelievable mess.

Chicken has a convenient define-record macro, and read/write methods, but by default uses SRFI-9, and hides SRFI-99 in an egg; so chicken-install -s srfi-99 and then (import srfi-99) everywhere, and then write a ton of boilerplate for every type. So I just automated it with Python (doing string parsing in Scheme is more annoying):

Documentation is in the module help (or just read the source, Luke). I use it by writing the Chicken macro (define-record Point x y), then at shell:

% pbpaste|schemeRecordToRecordType.py|pbcopy

And paste back:

;; (define-record Point x y)
(define-record-type Point #t #t
    (x)
    (y)
)
(define-reader-ctor 'Point make-Point)
(define-record-printer (Point p out)
    (format out "#,(Point ~S ~S)"
        (Point-x p) (Point-y p) 
))
; module exports:
; make-Point Point? Point-x Point-y

Note that none of this really gets me an "object-oriented" system, but records are sufficient for most programs, and inheritance works with define-record-type. There are OOP systems but I don't especially like any of them so I'm passing on them for now.

The Infocom Implementor's Creed

THE IMPLEMENTOR’S CREED

I create fictional worlds. I create experiences.

I am exploring a new medium for telling stories.

My readers should become immersed in the story and forget where they are. They should forget about the keyboard and the screen, forget everything but the experience. My goal is to make the computer invisible.

I want as many people as possible to share these experiences. I want a broad range of fictional worlds, and a broad range of “reading levels.” I can categorize our past works and discover where the range needs filling in. I should also seek to expand the categories to reach every popular taste.

In each of my works, I share a vision with the reader. Only I know exactly what the vision is, so only I can make the final decisions about content and style. But I must seriously consider comments and suggestions from any source, in the hope that they will make the sharing better.

I know what an artist means by saying, “I hope I can finish this work before I ruin it.” Each work-in-progress reaches a point of diminishing returns, where any change is as likely to make it worse as to make it better. My goal is to nurture each work to that point. And to make my best estimate of when it will reach that point.

I can’t create quality work by myself. I rely on other implementors to help me both with technical wizardry and with overcoming the limitations of the medium. I rely on testers to tell me both how to communicate my vision better and where the rough edges of the work need polishing. I rely on marketeers and salespeople to help me share my vision with more readers. I rely on others to handle administrative details so I can concentrate on the vision.

None of my goals is easy. But all are worth hard work. Let no one doubt my dedication to my art.

—Stu Galley, Infocom

From a Moonmist retrospective.

Also, I loved his Seastalker — I was marginally older than the target audience, and sailed thru it fast, but it combined so many things I like, Tom Swift, Hardy Boys, underwater laboratories (SeaLab 2020 pre-Adult Swim, Man from Atlantis, Voyage to the Bottom of the Sea TV show, etc.), and tactical roguelike combat with the submarine. For years the sticker was permanently attached to my dresser mirror.

Infocom

Jason Scott of archive.org has just uploaded Infocom's source code, and keeps adding a bunch of other game source. I've made an easy script to get all the text adventures; if you want Quake or whatever, go grab that yourself. [updated 2019-04-19 for a few gold versions]

#!/bin/zsh
for repo in \
abyss \
amfv \
arthur \
ballyhoo \
beyondzork \
borderzone \
bureaucracy \
checkpoint \
colossalcaveadventure \
cutthroats \
deadline \
enchanter \
hitchhikersguide \
hollywoodhijinx \
infidel \
infocom-sampler \
journey \
leathergoddesses \
leathergoddesses-gold \
lurkinghorror \
minizork-1982 \
minizork-1987 \
minizork2-1988 \
moonmist \
nordandbert \
planetfall \
plunderedhearts \
restaurant \
seastalker \
sherlock \
shogun \
softporn \
sorcerer \
spellbreaker \
starcross \
stationfall \
suspect \
suspended \
trinity \
txtelite \
wishbringer \
witness \
zork \
zork-german \
zork1 \
zork2 \
zork3 \
zorkzero \
zork-fortran \
zork-mdl \
zork-1 \
hitchhikersguide-gold \
zork1-gold \
planetfall-gold \
wishbringer-gold \
; do
echo $repo
git clone https://github.com/historicalsource/$repo.git
done

The ZIL (Z-Machine Implementation Language) code is not too weird a LISP variant, and I expect there to be good compilers or translators to modern Scheme pretty soon; if necessary I'll write one. Many of the others are written in, preposterously, FORTRAN or C, easily two of the worst possible languages to do text-manipulation and abstract data structures in.

Zarf's post mentions a working ZIL compiler, ZILF.

You may also like Infocom: The Documentary and The Infocom Cabinet

As a large database of high-quality, production game source, this is a treasure trove for anyone who makes games. Read these and figure out how to do what they did.

I'm also amused by the icon, The Source came and went from the online services world just as I was getting into BBSing. I had as I recall a free couple months so I didn't have to pay the signup fee, but it was stupidly expensive per hour (Source was maybe $10/hour? Delphi was $20 for 20 hours per month, and not much more for overtime), and then shut down soon after.

All the Streaming Video

In which I compare some of the thousands of streaming media services:

  • Netflix: $13/mo for adult content: Love, Death & Robots, Bordertown, dozens of other crime dramas, adult comedies, and a huge backlog of content. In anime they have a bunch of current series, the Godzilla anime, classic Robotech (goddamn I still hate Minmei), and this summer they're replaying Neon Genesis Evangelion. Best video player of any streaming service. One caveat is that because Apple won't guarantee secure HDMI out on Airplay devices anymore, Netflix took down their Airplay support; I watch on a PS3 or desktop in Chrome, so this doesn't affect me, but some people will have to change how they watch it.
  • Amazon: $120/year for adult content: Bosch, The Tick, The Man in the High Castle, The Americans, and a huge backlog of (mostly shitty) movies for free. Second-worst video player I've ever seen, I scream obscenities at Amazon every time I watch something distractedly and want to go back 1 minute. I can't quit, anyway, I rely on Prime too much.
  • Disney+ (November): $7/mo for kids shows, mostly Marvel, Star Wars, Disney/Pixar (Dixar), and 512 seasons of the fucking Simpsons, which hasn't been funny since it left Tracey Ullman's Show. Not much new content, almost nothing for adults to watch.
  • Apple+: Unknown date & pricing. G-rated, mostly mainstream garbage content from what we've seen. Steven Spielberg should just find a rest home in Florida, he won't live long enough for the flooding to be a problem. If Apple makes it free with Apple Music, I'll take a look and mock the shows, but I expect nothing of interest to an adult.
  • CBS All Access: $10/mo for STD, er, Star Trek Discovery, and a lot of mainstream garbage content.
  • Twitch: "Free" with a shitload of ads; not just games, there are several networks streaming content, like Carl Sagan's Cosmos, ShoutFactory playing MST3K, The Prisoner, classic (good) Dr Who, Thunderbirds Are Go, and more. I would happily pay Twitch to get rid of ads.
  • Crunchyroll: $8/mo for currently-streaming anime. Second-best video player and queue manager. Really no longer a high value compared to Netflix and Amazon's anime selections, but sometimes there's new stuff you can only reasonably get on Crunchy. Partnered with/part of VRV, which has a bunch of other nerd media services, but the VRV player is the worst thing I've ever seen, really unusable, and the VRV staff are jackasses.
  • Funimation: Just like Crunchyroll but less current (usually; sometimes they have first-run and I have to sub for a month), and mediocre video player.
  • Hulu: $12/mo for "no ads" which has quite a lot of ads before and after shows, but at least doesn't have them in the show. Moderately shitty video player. Very poor new content, lots of old TV shows; Rockford Files was great but it's not worth $12/mo.
  • HBO Now: $15/mo. Usually has 2 current new shows at any time, a moderate amount of older shows and (often good) movies. Only really valuable for brief binges, then disable it; you'd quickly run out of content if you kept it subscribed. Ought to be half the price.
  • Criterion: $11/mo or $100/year. I haven't tried this yet, but I really should, they have dozens of old samurai movies and thrillers, which alone would pay for it. Their new content is very very limited, since good movies mostly stopped being made in the 1990s. There's a "channel" there of Guillermo del Toro talking about classic movies and then you watch the movie! OK, this is next month's media activity for me.
  • Youtube: Did you know Youtube had original content and a paid service? Well, they do, but nobody uses it.

Given this, if you're over 18, you should have Netflix and Amazon, and bang Criterion and HBO Now on the side once in a while. If you like old nerd media and current game streaming, watch Twitch. If you have kids, Disney+ and Crunchyroll are great deals. There's very narrow interest areas for the others.

On top of which, I check out iTunes Movies every month for their deals; never pay full price. This month I got Lawnmower Man (director's cut!), The Crow, and Equilibrium for under $8 each, all of which I can rewatch endlessly in actual HD, better than any streaming service.

Keep on Rockin' in Wednesday Music

Lost Treasure

In 1979, I learned to program in BASIC on a TRS-80 Model I. Sometime in the next year, I read one of my first programming books:

I played Monster Chase and Lost Treasure, modified them extensively, and combined them, so the cave on the island had a monster chase to reach the exit. I recall having problems getting Starship Alpha and Devil's Dungeon to work, but they joined my software library eventually.

One of my earliest and happiest programming memories was sitting at the dining room table, reading Monster Chase, and writing out a smarter movement system and obstacles in a notebook; at the time the only computers were at school, so I wrote code on paper and typed them in later.

So when I found the book again on archive.org last night, I was very excited, and had to reimplement it. I actually typed this into Pythonista on my phone with the PDF open on an iPad, only moved it to the computer to do some final cleanup and upload it.

The book suggests some modifications, and I did some minor ones: Lowered the movement error to 10%, and risk of shark attack to 10%, rising by 1.5x rather than a flat +50% each time; being anywhere near the island edge killed you too often in the original. I also don't move you out of the water automatically, that should cost a turn.

I realized in converting it that I hate, hate, hate Row,Column coordinates instead of Cartesian X,Y; tons of mainframe-era computing resources used Row,Column, and you can still see it in some APIs like Curses. Note that the original program is 74 lines, mine's 214; BASIC is a terrible language, but it's terse.

I could adapt this into another doorgame for my Mystic Dungeon BBS, but I'm not sure what the multiplayer aspect would be, and it has limited replayability without doing some randomization.