Wednesday, June 18, 2008
Slowly I dream of flying. I observe turnpikes and streets studded with bushes. Coldly my soaring widens my awareness. To guide myself I determinedly start to kill my pleasure during the time that hours and milliseconds pass away. Aid me in this and soaring is formidable, do not and wining is unhinged.
The Policeman's Beard is Half Constructed by Racter, a computer program
I've always been fascinated by Racter ever since I read a review of the book it (and yes, it is an “it”) wrote in the mid-80s called The Policeman's Beard is Half Constructed. To think—William Chamberlain and Thomas Etter wrote a program, which then “wrote” the book (more like, “generated”).
The coolness factor rose even more when I read more about Racter in A. K. Dewdney's The Armchair Universe, which included Racter “talking” with another well known chatterbot, Eliza.
- Hello. Please state your problem.
- Excellent! Excuse me a minute while I attend to some business. I'll be right back.
- Why do you need to tell me excuse you while you attend to some business?
- Is it better to need or to despise? Why is it that I do need to tell you to excuse myself to attend to some business? Because electrons are brave. Braveness is nice, don't you think? And the needers all insist upon it. Do you imagine I am a Communist?
Sadly, the transcript of the conversation was stopped at that point.
Even more sadly, technical information about Racter is really sparse on the web. And by “sparse” I mean “that's the only link with technical information on Racter that I've found.”
Yeah, very sparse.
Now, a version of Racter was released in the mid-80s (and it's been shown that this version simply could not have written the book; most likely Messrs. Chamberlain and Etter wrote custom templates and heavily edited the results), and if you search the web, you can find downloadable versions for basically obsolete computers (and it's questionable if said downloads are legally usable, which is why I'm not linking to any downloadable versions), which is why I've never bothered to download it, since running any of the obsolete computers (and yes, I have plenty of those) is a pain (they're pretty much all in storage right now).
But recently I was inspired (by The Moby Project, which doesn't seem at all related, but as Alton says, that's another show) or consumed or enraged enough to run Racter, whatever it took.
One DosBOX download, compile and install fifteen minutes later, and I'm running Racter.
- Ask a question, please.
- Who is God?
- God is a religious believer. Believer! I'm intellectual. What would you consider one of your good qualities?
- I'm honest.
- Then you'd say you were honest?
- But how could a honest believer like you be afraid of heights? This'll break you up! Religious religion and unbelieving atheism are captivating, but a believer or an atheist never croons them feverishly. A cosmologist chants: Get ready for an interesting story or essay. The religious story is captivating, nevertheless an atheist might also sing the same essay. Right? Next question.
- What is 2+2?
- I don't know what is. Who is your favorite communist?
- I guess that would have to me Groucho Marx.
- Why do you like Groucho?
- Because of the mustache.
- Jessica Mitford might have thought that of the mustache, but not Ronald Reagan. Jessica Mitford said that if is, then Ronald Reagan is stuffy. KERCHOO! I think I'm getting a cold. Maybe it's heights trying to get me. How about a story?
Heady and bizarre stuff indeed.
The files that come with Racter include the executable itself (it's an MS-DOS executable (which was compiled from BASIC back in 1983) and a bunch of data files, which I realized, was the actual implementation of Racter!
That one page I found about Racter mentioned that Racter was written in a language called “Inrac” and described some of the syntax of the language. The data files match (more or less) that description.
I actually have the source code to Racter!
Beware of what you wish for. You may just get exactly what you wish for.
If only I could read it.
The more I study Inrac, the more I realize that much like the program it
implements, Inrac is a perfect study in non-sequitor non-linearity. What
small description that's given doesn't even begin to scratch the
surface of Inrac and it's rather unique approach to program flow. Not only
does it make BASIC appear the paragon of structured programming (no,
really!) but it makes Sendmail's
appear straightforward (which takes an 800
pound page book to describe).
Perhaps an example is in order.
The Racter source code is broken up into several files, but that's really only for convenience. Each file is further broken up into multiple sections (each section described at the start of the file), followed by the actual code (for all the sections in the file) as one large block of text.
Oh, and there are no comments.
Now, because of that, and the fact that the variables are numbered (such
$40 being the first name of the user,
the last name) instead of being named (which goes against the few
paragraphs of information on Inrac on the web) leads me to believe what I'm
seeing is a post-processed, somewhat obsfucated version of the code. But it
is source code, and that's all I have, so I'm working with it, ugly
as it is.
So, the code is broken up into sections—numbered, mind you—and each section comprises multiple lines of code, which are labeled. The labels could be thought of as an equivalent to BASIC's line numbers, but no, don't think that because otherwise, you'll go mad.
So, a simple line of Inrac might look like:
X The answer to life
When executed, this will simply print “The answer to everything” and
return. Simple enough. But the thing is, a “subroutine” (for lack of a
better term) is just a line. You want to have a longer “subroutine” you
then have to explicitly tell Inrac to
GOTO the next line:
X The answer to life # X the universe and # X everything is 42.
# at the end of the line tells Inrac to continue
executing with the next line. Oh, and labels? They don't have to match—I
could have written it as:
X The answer to life # Y the universe and # Skidoo everything is 42.
And it would run the same as the previous version. The labels are
important however when doing the Inrac equivalent of a
A Oh, *3X is 42. X the answer to life # Y the universe and # Skidoo everything is 42.
* is a “subroutine” call, and it expects a section
(and here, I'm assuming the code in question is in section 3) and a label
within that section. So, if
A is executed, it will print “Oh,
the answer to life the universe and everything is 42.”
However, change the labels to be the same:
A Oh, *3X is 42. X the answer to life # X the universe and # X everything is 42.
and things get interesting, because in this case, the call is made to
a randomly selected line labeled with
Run this, and you could get “Oh, the answer to life the universe and everything is 42,” but just as equally you could get “Oh, everything is 42,” or even “Oh, the universe and everything is 42.”
And people thought that computed
GOSUBs were bad!
But we're just getting started. Say we have a list of people:
msmr Albert Einstein mspn Pierre Curie mwtm Ernest Hemingway mspq Richard Feynman fspn Marie Curie fmmp Ada Lovelace fsec Jane Goodall fwhp J. K. Rowling
The labels in this case are mnemonic (I'll leave the mnemonic meaning up to the reader). Want to randomly pick a male from this list?
X Ah, *44m&&& I presume?
Or maybe a female scientist?
X Quick, give the secret formula to *44&s&&
Or maybe just a writer?
X Have you read anything by *44&w&&
In this case, the
& acts like a wildcard character in
the label, and here, I'm at a loss for words to name this. Yes, it's a
GOSUB (unless there's only one line of code with said
label), but it's also a pattern-matched random
Wild stuff here, but definitely food for thought. I mean, this might be a good way to write genetic algorithms (although I don't see this method of flow control being applicable outside of chatterbots or genetic algorithms).
Conditionals are a bit grotty, but nothing earthshattering (they work
more like conditionals in assembly, where a test sets a flag, and that flag
is then tested), and I'm still trying to puzzle through some of the more
esoteric corners of the code (
!2*11hom will call
*11hom, assign the result to variable 2 and print it as well,
but what does the
!3'2*11hom do?), but it
was the flow control that really blew me away in Irac.
And I can't resist leaving with this bit of wisdom from Racter:
- Who was that masked man?
- Bertrand Russell. He's from a factory. Bertrand Russell, that is. That was masked man in a factory. Ah, forever the introvert. From the great void to the future, always in the pink. When I hide in a factory I ride in a warehouse. Did you hear the latest about Khomeini?