Mechanics: Discussion – Goal Oriented Sex

Let’s consider a simple goal-based AI implemented using a stack of actions and thoughts. This is a system I’m considering using to control NPC’s actions during sex scenes, but it should also have different applications.

What are we going to need for this?

  • A stack, though it might be better to think of this is a list really since I’ll talk in a moment about operations affecting the stack itself;
  • Thought and actions, since this is just a sketch of an idea, let’s just think about it pretty abstractly – every thought and action can have parameters and ultimately has a handler that will execute it.
  • A starting though, or series of thoughts, defining the goals of the character.

Then, the procedure is simple: if the stack isn’t empty, pop an element and pass it to the handler. By being executed, it might or might not add more elements to the stack. Repeat until you run out of elements in the stack.

Thus, this system’s vital element, without which it can’t really do anything, is the handler. That is where the behaviours are defined. In essence, it’s a mapping between spaces, but it might be best to just think of it as a black box for now. The handler’s goal for thoughts is to add more data (both thoughts and actions) onto the stack, by elaborating on them. When thinking of a thought, it maps it (combined with the world state) to a sequence of thoughts and actions and potentially applies changes to the character’s state. On the other hand, when the handler resolves an action, it makes changes to the world state and produces output for the game (since it is a text game).

Additionally, as actions might provoke the PC to take action or express herself somehow, these elements can also be added to the stack in the form of thoughts. It is also possible for the handler to force a re-evaluation of the NPC’s goals by partially or fully clearing the stack and re-populating it. While simulating realistic BDSM, this is important, as the PC’s actions might cause the NPC to stop what they are doing and either cut the scene short or decide to approach it differently.

You might note that the difference between thoughts and actions is not necessarily significant, but keeping track of what is a thought and what is an action leads to some simplifications later.

Let’s see how this works for a scene where the NPC decides to get a bit frisky with the PC at the door! Let’s assume this NPC is Cornelius, because he’s what I’m currently working on.

Firstly, let’s consider the state of the world:

  • the PC and NPC are close together,
  • the PC is clothed,
  • the NPC is clothed,
  • there is a wall nearby.

Stack:

  • thought: give the PC an orgasm

The system pops the element and processes it, assuming it understands such a thing as sex against a wall; it might then add the following series of thoughts to the stack:

Stack:

  • action: kiss the PC
  • action: explain intent to PC ↦ sex against the wall
  • thought: sex against the wall
  • thought: give the PC an orgasm

Next, it can process the actions, and after the NPC explains his intent, the PC can be presented with a series of choices. For simplicity, let’s say that the PC contents to the NPC’s intentions.

Stack:

  • thought: PC gave consent to ↦ sex against the wall
  • thought: sex against the wall ↦ prepare
  • thought: give the PC an orgasm

Having the PC consent to the NPC’s wishes is a good place to insert extra foreplay, teasing, or dirty talking. A few grabs at her body through her clothing, another kiss, etc. I’ll skip this not to bog this explanation down with unnecessary details, especially as right now they are purely theoretical.

As such, we might as well get to resolving the next one as well. This is a specific act the NPC wants to perform; it can have particular prerequisites before it starts, these prerequisites can be added to the stack.

Stack:

  • thought: ensure PC’s womanhood is accessible
  • thought: ensure NPC’s member is accessible
  • thought: ensure PC is in position ↦ against the wall
  • thought: sex against the wall ↦ initiate
  • thought: give the PC an orgasm

This can but doesn’t need to result in actions. Either or even both of them can already be naked enough for this to work. Though likely ensuring the position will happen as an action. Similarly to what I said before, there might be places where the PC takes action that later results in a different flow of events — alternatives between stripping down herself/helping him or letting him do it. As well as space to add additional foreplay actions related to the NPC’s current efforts. If he needs to pull her panties down, it’s possible to insert further activities there related to some groping… or perhaps probing the PC with his fingers. And as such, we finally arrive at a stack containing the deed itself.

Stack:

  • action: sex against the wall ↦ initiate
  • thought: give the PC an orgasm

This, in itself, leaves a lot of openings for the progressive modularisation of the whole problem. But sadly, I’d like to finish here, so I’ll just mention that sex itself must be divided into segments. This lets both the PC and NPC influence what happens, add to the scene with details or change the goals or world state. Nothing says that just since it started in some position or place, it has to end there.

Comparably to what I was working with before (a hierarchical recursive system of calls), this is a flat system progressing based on data. Easier to manipulate, more modular and open for content expansion. However, there’s an issue, and I will need to consider what I want to do with it – a system like this requires more fore-planning since the modules would need to be much more open-ended. I can’t treat them as closed boxes I can tinker with separately from the whole. Which is valuable in terms of crafting individually bigger but complete structures. While each thought or action is individually smaller, they are all collectively interdependent on the data (world state) they share.

Possibly the solution to this is starting with a skeleton for all the interactions and then detailing them top-down? It wouldn’t be the first time this kind of design worked for me. Well, we’ll see how it goes, I guess!

One thought on “Mechanics: Discussion – Goal Oriented Sex

Leave a comment