Skip to content

Let rules reference characters by ID? #108

@meldckn

Description

@meldckn

Let rules reference characters directly? This would mean accepting character IDs in the conditions and effects of trigger rules and volition rules, and in the conditions, effects, and influence rules of actions).

This is relevant for example, for actions that only the player-character can take, or a domain that has a traditional protagonist that many other actions, desires, etc, reference or focus on.

Even though it's desirable, in the sense that it's more procedural and better code reuse, to write all your rules so they can be bound to any character, in practice it's way common to want to explicitly link some of your rules to particular characters. Like for special treatment of the player-character. The assumption that you should write rules that could be applicable to all characters, or maximally rebound, seems like it was inherited from Prom Week (where there was no single player-character, and all characters had access to symmetrical actions/volitions/rules for reasoning about the world).

So I think we should allow this, to make it easy, but should maybe advise users to write rules with generic roles as much as possible in the materials and stuff, because I also think this explicit character naming thing can be overused and lead to dark patterns in your simulation design.

Current Workaround

The current work-around is to use 'named character traits', as illustrated in the Lovers and Rivals example:

  1. Create schema types for different character names:
{ 
  "schema": [{
    "category" : "trait",
    "isBoolean" : true,
    "directionType" : "undirected",
    "types" : ["named hero", "named love", "named rival", "anyone"],
    "actionable" : false,
    "defaultValue" : false
  }]
}
  1. Give each character their name trait in your history JSON or using ensemble.set() at the beginning of the simulation:
{ 
  "history": [{
    "pos": 0,
    "data": [{
      "category" : "trait",
      "type" : "named hero",
      "first" : "hero",
      "value" : true
    },{
      "category" : "trait",
      "type" : "named love",
      "first" : "love",
      "value" : true
    },{
      "category" : "trait",
      "type" : "named rival",
      "first" : "rival",
      "value" : true
    }]
  }]
}
  1. Use the schema type corresponding to the character you want to reference to bind them to the "first" or "second" role in any rule condition. For example, this volition rule:
{
  "type": "volition",
  "rules": [{
    "name": "The hero REALLY wants to increase closeness to the love",
    "conditions": [
      {
        "category": "trait",
        "type": "named hero",
        "first": "x",
        "value": true
      },{
        "category": "trait",
        "type": "named love",
        "first": "y",
        "value": true
      }
    ],
    "effects": [
      {
        "category": "feeling",
        "type": "closeness",
        "first": "x",
        "second": "y",
        "weight": 20,
        "intentType": true
      }
    ]
  }]
}

Proposal

Not sure what it should look like though...

One possibility: use character IDs as values in the role properties ("first", "second") of effects. No need to bind them in the condition?

{
  "type": "volition",
  "rules": [{
    "name": "The hero REALLY wants to increase closeness to the love",
    "conditions": [],
    "effects": [
      {
        "category": "feeling",
        "type": "closeness",
        "first": "hero",
        "second": "love",
        "weight": 20,
        "intentType": true
      }
    ]
  }]
}

^ If we use this, we'd have to hold character IDs as keywords that you can't use as normal role names in rules.

Another possibility: Allow a new kind of "name", "character", or "characterID" condition statement to bind characters to abstract roles and then use the roles in effects.

{
  "type": "volition",
  "rules": [{
    "name": "The hero REALLY wants to increase closeness to the love",
    "conditions": [
      {
        "name": "hero", 
        "first": "x",
        "value": true
      },{
        "name": "love",
        "first": "y",
        "value": true
      }
    ],
    "effects": [
      {
        "category": "feeling",
        "type": "closeness",
        "first": "x",
        "second": "y",
        "weight": 20,
        "intentType": true
      }
    ]
  }]
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions