a rising mist
The Goodly Mist
A Workingblog for Rob Sherman
#books   #code   #d&d   #essay   #food   #games   #link   #music   #nature   #news   #notes   #poetry   #projects   #prose   #spoken   #tech   #travel   #videos   #visart

knole Prototype #1a – The BOD Architecture

March 7, 2016


[ link to prototype (.exe) ]   [ github repo ]


I’ve just released another prototype of knole’s titular landscape god, but there is nothing new for you to see. It still just sits on its own neck and watches, breathing and blinking slowly, and I still question whether or not a god even should breathe. My placeholding art is still holding the place, though hopefully I will soon feel confident enough to show some other concepts; many people to whom I’ve shown it even like the clean lines and demarcated, symbolic biology, and feel that I should keep it that simple and abstract throughout. This would certainly irrigate my theories (cribbed from others) concerning the power of human imaginative abstraction, and significantly lower my workload.

In its quiet, introverted self-regulation it still has, in the words and work of my supervisor Dr. Leon Watts, no ‘Social Presence’; that is, without some method of interaction, it cannot enter into the user’s conceptual ecosystem of interpersonal relationships as a recognised peer or self-willed organism; this is the very definition of an agent 1. However, in showing it to friends and colleagues I am beginning to question this assertion; their personal ecosystems are doing a very charitable job of trying to include the god as an imagined agent, if not one in reality. They project its presence on its behalf, agree on the potential of its participation in a social relationship with them; even if the god, all the way down to the very genesis of its code, has no concept of participating with its subjects at all.

The main differences between this prototype and the first lie in the architecture of that code. However, rather than being simply due to an act of machinist housekeeping, these differences constitute entirely distinct ways of thinking about what it means to be a creature, an agent, a god, a creation and its creator. At least for myself.

I have mentioned here before the Behaviour-Oriented Design (BOD) architecture developed by Dr. Joanna Bryson from the University of Bath; and I am going to do so again, completely artificially, as I think that I could do with the practice. BOD is a general, language-agnostic set of principles for building intelligent digital agents, whether they be robots or entirely-software based entities 2. It involves programming the agent with two internalised, interconnected layers of functionality; a set of behaviours, modular, self-contained programs that each control an aspect of the agent’s internal and external appearance, actions and mien, alongside a reactive planning script that decides which of those behaviour modules should execute at any particular time.

BOD architecture diagram

In BOD, each distinct behaviour of the agent (in knole’s case, the breathing and blinking behaviours) are hermetic objects in and of themselves; ancillary, independent programs that can conduct their own internal calculations and computations quite happily. These behaviours can model internal processes; such as, for example, listing all the obsolete chocolate bars once sold in the United Kingdom; or external actions, such as putting on a bolo tie. These behaviours do not need to run one at a time, but can run in vast parallel if called upon by the plan to do so. Their object-oriented design, like that of other programming languages to which I cling parochially, removes any worries about interdependencies, conflicts or fug when it comes to running these behaviours. They are logical islands.

Though they can conduct their own business internally, any influence they might have over the world outside of themselves is controlled by the reactive plan. This script decides which behaviours to trigger in any particular instant, based on a combination of the agent’s internal state and the state of that part of the external world that the agent can perceive. The plan makes such a decision once every program cycle (for knole, this is once every 60th of a second). Dr. Bryson calls these plans POSH (Parallel-Rooted, Ordered, Slipstack Hierarchical), and they are structured in a very particular way to allow certain decisions, or factors in those decisions, to take precedent over others.

This structure has three parts, or aggregates, which are influenced by the internal state of the agent and the sensual data being received from the external, perceptual world, and which in their turn influence the acts that the agent might then commit. In order of importance (or position in the hierarchy), these aggregates are:

    • Drive Selections – This is a process of constant checking, once every program cycle, of the agent’s current goals. These may be short-term or long-terms goal, and are subject to constant deletion, creation and re-categorisation based on new information received either from inside or outside the agent. Suppose, for our nostalgic, pseudo-Arizonan example agent of above, that there are no more chocolate bars to be wistfully remembered, and so that lofty goal has been attained; no longer relevant, the agent can delete that drive, turn off the behaviour and move onto the scintillating business of fastening its culturally-reductive neckwear.

 

    • Competences – These are the major functionality of a POSH plan, in which the agent acts (through behaviours) to achieve the goals chosen during the drive selection. They represent lists of hypothetical and conditional actions, which must fulfill the parameters of the actions above them to be initiated. For example, an agent can only put on their bolero if they have first bought one; therefore, the [buy bolero] action would come above [put on bolero]. Down the list the agent goes, taking those actions which are both highest on the list and possible to fulfill. Usually, there is a default action which is activated if none of the other conditions are met; in our agent’s case, this might be simply a furtive, rebellious whisper of ‘Shucks’.

 

    • Action Patterns – In many cases, no deliberation over an action is needed; it executes in the same way, and in the same order, every time it is called, with no conditions to fulfill. These action patterns are syllogistic to reflexes, and often don’t even need to pass through the reactive plan at all; they can instead be directly triggered by senses, or even other behaviours and actions. They represent the most instinctual, systematic components of an otherwise-rational agent.

 

BOD design diagram for knole

This prototype was an attempt to reconstruct my godlet as a BOD agent. Construct 2, the software I used for the first prototype, was not up to snuff for this task, and so I returned to Gamemaker: Studio. Perhaps Construct could have handled the BOD architecture, but I find the way it structures and represents the architecture to be confusing and restrictive. One of things that I like about BOD is its modular, object-oriented structure. Building my creature in this way allows me to think about my creature in this way, to compartmentalise it in an almost-cartographic fashion; the diagrams in this post, I think, looks more like a map than anything else. Construct 2, with its event sheets and terraced UI, only serves to block this conception, forcing me to consider my creature as a temporal, linear process rather than a spatial system. I can also code by hand in Gamemaker, which is certainly faster than clicking through sub-menus with a £5 mouse.

Above is a diagram of the general structure of my godlet using BOD. Even though it is all a little artificial, the creature now has a believable, living metaphor at its centre, even if it is a mechanistic and reductive sort of metaphor. In Construct, the breathing and blinking were the entirety of the godlet’s internal function, animations that were programmed to begin and repeat without any structure to give that beginning or repetition any meaning. With these two behaviours now separated into modules and subsumed into the larger organisational structure of BOD they have a purpose, and indeed form an amoebic narrative. The creature breathes and blinks because the POSH plan, a metaphor of cogency, is telling them they should. Of course this isn’t anything like true agency; in the discourse of BOD these behaviours are merely action patterns, and once called to activate they will run in the same manner every time, much like a reflex in an organism. However, I have built some fuzzy variables into their functioning, which in the future may be altered by other factors both internal and external; these variables include the rate of breathing, the range of motion in the components of the face and the speed of the blink. It will be interesting to see how these cyclical, impregnable processes will be influenced. As always with object-oriented design, there is an ongoing question of control; when objects contain their own variables, and are trusted to coexist with many other objects in a complex space, how does the designer create a rule-set for allowing interaction between those objects? These interactions are key to more complex and interesting behaviours, but a schema has to be imposed; as the godlet becomes more complicated, the interrelations, interferences and persuasions between objects will become harder to plot. Perhaps this is where the truly emergent, unexpected behaviour will arise; then again, perhaps it will just be a nightmare to debug.

The other issue with this approach lies in the question of granularity of the cognitive metaphor that I have created using BOD. The creature, and its development, are predicated on an ‘illusion’ of intelligence and life. I wish to demonstrate how a simulation of life only needs to be as developed as much the fiction requires it, and no more. Where that requirement ends, however, is a thick line to draw, and begs a further question; for the creature to succeed as a dynamic character, does the designer need to invest in the illusion, as well as the audience? How much functionality must I build which, while having no impact on the audience’s external experience of the godlet, provide me with an internal experience, a personal fiction, that might help me develop the rest of the simulation?

Both behaviours in my prototype demonstrate this case in point. In the blinking behaviour, I have carried over a lot of the functionality from Prototype #1, including the mechanical action of the eyes opening and closing, and the random activation of that action; at a random point every 400 milliseconds, the blink is triggered. This little action pattern is plenty good at giving the illusion of a living being to a observer. It is easy to imagine, when the functionality is hidden, that the godlet is not responding to a random timer but is instead clearing its precious, holy corneas of grime. However, in the BOD prototype the random activation of the blinking is encased in a new conceptual metaphor, represented by the invisible object [mIrritationDetector]. This object is there on the godlet’s face, even if you cannot see it; a dimensionless bindi positioned directly between its eyes.

Here is the code that it runs:


if IrritationCounter > 0 {
IrritationCounter = IrritationCounter - 1
} else if IrritationCounter <= 0 {
Irritated = true
IrritationType =
choose("dust","light","blood","sweat","tear","insect")
}

So, every 400ms the [mIrritationDetector] gets irritated, and broadcasts that irritation to the godlet’s reactive plan, along with a randomly-chosen ‘irritation type’ represented as a string; this type might be “dust”, “insect”, “tear” or even “user’s finger”. The reactive plan then causes the blinking behaviour to run. It’s an odd and unnecessary bypass.

In a similar manner, the breathing behaviour is placed in an arbitrary container of its own, one reified by me, the designer, as a way of thinking about my being as being. The godlet’s reactive plan only runs if the variable Alive is true; in turn, the Alive variable is only true if the invisible object mAir is present in the godlet’s world (its ‘room’, in the ontology of Gamemaker). If I remove the mAir object, the creature is no longer alive. However,


if Alive = true {
if instance_exists(mAir) {
bBreathing.BehaviourActive = true
}
}

Both of these systems are arbitrary and redundant; the roundabout route of the irritation from detector to POSH plan to behaviour does not change the outward appearance of the behaviour at all; which most AI developers, including myself, might argue is all that matters. The Alive variable is just another set of brackets around functionality that I wish to run regardless; I have no intention, currently, of ever setting that Alive Boolean to false, or of deleting the mAir object and having the godlet suffocate. It would be perfectly reasonable to argue that such structures are a waste of code, memory, program cycles and time. knole functioned, to all appearances, in the exact same way without them.

These complications, then, were created primarily for myself, rather than for anybody or anything else. Perhaps in the future I will need to start thinking about memory allocation and performance; keeping the godlet graphically and functionally partial, a tortured head rather than a free, enacting body, was certainly motivated as much by this as by my desired fiction. For the moment, however, these useless lines of code and invisible, symbolic objects are part of a necessary and ongoing imaginative simulation of what my creature might still be. I set Alive to true< because, one day, my godlet might not be alive; and in creating that postulate of a god that might not be alive, I learn something about its divinity, and also learn something about that which it might value. Gods traditionally have little to fear, for they cannot be obliterated; what does it do to a being's animus to be vulnerable in that manner? What if-elses does it add to its POSH plan? Even further granularity could be imagined; a debate arises about the fuzziness of living, philosophically and mechanically; is it simplistic to represent living as a binary value? Should it instead be a scale, a program in and of itself? The irritations in the godlet's eye, with their pointless taxonomy, may not always be pointless; just because it does not yet cry, that does not mean that I want it to have no system of self-responsibility when it finally does. Perhaps it will fall in love with a particular type of insect, themselves a sort of virtual agent inside the godlet's room, and permit this insect to drink from its caruncula. When building agents, the illusion that we construct for ourselves as creators is as important as the illusion we construct for our audience. Until I know what my knole is, as much as I will ever know this quiet, expectant non-participant of a deity, I cannot preclude the infinite structures, associations, relationships and cogitations that might lurk invisible between its eyes. While such a non-prescriptive process makes for a sloppy codebase, it matters to me.

1. An interesting thought occurs regarding the more populist use of the word ‘agent’ to represent spies, assassins and other clandestine shenaniganeers. It’s an oddly general term for such people, the word meaning as it does ‘something or someone who acts’. In computing, the use implies a certain degree of will; an agent collects information from around it and uses this to inform an independent decision as to the most rational action to next take; this implies autonomy. Apart from a few exceptional examples, the operatives of MI5, the KGB and the rest are more like subroutines than agents; a cellular component of a much larger operation, acting according to instructions sent from somebody higher up. There is actually very little power to act rationally in them at all; indeed, the entirety of a spy agency functions more like a single agent than the agents that comprise it.

2. knole is a combination of the two; primarily software based, with little method of actuating in the real world, but sensible to that world through arrays including geolocation, aural and visual recognition, gyroscopic arrays and temperature indicators. Probably. I’m still not sure how most of it works.