Wednesday, October 27, 2021

Acuitas Diary #43 (October 2021)

This month I have *mostly* finished my overhaul of the Conversation Engine. I managed to restore a majority of the original functionality, and some things I haven't put back in yet are perhaps best left until later. I also got the janky new code cleaned up enough that I'm starting to feel better about it. However, I did not end up having the time and energy to start adding the new features that I expect this architecture to enable. I'm not sure why this particular module rebuild felt like carrying heavy rocks through a knee-deep river of molasses, but it did. The year is waning, so maybe I'm just getting tired.

A tree structure. No, really. Photo by Ed Vaile ("Edric") from Palmpedia.

So what's new? I mentioned last month that part of the goal was to give conversation tracking a more tree-like structure. Given a new text input from the speaker, the Conversation Engine will explore a tree made of previous sentences (starting from the most recent leaf) and try to find a place to "attach" it. It gets attached to the root of the tree if it doesn't obviously follow or relate to anything that was previously said. The old CE just put previous sentences from the conversation into a list, and all but the most recent one or two were never considered again, so this should be more powerful and flexible. 

 The CE then performs a "scripting" function by generating a set of reasonable responses. These are sent to the Executive, which selects one based on appropriate criteria. For example, if the speaker orders Acuitas to do something, possible reactions include "ACCEPT" and "REFUSE," and the Executive will pick one by running a check against the goal system (does Acuitas *want* to do this or not?). The chosen action then calls the Text Generator to compose the right kind of spoken reply. 

 The Executive can also prompt the CE for something to say spontaneously if the conversation is lagging (this is where those internally-generated questions come back into play). The Narrative manager is attached to the CE and tracks plot information from any story sentences the CE passes to it. Someday I will try to diagram all this ... 

 The renovations have reduced the size of the Conversation Engine from almost 2000 lines to a much tidier 946 lines. I can't claim all of that as a savings, since some of the code has simply moved elsewhere (e.g. into the Action definitions), but I think it's at least better organized now. 

 I also did some bonus work on the Text Parser. I have started working on coordinating conjunctions, which are a major grammar element the Parser doesn't yet comprehend. This is a big deal. For the sake of getting off the ground quickly, I designed the original parser to only interpret the simplest sentence structures. I later added support for nesting, which enables dependent clauses. Now to handle coordinating conjunctions, I have to overhaul things again to allow branching ... and my, are there a lot of ways a sentence can branch. 

 I might not finish this until next year, but I'm relieved to have made a start on it. When I began Acuitas v3, I don't think I anticipated (at all!) how long it would take just to get the Parser working on all the basic parts of speech! I suppose it would have gone faster if I had only worked on the Parser, but too many other things came up. 

Until the next cycle, Jenny