Class: Legion::Extensions::Agentic::Self::DefaultModeNetwork::Helpers::WanderingThought
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Self::DefaultModeNetwork::Helpers::WanderingThought
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb
Constant Summary
Constants included from Constants
Constants::ACTIVITY_LABELS, Constants::DEEP_IDLE_THRESHOLD, Constants::DEFAULT_SALIENCE, Constants::IDLE_THRESHOLD, Constants::MAX_ASSOCIATION_CHAIN, Constants::MAX_THOUGHT_HISTORY, Constants::MAX_WANDERING_THOUGHTS, Constants::PLANNING_PROBABILITY, Constants::SALIENCE_ALPHA, Constants::SALIENCE_LABELS, Constants::SELF_REFERENTIAL_PROBABILITY, Constants::SOCIAL_REPLAY_PROBABILITY, Constants::THOUGHT_DECAY, Constants::THOUGHT_SALIENCE_FLOOR, Constants::WANDERING_PROBABILITY
Instance Attribute Summary collapse
-
#association_chain ⇒ Object
readonly
Returns the value of attribute association_chain.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#salience ⇒ Object
Returns the value of attribute salience.
-
#seed ⇒ Object
readonly
Returns the value of attribute seed.
-
#thought_type ⇒ Object
readonly
Returns the value of attribute thought_type.
Instance Method Summary collapse
- #boost_salience(amount = Constants::SALIENCE_ALPHA) ⇒ Object
- #decay ⇒ Object
- #faded? ⇒ Boolean
-
#initialize(seed:, association_chain:, domain:, thought_type:, salience: Constants::DEFAULT_SALIENCE) ⇒ WanderingThought
constructor
A new instance of WanderingThought.
- #label ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(seed:, association_chain:, domain:, thought_type:, salience: Constants::DEFAULT_SALIENCE) ⇒ WanderingThought
Returns a new instance of WanderingThought.
15 16 17 18 19 20 21 22 23 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 15 def initialize(seed:, association_chain:, domain:, thought_type:, salience: Constants::DEFAULT_SALIENCE) @id = SecureRandom.uuid @seed = seed @association_chain = Array(association_chain) @domain = domain @thought_type = thought_type.to_sym @salience = salience.to_f.clamp(0.0, 1.0) @created_at = Time.now.utc end |
Instance Attribute Details
#association_chain ⇒ Object (readonly)
Returns the value of attribute association_chain.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 12 def association_chain @association_chain end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 12 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 12 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 12 def id @id end |
#salience ⇒ Object
Returns the value of attribute salience.
13 14 15 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 13 def salience @salience end |
#seed ⇒ Object (readonly)
Returns the value of attribute seed.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 12 def seed @seed end |
#thought_type ⇒ Object (readonly)
Returns the value of attribute thought_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 12 def thought_type @thought_type end |
Instance Method Details
#boost_salience(amount = Constants::SALIENCE_ALPHA) ⇒ Object
25 26 27 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 25 def boost_salience(amount = Constants::SALIENCE_ALPHA) @salience = [@salience + amount.to_f, 1.0].min end |
#decay ⇒ Object
29 30 31 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 29 def decay @salience = [@salience - Constants::THOUGHT_DECAY, Constants::THOUGHT_SALIENCE_FLOOR].max end |
#faded? ⇒ Boolean
33 34 35 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 33 def faded? @salience <= Constants::THOUGHT_SALIENCE_FLOOR end |
#label ⇒ Object
37 38 39 40 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 37 def label Constants::SALIENCE_LABELS.each { |range, lbl| return lbl if range.cover?(@salience) } :fleeting end |
#to_h ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 42 def to_h { id: @id, seed: @seed, association_chain: @association_chain, domain: @domain, thought_type: @thought_type, salience: @salience.round(4), label: label, created_at: @created_at } end |