Class: Legion::Extensions::Agentic::Affect::Interoception::Helpers::SomaticMarker
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Affect::Interoception::Helpers::SomaticMarker
- Defined in:
- lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#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.
-
#strength ⇒ Object
Returns the value of attribute strength.
-
#valence ⇒ Object
readonly
Returns the value of attribute valence.
Instance Method Summary collapse
- #bias_for(candidate_action) ⇒ Object
- #decay ⇒ Object
- #faded? ⇒ Boolean
-
#initialize(action:, domain:, valence:, strength: 1.0) ⇒ SomaticMarker
constructor
A new instance of SomaticMarker.
- #label ⇒ Object
- #negative? ⇒ Boolean
- #positive? ⇒ Boolean
- #reinforce(amount: 0.1) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(action:, domain:, valence:, strength: 1.0) ⇒ SomaticMarker
Returns a new instance of SomaticMarker.
13 14 15 16 17 18 19 20 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 13 def initialize(action:, domain:, valence:, strength: 1.0) @id = SecureRandom.uuid @action = action @domain = domain @valence = valence.clamp(-1.0, 1.0) @strength = strength.clamp(0.0, 1.0) @created_at = Time.now.utc end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
10 11 12 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 10 def action @action end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 10 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
10 11 12 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 10 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 10 def id @id end |
#strength ⇒ Object
Returns the value of attribute strength.
11 12 13 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 11 def strength @strength end |
#valence ⇒ Object (readonly)
Returns the value of attribute valence.
10 11 12 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 10 def valence @valence end |
Instance Method Details
#bias_for(candidate_action) ⇒ Object
22 23 24 25 26 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 22 def bias_for(candidate_action) return 0.0 unless candidate_action == @action @valence * @strength * Constants::MARKER_INFLUENCE end |
#decay ⇒ Object
32 33 34 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 32 def decay @strength = [@strength - Constants::MARKER_DECAY, Constants::MARKER_FLOOR].max end |
#faded? ⇒ Boolean
36 37 38 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 36 def faded? @strength <= Constants::MARKER_FLOOR end |
#label ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 48 def label if positive? :approach elsif negative? :avoid else :neutral end end |
#negative? ⇒ Boolean
44 45 46 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 44 def negative? @valence <= Constants::MARKER_NEGATIVE_THRESHOLD end |
#positive? ⇒ Boolean
40 41 42 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 40 def positive? @valence >= Constants::MARKER_POSITIVE_THRESHOLD end |
#reinforce(amount: 0.1) ⇒ Object
28 29 30 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 28 def reinforce(amount: 0.1) @strength = [@strength + amount, 1.0].min end |
#to_h ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/legion/extensions/agentic/affect/interoception/helpers/somatic_marker.rb', line 58 def to_h { id: @id, action: @action, domain: @domain, valence: @valence, strength: @strength, label: label, created_at: @created_at } end |