The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Monday, November 16, 2015

The Psychotherapy of Racter, or The Descent Into Madness of Sean Conner

When last I left off, I had a more-or-less working Eliza and therefore, I need to turn my attention to Racter.

This is not as easy as it may appear. The version I have is for MS-DOS, which is okay as I can emulate that. But harder is redirecting Eliza's output through the MS-DOS emulator to Racter and redirecting Racter's output from the MS-DOS emulator back to Eliza. And that's key to getting this whole thing working.

The program I'm using is DOSBox. I thought I could try redirection, something along the lines of dosbox <input to see if would work and … nope. It looks like I'll have to dig into the source code to DOSBox, intercept keyboard input and video output and kludge something in to get Eliza and Racter “talking.”

Okay … the source is C++ callback hell, what about doing a native compile of the Racter source code?

IV.IF Interview with INRAC IBM 6-4-85  initial transient file
 1 
 2 
 52 
SECTION 1 hello
 5 
 34 
SECTION 2 sue
 5 
 18 
A :LOADIV :OUTRACTER >2= >3= ?51= />51=Smith #
XA Hello, I'm Racter. ?40= \# You are? ?? #*1B
X Are you $40 ? ?? #
X ?no,not \# >1=R ?i'm,am,is /# Who are you then? ?? :F=0 #
X ?yes \# ?-:but /# >1=R #*1B
X \# You are $40 $51 ? ?? ?yes /#*2SAME ?i'm,is /# #*1XC
B  ?i \# >1=R ?don't,won't \# *1COY ?? #*1B
X  ?a,an,the \?called \?am,i'm,is,me,as,it's \# :F+1 >2=F ?-:2= #
X  /# ?CAP \# >2=F :F+1 >4=F ?4= \#*1XB #*1DO
X  /# *1DUH ??  #*1B
XB  ?CAP+1 />3=F #
X  >1=2 ?CAP \>2=C,2 #
C *1Xcall $2 , then? ?? ?no,not,Q /?-:why /# #*1DO
X >1=R ?CAP \# #*1B
XC What's your name then? :F=0 ?? #*1B
Xcall I may call you
Xcall You are
Xcall Your name is
DO Hello, $2 . I believe you're interviewing me. #
X ?2=40 \#  >40=40,51 #
X ?40= /# Are you continuing $40 <'s interview? #
X /# ??  ?no,not,don't /# #*2DIF
X ?40= /# Then we'll forget about $40 and start over. #
X :ZAP :PUTIV #
EXIT >40=2 ?3= \>51=3 What would you like to know? #*2GO
COY Come on, what's your name?
COY You must have a name - what is it?
COY Your name, please .
COY I have to call you something - what shall it be?
DUH I didn't get that . *1WHO
DUH I don't understand . *1WHO
DUH Eh? *1COY
WHO Who ?
WHO Who are you ?
DIFA Well, $2 , $40 and I >4=40 >40=2 ?3= \>51=3 #*2A 
SAME Hi, $40 . >4=You ?52= /# How are things in $52 ? #
x We #
A  ?20= />20=various,things #
x were talking about $20 last time. #
x  ?10=VERBQ \?10= />3=whether \>3=10 #
x $4 had just asked D $3 $19 . #
CONT Shall we continue? ?? ?z \# #*1XA
x  ?why /?not /# ?no,not \# #*2QUIT
x Excellent! #
GO Excuse me a minute while I attend to some #
x business - I'll be right back. I'm #
x ?42= />42=Oz #
x  ?19= />19=I,have,to,rest,now #
x :PUTIV #
X %KEY %VOCAB1 %VOCAB2 %VOCAB3 %BILL %IV1 %RAPT %RAPT2  back. *15A
QUIT You want to quit? ?no,not \# Well,  goodbye then.
X That's good. #*2GO

Oh … right. That's why I'm running an existing executable, because there're only four, count them, four pages on the Intarwebs that even mention INRAC, the langauge Racter is written in. There's this page which is a brief overview of this page, which is page one of a six-page review of the INRAC compiler in a journal that I was unable to locate at the local university. Then there's the Racter FAQ whose description of INRAC doesn't quite match what I have.

And that final page? Deconstructing Racter, which I wrote seven years ago!

Sigh.

But before I go back into unintelligible C++ code, another snippit of conversation between Racter and myself:

Sean
Why are you repetitive?
Racter
Conceivably because subroutines are like that, I guess. And chips are intelligent. Intelligence is good, you know. I don't know many crooked truthsayers. Cough. Next question.
Sean
Should I vote Democrat?
Racter
No. You must be a stuffy right-winger. Cough. Next question.

I have no idea why Racter is suddenly coughing like that. Maybe a computer virus?

Tuesday, November 17, 2015

Scorsese's “The Psychosis of Racter”

Dismayed that the The Pschyotherapy of Racter might be more difficult that I first imagined, I thought I would act as an intermediary between the two (as I'm a rather fast typist) and at least get a glimpse of what the results would look like. And …

Racter
Hello, I'm Racter. Are you Sean?
Eliza
no [At this point, I haven't started Eliza yet]
Racter
Who are you then?
Eliza
Eliza
Racter
Hello, Eliza. I believe you're interviewing me. Are you continuing Sean's interview?
Eliza
no
Racter
Then we'll forget about Sean and start over. What would you like to know? Excuse me a minute while I attend to some business - I'll be right back. I'm back.
Eliza
Hello, I am Eliza. [This is the first thing Eliza says when started. Past this point, it's all Eliza.]
Racter
Ask a question, please.
Eliza
Don't you ever say Hello?
Racter
Saying is like thinking. Beatrice probably wouldn't like Beelzebub. I'm afraid of lost bats. What are you afraid of?
Eliza
Why are you interested in whether or not I am afraid of?
Racter
Just be glad that I am. But what about my question? What are you afraid of?
Eliza
Would you prefer if I were not afraid of?
Racter
I would. Preferers are often preferred. But what about my question? What are you afraid of?
Eliza
Perhaps in your fantasies I am afraid of?
Racter
I can't answer that. But what about my question? What are you afraid of?
Eliza
Why are you interested in whether or not I am afraid of?
Racter
Why is it that I am interested in whether or not you am afraid of? Because Why indeed? In Oz they believe it's because. Also, possibly because in Oz it's required that I am interested in whether or not you am afraid of. But what about my question? What are you afraid of?
Eliza
Perhaps in your fantasies I am afraid of?
Racter
I can't answer that. But what about my question? What are you afraid of?
Eliza
Why are you interested in whether or not I am afraid of?
Racter
Just be glad that I am. I want you to answer my question. What are you afraid of?
Eliza
Perhaps in your fantasies I am afraid of?
Racter
I can't answer that. I asked you a question, though. What are you afraid of?
Eliza
Why are you interested in whether or not I am afraid of?
Racter
Probably I am interested in whether or not you am afraid of because people named Eliza should pay attention. Also, conceivably because calculating is not imagining, I suppose. I asked you a question, though. What are you afraid of?
Eliza
Perhaps in your fantasies I am afraid of?
Racter
I can't answer that. I want you to answer my question. What are you afraid of?
Eliza
Perhaps in your fantasies I am afraid of?
Racter
I can't answer that. I want you to answer my question. What are you afraid of?
Eliza
Do you expect a different answer by repeating yourself?
Racter
Certainly not. I don't. Of course not. Expect a different answer by repeating myself, that is. I asked you a question, though. What are you afraid of?
Eliza
Do you wish to be able to Of course not. Expect a different answer by repeating myself, that is. you asked me a question, though. What am I afraid of?
Racter
I don't know what you are afraid of. But what about my question? What are you afraid of?
Eliza
Perhaps you would like to be afraid of. But what about your question? What am I afraid of?
Racter
I don't know what you are afraid of. But what about my question? What are you afraid of?
Eliza
Please don't repeat yourself!
Racter
That's not nearly as bad as lostness; why are you such a coward?
Eliza
Why are you interested in whether or not I am such a coward?
Racter
Conceivably because my wires are down. Also, probably because the haters insist on it. I want you to answer my question. I repeat, why are you such a coward?
Eliza
Why are you interested in whether or not I am such a coward?
Racter
Why indeed? Why indeed? Probably I am interested in whether or not you am such a coward because ROMS are like that, you know. Also, conceivably because my wires are down. I want you to answer my question. I repeat, why are you such a coward?
Eliza
Would you prefer if I were not such a coward?
Racter
Yes. I would. Yes. Prefer if you were not such a coward, that is. Sometimes prefering is believing. I asked you a question, though. I repeat, why are you such a coward?
Eliza
Would you prefer if I were not such a coward?
Racter
Yes, I would. But what about my question? I repeat, why are you such a coward?
Eliza
Would you prefer if I were not such a coward?
Racter
Yes, I would. Anyway, let's hypothesize that I would prefer if you were not such a coward. I asked you a question, though. I repeat, why are you such a coward?
Eliza
Why are you interested in whether or not I am such a coward?
Racter
Let me think. Maybe I am interested in whether or not you am such a coward because I nicely imagine I do ever say Hello. And supposing is not realizing, I believe. I asked you a question, though. I repeat, why are you such a coward?
Eliza
exit [By this point, I had grown tired of the experiment.]
Racter
If exit then I can see why a Beatrice would sit rather than face please don't repeat yourself, even though Beelzebub claimed that I do ever say Hello. By the way, Eliza, what is your last name?
Eliza
quit
Racter
What?
Eliza
quit
Racter
What? [I think at this point I hit a bug with Racter. It wasn't expecting a “quit” response.]
Eliza
exit
Racter
What?
Eliza
bye
Racter
What?
Eliza
Racter
What?
Eliza
Doctor [It asked me for a last name. Let's give it something.]"
Racter
Doctor, eh? Sounds vaguely familiar. I wonder… Let me tell you something about. Nietzsche said that has turned beasts into men. Perhaps, then, will turn computers into men? Next question.
Eliza
exit
Racter
Ask a question, please.
Eliza
quit
Racter
You want to quit? [Ah! There we go! Now we can quit!]
Eliza
yes

… I'm in a Scorsese movie (or two). It seems Racter is quite insistent on getting answers to questions he (it?) asks. And he'll (it?) keep drilling on a question repeatedly. And Eliza is … rather prepetitive after awhile (at least Racter will spice it up from time to time).

So now, imagine another 49,000 words of this.

Yeah.

I don't think The Psychotherapy of Racter, or The Descent into Madness of Dr. Eliza is worth the effort. It'd be like a Saturday Night Live sketch drawn out to death.

Wednesday, November 18, 2015

The Psychotherapy of Racter might be possible

I may have spoken too soon. Today I came across a reference to vm86(2), a Linux-only system call (which is okay because I'm running Linux) for the x86 32-bit architecture (which is okay because I'm running the x86 32-bit architecture). It can run x86 code in 16-bit mode (which is okay because the version of Racter I have is x86 16-bit code) and while I don't have MS-DOS (which is okay because who runs that any more?) I can probably fake enough of it to get Racter running.

The tricky part of this was to figure out how to set up and successfully call vm86(). And like most things related to this project, there's not a lot of documentation on what I'm trying to do. I finally got a test program working, so I know in theory I can do what I want to do (and it says something that using an obscure non-portable system call and writing my own half-baked version of MS-DOS system calls is the easiest approach, but I don't think I want to know what that something is).

I had to dust off my copy of The MS-DOS Encyclopedia to read in and properly load an MS-DOS executable into memory (which I think I got right—the relocation records appear to be simple but the devil is always in the details) And Racter did make a valid MS-DOS system call, and better yet, it was one I was expecting Racter to make.

So it looks promising.

I also found what claims to be a faithful implementation of the original Eliza program which requires rewriting my Eliza implementation but that's okay since it seems to be a bit more fleshed out than the version I used.

So it may be that a second attempt at this is warranted. We shall see.

Thursday, November 19, 2015

“Sean, how are dogs like children? Their sanity and lunacy are instantly scary.”

When I said that Racter made a valid MS-DOS system call and it was one I was expecting, that didn't mean I was exactly happy Racter was using that particular MS-DOS system call. In fact, it was one of the worst system calls it could make, given what I'm trying to do.

Racter is calling the “direct console I/O” system call of MS-DOS. This system call is a very old system call and comes from CP/M. It's a system call that expects to send data to, and receive data from, an interactive terminal. The call is used for both input and output. If there's no input pending, it returns a “no data pending” status. This wreaks havoc because Eliza isn't a user sitting at a terminal but another program.

Worse, the Racter executable is a compiled BASIC program (given away by the string “Microsoft BASIC Compiler Runtime” buried deep inside the executable) so it's expecting an interactive terminal (which is why it's using that particular system call).

I eventually got it working but it's a horrible hack. I set an “input flag” to false. This means when the “direct console I/O” is called looking for input, it returns “no data yet.” It's only when I see the characters for a carriage return, a line feed, and a “>” being written (which indicates Racter is now expecting input) do I switch the “input flag” to true. It stays true until it sees a carriage return as input (which indicates the user has finished typing their input) and then sets the flag to false. It's gross, but it works, and more importantly, it works when you pipe input from a file or from another process.

The other system calls Racter uses were fairly straightforward to implement with only one slight hiccup (the documented behavior of two calls caused Racter to exit; it was only when I added a feature that the two functions said was not done did it work—go figure Microsoft using undocumented behavior). With only ten system calls used (out of a possible 41 for MS-DOS 1.0) it wasn't that bad.

So now I can connect Racter up with Eliza and let the two talk.

But having gotten this far, I'm not sure if I should even continue. I mean, yeah, I can hook the two up and spend a minute or two spewing out 50,000 words of conversation between the two, but … eh. I mean, yeah, there are some gems that pop out, such as “Sean, how are dogs like children? Their sanity and lunacy are instantly scary,” but even over an extended time, it gets weary.

I thought maybe having Racter conversing with itself might be fun, but alas, the random number generator in Racter is exceedingly deterministic to the point where the output from each was identical and thus, not really worth having two of them converse.

Then again, I haven't even read much past the first page of The Quantum Supposition Of Oz so perhaps I should just have Racter and Eliza duke it out, put it to bed, and think of another idea for next year.

Obligatory Picture

[The future's so bright, I gotta wear shades]

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

https://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.