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.