UNPKG

agents-flow

Version:

Framework for multi-agent interactive fiction videogame.

3 lines (2 loc) 23.9 kB
import{Effect as t,EffectDirection as e,Situation as i,apply as n,Reactions as s}from"npc-emotional";import{LogicAgent as r,Individual as o,TruthTable as a,Sentence as l,modusPonens as h}from"first-order-logic";import{Queue as c}from"data-structs-n-algos";class u{constructor(t){this._choiceIndex=void 0,this._choiceIndex=t}get choiceIndex(){return this._choiceIndex}get isVoid(){return this._choiceIndex<0}static void(){return new u(-1)}}var _,d;function g(t){return 1===t.length?t[0]:t[function(t){var e=t+1;return Math.floor(Math.random()*e)}(t.length-1)]}!function(t){t[t.Low=-1]="Low",t[t.None=0]="None",t[t.High=1]="High"}(_||(_={}));class m{constructor(t,e,i=null){if(this._content=void 0,this._effect=void 0,this._sentence=void 0,null==t||""===t.trim())throw new Error("Content cannot be empty.");if(null==e)throw new Error("Effect cannot be null.");this._content=t,this._effect=e,this._sentence=i}get content(){return this._content}get effect(){return this._effect}get sentence(){return this._sentence}get hasSentence(){return null!==this._sentence}}class f{constructor(e,i=null,n=null){if(this._text=void 0,this._effect=void 0,this._sentence=void 0,null==e)throw new Error("Text function cannot be null.");this._text=e,this._effect=null==i?e=>t.null():i,this._sentence=n}get text(){return this._text}get effect(){return this._effect}get sentence(){return this._sentence}}class p{constructor(t,e=null){if(this._alternatives=void 0,this._performerRole=void 0,this._targetRole=void 0,this._isIntimate=void 0,null==t||""===t.trim())throw new Error("Performer role cannot be null.");if(null!=e&&""===e.trim())throw new Error("If defining target role, it can't be empty.");this._performerRole=t,this._targetRole=e,this._isIntimate=!1,this._alternatives=[]}get performerRole(){return this._performerRole}get targetRole(){return this._targetRole}get isIntimate(){return this._isIntimate}get isMultialternative(){return this._alternatives.length>1}allAlternatives(t){return this._alternatives.map(e=>e.text(t))}withAlternative(t,e=null,i=null){if(null==t)throw new Error("Alternative cannnot be null");return this._alternatives.push(new f(t,e,i)),this}intimate(){this._isIntimate=!0}action(t,e,i=-1){let n=this.chooseAlternative(t,e,i),s=n.text(t);if(s.includes(":")){let e=s.split(":");return new m(t.get(p.uncorcheted(e[0])).say(t.assignRoles(e[1])),n.effect(t),null==n.sentence?null:n.sentence(t))}return new m(t.assignRoles(s),n.effect(t),null==n.sentence?null:n.sentence(t))}chooseAlternative(t,e,i){return 1===this._alternatives.length?this._alternatives[0]:i>=0?this._alternatives[i]:this.performerHasMeaningfulDesires(t,e)?this.calculateAlternativeBasedOnDesires(t,e):this.calculateAlternativeBasedOnEmotions(t)}performerHasMeaningfulDesires(t,e){let i=t.get(this._performerRole).Desires;return i.any&&i.anyInvolved(e.all)}calculateAlternativeBasedOnDesires(t,s){const r=-1e6;let o=t.get(this._performerRole),a=this._alternatives[0],l=r;for(let u of this._alternatives){let _=r,d=u.effect(t);if(d.direction===e.Neutral)_=o.Desires.heuristicTotal(s);else{var h=s.copy(),c=new i(h.get(o.Name),h.get(t.get(d.target).Name),this._isIntimate?d.isThirdPerson?[h.get(t.get(this._targetRole).Name)]:[]:h.all.filter(e=>e.Name!==t.get(d.target).Name&&e.Name!==o.Name));n(d,c,this._isIntimate),_=o.Desires.heuristicTotal(h)}_>l&&(a=u,l=_)}return a}calculateAlternativeBasedOnEmotions(t){var e=null==this._targetRole?this.calculateEffectDirection(t.get(this._performerRole).Happiness):this.calculateEffectDirectionWithRelation(t.get(this._performerRole).Relations.get(t.get(this._targetRole).Name),t.get(this._performerRole).Happiness),i=this._alternatives.filter(i=>i.effect(t).direction===e);return 0===i.length&&(i=this._alternatives),g(i)}calculateEffectDirection(t){return t.isHappy?e.Positive:t.isUnhappy?e.Negative:e.Neutral}calculateEffectDirectionWithRelation(t,i){if(t.isPonderatedGood&&i.isHappy)return e.Positive;if(t.isPonderatedBad&&i.isUnhappy)return e.Negative;if(t.isPonderatedNeutral&&i.isNeutral)return e.Neutral;if(t.isPonderatedNeutral&&i.isHappy)return e.Positive;if(t.isPonderatedNeutral&&i.isUnhappy)return e.Negative;if(t.isPonderatedGood&&i.isNeutral)return e.Positive;if(t.isPonderatedBad&&i.isNeutral)return e.Negative;if(t.isPonderatedGood&&i.isUnhappy)return e.Neutral;if(t.isPonderatedBad&&i.isHappy)return e.Neutral;throw new Error("Not existing option.")}static uncorcheted(t){return t.replace("[","").replace("]","")}}class v{constructor(t,e=[]){if(this._main=void 0,this._secondarys=void 0,null==t||""===t.trim())throw new Error("Main cannot be null.");if(null==e)throw new Error("Secondarys cannot be null.");this._main=t,this._secondarys=new Set(e)}get main(){return this._main}get secondarys(){return Array.from(this._secondarys.values())}get all(){return[this._main,...this.secondarys]}}class w{constructor(){this._roles=void 0,this._roles=new Map}get roleNames(){return Array.from(this._roles.keys())}get agents(){return Array.from(this._roles.values())}match(t,e){return this.validateRole(t),this.validateAgent(e),this._roles.set(t,e),this}get(t){if(this.validateRole(t),!this._roles.has(t))throw new Error("Specified role doesn't exist");return this._roles.get(t)}has(t){return this.validateRole(t),this._roles.has(t)}matched(t){return this.validateAgent(t),this.agents.some(e=>e.Name===t.Name)}assignRoles(t){let e=t;for(let t of this._roles.keys())e=e.replace(`[${t}]`,this._roles.get(t).Name);return e}equals(t){if(null==t)return!1;if(this._roles.size!==t._roles.size)return!1;for(let e of this._roles.keys()){if(!t._roles.has(e))return!1;if(this._roles.get(e).Name!==t._roles.get(e).Name)return!1}return!0}toString(){return this.roleNames.map(t=>`${this._roles.get(t).Name} as ${t}`).join(",")}validateRole(t){if(null==t||""===t.trim())throw new Error("Role cannot be empty.")}validateAgent(t){if(null==t)throw new Error("Agent cannot be null.")}}class b{constructor(){this._content=void 0,this._ender=void 0,this._choices=void 0,this._reactions=void 0,this._content=[],this._choices=null,this._reactions=null}get content(){return this._content}get isEnder(){return this._ender}get hasChoices(){return null!==this._choices}get choices(){return this._choices}get reactions(){return this._reactions}get hasReactions(){return null!=this._reactions}append(t){return null!=t&&""!==t.trim()&&this._content.push(t),this}static fromContent(t,e=!1){if(null==t||""===t.trim())throw new Error("Content cannot be empty.");let i=new b;return i._content=[t],i._ender=e,i._choices=null,i}static fromChoices(t,e=!1){if(null==t||0===t.length)throw new Error("Choices cannot be empty.");let i=new b;return i._ender=e,i._choices=new I(t),i}static fromReactions(t,e=!1){if(null==t)throw new Error("Reactions cannot be null.");let i=new b;return i._ender=e,i._reactions=t,i}}class I{constructor(t){if(this._items=void 0,null==t||0===t.length)throw new Error("Items cannot be empty.");this._items=t}get count(){return this._items.length}get items(){return this._items}isValidItem(t){return t>=0&&t<this._items.length}}class E{constructor(t,e,i,n,s,o,a,l,h=null){if(this._name=void 0,this._aspect=void 0,this._likes=void 0,this._relations=void 0,this._happiness=void 0,this._personality=void 0,this._isHuman=void 0,this._characteristics=void 0,this._desires=void 0,this._onTurnPassed=void 0,this._logic=void 0,this._isActive=void 0,null==t||""===t.trim())throw new Error("Name cannot be empty.");if(null==e)throw new Error("Aspect cannot be null.");if(null==i)throw new Error("Relations cannot be null.");if(null==n)throw new Error("Happiness cannot be null.");if(null==s)throw new Error("Personality cannot be null.");if(null==o)throw new Error("Likes cannot be null.");if(null==a)throw new Error("Characteristics cannot be null.");this._name=t,this._aspect=e,this._relations=i,this._happiness=n,this._personality=s,this._likes=o,this._characteristics=new A(t,a),this._desires=new R,this._isHuman=l,this._isActive=!0,this._onTurnPassed=null==h?(t,e)=>"":h,this._logic=new r,this._logic.population.add(this.Individual)}get Name(){return this._name}get Aspect(){return this._aspect}get Likes(){return this._likes}get Relations(){return this._relations}get Happiness(){return this._happiness}get Personality(){return this._personality}get IsHuman(){return this._isHuman}get Characteristics(){return this._characteristics}get Desires(){return this._desires}get IsActive(){return this._isActive}get OnTurnPassed(){return this._onTurnPassed}get Individual(){return new o(this.Name.replace(" ",""))}get logic(){return this._logic}say(t){if(null==t)throw new Error("Content cannot be null.");return`${this.Name}: - ${t}`}activate(){this._isActive=!0}deactivate(){this._isActive=!1}humanize(){this._isHuman=!0}dehumanize(){this._isHuman=!1}copy(){return new E(this._name,this._aspect.copy(),this._relations.copy(),this._happiness.copy(),this._personality.copy(),this._likes.copy(),this._characteristics.table.elements.map(t=>t.function.name),this._isHuman)}passTurn(t){return this._onTurnPassed(t,this)}}class N{constructor(t){if(this._crowd=void 0,null==t)throw new Error("Agents cannot be null.");this._crowd=new Map;for(let e of t)this._crowd.set(e.Name,e)}get all(){return Array.from(this._crowd.values())}get(t){return this._crowd.get(t)}copy(){return new N(this.all.map(t=>t.copy()))}}class y{constructor(t,e){if(this._involved=void 0,this._heuristic=void 0,null==t)throw new Error("Heuristic cannot be null.");if(null==e)throw new Error("Involved agents cannot be null.");this._heuristic=t,this._involved=new Set(e)}get heuristic(){return this._heuristic}anyInvolved(t){return t.some(t=>this._involved.has(t.Name))}}class R{constructor(){this._desires=void 0,this._desires=[]}get any(){return this._desires.length>0}append(t){return null!=t&&this._desires.push(t),this}clear(){this._desires=[]}anyInvolved(t){return this._desires.some(e=>e.anyInvolved(t))}heuristicTotal(t){return this._desires.reduce((e,i)=>e+i.heuristic(t),0)}}class P{constructor(t){if(this._agents=void 0,this._availableAgents=void 0,null==t)throw new Error("Agents cannot be null.");this._agents=t,this._availableAgents=[]}get all(){return this._agents}get count(){return this._agents.length}allExcept(t){return this._agents.filter(e=>e.Name!==t.Name)}popRandomAgent(){0===this._availableAgents.length&&(this._availableAgents=[...this._agents]);let t=[];for(let e of this._availableAgents)for(let i=0;i<e.Personality.introvertyExtroverty;i++)t.push(e);let e=g(t);return this._availableAgents=this._availableAgents.filter(t=>t.Name!==e.Name),e}}class A{constructor(t,e=[]){if(this._name=void 0,this._table=void 0,null==t||""===t.trim())throw new Error("Name cannot be empty.");this._name=t,this._table=new a;for(let i of e)null!=t&&""!==t.trim()&&this._table.add(l.build(i,this._name))}get table(){return this._table}is(t){if(null==t||""===t.trim())throw new Error("Characteristic cannot be empty.");return this._table.exists(l.build(t,this._name))}}class x{constructor(t){if(this._name=void 0,this._connections=void 0,this._agents=void 0,null==t||""===t.trim())throw new Error("Location cannot be null.");this._name=t,this._connections=new Map,this._agents=new Map}get name(){return this._name}get connections(){return Array.from(this._connections.values())}get agents(){return Array.from(this._agents.values())}append(t){if(null!=t)for(let e of t)this._agents.set(e.Name,e)}remove(t){null!=t&&this._agents.delete(t.Name)}has(t){return null!=t&&this._agents.has(t.Name)}connectWith(t){null!=t&&this._connections.set(t.name,t)}isConnected(t){return null!=t&&this._connections.has(t.name)}static join(t,e){t.connectWith(e),e.connectWith(t)}}class S{constructor(t){if(this._locations=void 0,this._ubications=void 0,null==t)throw new Error("Locations cannot be null.");this._locations=new Map,this._ubications=new Map;for(let e of t)this._locations.set(e.name,e)}getLocation(t){return null!=t&&""!==t.trim()&&this._locations.has(t)?this._locations.get(t):null}getUbication(t){return null!=t&&this._ubications.has(t.Name)?this._locations.get(this._ubications.get(t.Name)):null}move(t,e){if(null==t||null==e||!this._locations.has(e.name))return!1;if(!this._ubications.has(t.Name))return this._ubications.set(t.Name,e.name),e.append([t]),!0;let i=this.getUbication(t);return!!i.has(t)&&!!i.isConnected(e)&&(this._ubications.set(t.Name,e.name),i.remove(t),e.append([t]),!0)}areInTheSameLocation(t,e){return!(null==t||null==e||!this._ubications.has(t.Name)||!this._ubications.has(e.Name))&&this._ubications.get(t.Name)===this._ubications.get(e.Name)}}!function(t){t[t.Single=0]="Single",t[t.GlobalSingle=1]="GlobalSingle",t[t.Repeteable=2]="Repeteable"}(d||(d={}));class C{constructor(t){if(this._phrases=void 0,null==t)throw new Error("Phrases cannot be null.");this._phrases=new c(t)}get isFinished(){return this._phrases.isEmpty()}deliver(t){if(!this.isFinished)return this._phrases.dequeue();throw new Error("No phrases to deliver.")}}class H{constructor(t,e,i,n,s){if(this._name=void 0,this._description=void 0,this._preconditions=void 0,this._postconditions=void 0,this._timing=void 0,this._isIntimate=void 0,null==t||""===t.trim())throw new Error("Name cannot be empty.");if(null==e||""===e.trim())throw new Error("Description cannot be empty.");if(null==n)throw new Error("Preconditions cannot be null.");if(null==s)throw new Error("Postconditions cannot be null.");this._name=t,this._description=e,this._timing=i,this._preconditions=n,this._postconditions=s,this._isIntimate=!1}get name(){return this._name}get description(){return this._description}get preconditions(){return this._preconditions}get postconditions(){return this._postconditions}get isIntimate(){return this._isIntimate}get timing(){return this._timing}equals(t){return null!=t&&this._name===t.name}globallyEquals(t){return null!=t&&this._name===t.name}getPermutations(t,e){let i=[],n=this.rolesDescriptor;if(e.length<n.secondarys.length)return i;let s=this.calculateAgentCombinations(e,n.secondarys.length);for(let e of s)if(0!==e.length)for(let s of e){var r=(new w).match(n.main,t);r.match(n.secondarys[0],s);var o=n.secondarys.filter(t=>!r.has(t)),a=e.filter(t=>!r.matched(t));this.fillRemainingPermutations(r,o,a),i.push(r)}else i.push((new w).match(n.main,t));return i}calculateAgentCombinations(t,e){let i=t.map(t=>[t]),n=[];n.push([]);for(let t of i){let i=n.length;for(let s=0;s<i;s++)n[s].length>=e||n.push(n[s].concat(t))}return n.filter(t=>t.length===e)}fillRemainingPermutations(t,e,i){if(0!==e.length)for(let r of i){t.match(e[0],r);var n=e.filter(e=>!t.has(e)),s=i.filter(e=>!t.matched(e));this.fillRemainingPermutations(t,n,s)}}}class D extends H{constructor(t,e,i,n,s=d.Single,r=((t,e,i)=>!0),o=((t,e)=>a.empty)){if(super(t,e,s,r,o),this._phrases=void 0,this._rolesDescriptor=void 0,null==i)throw new Error("Roles descriptor cannot be null.");if(null==n||0===n.length)throw new Error("Interaction must have almost one phrase.");this._rolesDescriptor=i,this._phrases=n}get deliverer(){return new C(this._phrases)}get rolesDescriptor(){return this._rolesDescriptor}intimate(){this._isIntimate=!0;for(let t of this._phrases)t.intimate();return this}}class T{constructor(e,i,n,s){if(this._deliverer=void 0,this._effect=void 0,this._performerRole=void 0,this._targetRole=void 0,this._actualPhrase=void 0,this._onGoingPostconditions=void 0,this._roles=void 0,this._map=void 0,this._table=void 0,this._interaction=void 0,null==e)throw new Error("Interaction cannot be null.");if(null==i)throw new Error("Roles cannot be null.");if(null==n)throw new Error("Map cannot be null.");if(null==s)throw new Error("Postconditions table cannot be null.");this._interaction=e,this._roles=i,this._map=n,this._table=s,this._effect=t.null(),this._performerRole=null,this._targetRole=null,this._onGoingPostconditions=new a}get interaction(){return this._interaction}get roles(){return this._roles}get map(){return this._map}get isInteractionEnded(){return this._deliverer.isFinished&&this._effect.isNull}get location(){return this._map.getUbication(this._roles.get(this._interaction.rolesDescriptor.main))}get postconditions(){return this._onGoingPostconditions.join(this._interaction.postconditions(this._table,this._roles,this._map)),this._onGoingPostconditions}performStep(t){return this.initializeDeliverer(),this._effect.isNull?t.isVoid?(this._actualPhrase=this._deliverer.deliver(this._roles),this.forcePhraseRelations(this._actualPhrase.performerRole,this._actualPhrase.targetRole),this._roles.get(this._actualPhrase.performerRole).IsHuman&&this._actualPhrase.isMultialternative?b.fromChoices(this._actualPhrase.allAlternatives(this._roles).map(t=>this._roles.assignRoles(t))):this.executePhraseAction(t)):this.executePhraseAction(t):this.calculateAgentsReactions()}initializeDeliverer(){null==this._deliverer&&(this._deliverer=this._interaction.deliverer)}forcePhraseRelations(t,e){null!=e&&""!==e.trim()&&(this._roles.get(t).Relations.get(this._roles.get(e).Name),this._roles.get(e).Relations.get(this._roles.get(t).Name))}executePhraseAction(t){let e=this._actualPhrase.action(this._roles,new N(this.location.agents),t.choiceIndex);return this._effect=e.effect,this._performerRole=this._actualPhrase.performerRole,this._targetRole=this._actualPhrase.targetRole,e.hasSentence&&!this._onGoingPostconditions.exists(e.sentence)&&this._onGoingPostconditions.add(e.sentence),b.fromContent(e.content,this.isInteractionEnded)}calculateAgentsReactions(){let r=new s;if(this._effect.direction!=e.Neutral){var o=this._effect.isTargeted?new i(this._roles.get(this._performerRole),this._roles.get(this._effect.target),this._interaction.isIntimate?this._effect.isThirdPerson?[this._roles.get(this._targetRole)]:[]:this.location.agents.filter(t=>t.Name!==this._roles.get(this._effect.target).Name&&t.Name!==this._roles.get(this._performerRole).Name)):new i(this._roles.get(this._performerRole),null,this.location.agents.filter(t=>t.Name!==this._roles.get(this._performerRole).Name));r.append(n(this._effect,o,this._interaction.isIntimate))}return this._effect=t.null(),b.fromReactions(r,this.isInteractionEnded)}equals(t){return this._interaction.equals(t.interaction)&&this._roles.equals(t.roles)}toString(){return this._roles.assignRoles(this._interaction.description)}}class M{constructor(){this._executions=void 0,this._executions=[]}add(t,e){if(null==t)throw new Error("Agent cannot be null.");if(null==e)throw new Error("On going interaction cannot be null.");this._executions.push({agent:t,ongoing:e})}hasExecutedInteraction(t){return this._executions.some(e=>e.ongoing.interaction.equals(t))}hasExecutedOnGoingInteraction(t){return this._executions.some(e=>e.ongoing.equals(t))}}class G{constructor(){this._conditions=void 0,this._conditions=[]}with(t){if(null==t)throw new Error("Condition cannot be null");return this._conditions.push(t),this}allMet(t){return this._conditions.every(e=>e(t))}}class F{constructor(){this._scenarios=void 0,this._lastScenario=void 0,this._scenarios=[],this._lastScenario=null}get currentScenario(){let t=this._scenarios.filter(t=>!t.isFinished);return 0===t.length?null:(null===this._lastScenario?this._lastScenario=t[0]:this._lastScenario.name!==t[0].name&&t[0].isInheritor&&t[0].postconditions.join(this._lastScenario.postconditions),t[0])}add(t){if(null==t)throw new Error("Scenario cannot be null.");this._scenarios.push(t)}}const k="0",q="1";class O{get thereIsCurrentInteraction(){return null!=this._currentInteraction}constructor(t,e,i,n,s,r=null){if(this._interactions=void 0,this._finishingConditions=void 0,this._globalPostconditions=void 0,this._onTurnPassed=void 0,this._currentInteraction=void 0,this._selectableInteractions=void 0,this._interactor=void 0,this._name=void 0,this._map=void 0,this._agents=void 0,this._historic=void 0,this._isFinished=void 0,this._turn=void 0,this._isInheritor=void 0,null==t||""===t.trim())throw new Error("Name cannot be empty.");if(null==e)throw new Error("Map cannot be null.");if(null==i)throw new Error("Agents cannot be null.");if(null==n)throw new Error("Interactions cannot be null.");if(null==s)throw new Error("FinishingConditions cannot be null.");this._name=t,this._map=e,this._agents=i,this._interactions=n,this._finishingConditions=s,this._onTurnPassed=null==r?(t,e)=>"":r,this._isFinished=!1,this._selectableInteractions=[],this._interactor=null,this._historic=new M,this._globalPostconditions=new a,this._turn=0,this._isInheritor=!1}get name(){return this._name}get map(){return this._map}get agents(){return this._agents}get interactions(){return this._interactions}get historic(){return this._historic}get isFinished(){return this._isFinished}get turn(){return this._turn}get isInheritor(){return this._isInheritor}get postconditions(){return this._globalPostconditions}inheritor(){return this._isInheritor=!0,this}performStep(t){return this.thereIsCurrentInteraction?this.performCurrentInteractionStep(t):t.isVoid?this.performIAInteraction():this.performHumanInteraction(t.choiceIndex)}performIAInteraction(){if(this._finishingConditions.allMet(this))return this._isFinished=!0,b.fromContent("0");let t=this.getNextAgentWithInteractions();null==t.agent&&(t=this.getNextAgentWithInteractionsAll());let e=t.agent,i=t.possibleInteractions;return null==e?(this._isFinished=!0,b.fromContent("1")):e.IsHuman?(this._interactor=e,this._selectableInteractions=i,1===this._selectableInteractions.length?(this._currentInteraction=this._selectableInteractions[0],this._historic.add(e,this._currentInteraction),this.performCurrentInteractionStep(u.void())):b.fromChoices(this._selectableInteractions.map(t=>t.toString()))):(this._currentInteraction=g(i),this._historic.add(e,this._currentInteraction),this.performCurrentInteractionStep(u.void()))}getNextAgentWithInteractions(){let t=null,e=null,i=0;for(;null==t&&i<=this._agents.count;){let n=this._agents.popRandomAgent();i++,e=this.calculateAllAvailableInteractions(n,this._agents.allExcept(n)),e.length>0&&(t=n)}return{agent:t,possibleInteractions:e}}getNextAgentWithInteractionsAll(){let t=null,e=null;for(const i of this._agents.all)if(e=this.calculateAllAvailableInteractions(i,this._agents.allExcept(i)),e.length>0){t=i;break}return{agent:t,possibleInteractions:e}}calculateAllAvailableInteractions(t,e){let i=[];for(let n of this._interactions){if(n.timing===d.GlobalSingle&&this._historic.hasExecutedInteraction(n))continue;let s=n.getPermutations(t,e);for(let t of s)if(n.preconditions(this._globalPostconditions,t,this._map)){let e=new T(n,t,this._map,this._globalPostconditions);n.timing!==d.Repeteable&&this._historic.hasExecutedOnGoingInteraction(e)||i.push(e)}}return i}performCurrentInteractionStep(t){let e=this._currentInteraction.performStep(t);if(e.isEnder){let t=this._currentInteraction.postconditions;if(this._globalPostconditions.join(t)){let e=this._currentInteraction.interaction.isIntimate?this._currentInteraction.roles.agents:this._currentInteraction.location.agents;for(let i of e)i.logic.rules.elements.length>0&&h(i.logic.rules,i.logic.population,i.logic.table,t.elements)}this._currentInteraction=null;for(let t of this.passTurn())e.append(t)}return e}performHumanInteraction(t){return this._currentInteraction=this._selectableInteractions[t],this._historic.add(this._interactor,this._currentInteraction),this.performCurrentInteractionStep(u.void())}passTurn(){this._turn++;let t=[this._onTurnPassed(this._turn,this)];for(let e of this._agents.all.map(t=>t.OnTurnPassed(this._turn,t)))t.push(e);return t}}export{E as Agent,P as Agents,f as Alternative,H as BaseInteraction,A as Characteristics,I as Choices,N as Crowd,C as Deliverer,y as Desire,R as Desires,G as FinishingConditions,M as HistoricInteractions,u as Input,D as Interaction,x as Location,S as MapStructure,T as OnGoingInteraction,p as Phrase,m as PhraseResult,w as Roles,v as RolesDescriptor,O as Scenario,k as ScenarioEndAllConditionsMet,q as ScenarioEndNoInteractions,b as Step,d as Timing,F as World}; //# sourceMappingURL=index.modern.js.map