Skip to content

Dictionary

Robert de Forest edited this page Jan 29, 2019 · 2 revisions

Example observation

The user has initiated an "open door". In this example we assume focus on doors (as opposed to chests and such) because that's what the user specified. To satisfy this goal the engine, core, system, setting, dictionary, world and domain all get a say in what means what. The code below creates an 'open' verb on the generic 'door' which could match a user's "open door" command, yielding a set of possible meanings with weights of likeliness.

    doorReferant = system.referant.door
    openAction   = doorReferant.action.open
    doorNoun     = dictionary.english.concrete.noun.portal.door
    theCreator   = dictionary.creator

    openableHypothesis = (subject, object) ->
      # relationship in event is supplied by createHypotheticalSuccess
      openAction.createHypotheticalSuccess {
        observer: subject
        context:  subject.context.now
        subject:  subject
        object:   object
      }
    
    doorNoun.addAction 'open',
        context: inputContext(
            inputMatches: verb: 'open', object: true

            possibleMeanings: (actor, objectString) ->
              objects = actor.matchObjects objectString

              objects.map (o) ->
                beliefs    = actor.beliefs
                hypothesis = couldOpen actor, o

                [o, actor.actionMatchQualities(hypothesis)]
          )

Which in english means:

  • The creators of this dictionary declare
  • When an actor enters a string matching 'open *'
  • Scan the actor's knowledge for possible meanings by
    • finding everything the actor knows of to which the subject string could refer
    • find the various ways those objects could match the hypothetical action

/* vim: syntax=markdown */

Clone this wiki locally