Class: Legion::Extensions::Agentic::Affect::SomaticMarker::Helpers::BodyState
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Affect::SomaticMarker::Helpers::BodyState
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/affect/somatic_marker/helpers/body_state.rb
Constant Summary
Constants included from Constants
Constants::BODY_STATE_DECAY, Constants::DEFAULT_VALENCE, Constants::MARKER_ALPHA, Constants::MARKER_DECAY, Constants::MARKER_STRENGTH_FLOOR, Constants::MAX_BODY_STATES, Constants::MAX_DECISION_HISTORY, Constants::MAX_MARKERS, Constants::MAX_OPTIONS_PER_DECISION, Constants::NEGATIVE_BIAS, Constants::POSITIVE_BIAS, Constants::PUNISHMENT_PENALTY, Constants::REINFORCEMENT_BOOST, Constants::SIGNAL_LABELS, Constants::VALENCE_LABELS
Instance Attribute Summary collapse
-
#arousal ⇒ Object
readonly
Returns the value of attribute arousal.
-
#comfort ⇒ Object
readonly
Returns the value of attribute comfort.
-
#gut_signal ⇒ Object
readonly
Returns the value of attribute gut_signal.
-
#tension ⇒ Object
readonly
Returns the value of attribute tension.
Instance Method Summary collapse
- #composite_valence ⇒ Object
- #decay ⇒ Object
-
#initialize(arousal: 0.5, tension: 0.5, comfort: 0.5, gut_signal: 0.0) ⇒ BodyState
constructor
A new instance of BodyState.
- #stressed? ⇒ Boolean
- #to_h ⇒ Object
- #update(arousal: nil, tension: nil, comfort: nil, gut_signal: nil) ⇒ Object
Constructor Details
#initialize(arousal: 0.5, tension: 0.5, comfort: 0.5, gut_signal: 0.0) ⇒ BodyState
Returns a new instance of BodyState.
14 15 16 17 18 19 |
# File 'lib/legion/extensions/agentic/affect/somatic_marker/helpers/body_state.rb', line 14 def initialize(arousal: 0.5, tension: 0.5, comfort: 0.5, gut_signal: 0.0) @arousal = arousal.clamp(0.0, 1.0) @tension = tension.clamp(0.0, 1.0) @comfort = comfort.clamp(0.0, 1.0) @gut_signal = gut_signal.clamp(-1.0, 1.0) end |
Instance Attribute Details
#arousal ⇒ Object (readonly)
Returns the value of attribute arousal.
12 13 14 |
# File 'lib/legion/extensions/agentic/affect/somatic_marker/helpers/body_state.rb', line 12 def arousal @arousal end |
#comfort ⇒ Object (readonly)
Returns the value of attribute comfort.
12 13 14 |
# File 'lib/legion/extensions/agentic/affect/somatic_marker/helpers/body_state.rb', line 12 def comfort @comfort end |
#gut_signal ⇒ Object (readonly)
Returns the value of attribute gut_signal.
12 13 14 |
# File 'lib/legion/extensions/agentic/affect/somatic_marker/helpers/body_state.rb', line 12 def gut_signal @gut_signal end |
#tension ⇒ Object (readonly)
Returns the value of attribute tension.
12 13 14 |
# File 'lib/legion/extensions/agentic/affect/somatic_marker/helpers/body_state.rb', line 12 def tension @tension end |
Instance Method Details
#composite_valence ⇒ Object
28 29 30 |
# File 'lib/legion/extensions/agentic/affect/somatic_marker/helpers/body_state.rb', line 28 def composite_valence (@comfort * 0.4) + ((1.0 - @tension) * 0.3) + (@gut_signal * 0.3) end |
#decay ⇒ Object
32 33 34 35 36 37 |
# File 'lib/legion/extensions/agentic/affect/somatic_marker/helpers/body_state.rb', line 32 def decay @arousal = drift(@arousal, 0.5, BODY_STATE_DECAY) @tension = drift(@tension, 0.5, BODY_STATE_DECAY) @comfort = drift(@comfort, 0.5, BODY_STATE_DECAY) @gut_signal = drift(@gut_signal, 0.0, BODY_STATE_DECAY) end |
#stressed? ⇒ Boolean
39 40 41 |
# File 'lib/legion/extensions/agentic/affect/somatic_marker/helpers/body_state.rb', line 39 def stressed? @tension > 0.7 && @comfort < 0.3 end |
#to_h ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/legion/extensions/agentic/affect/somatic_marker/helpers/body_state.rb', line 43 def to_h { arousal: @arousal, tension: @tension, comfort: @comfort, gut_signal: @gut_signal, composite_valence: composite_valence, stressed: stressed? } end |
#update(arousal: nil, tension: nil, comfort: nil, gut_signal: nil) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/legion/extensions/agentic/affect/somatic_marker/helpers/body_state.rb', line 21 def update(arousal: nil, tension: nil, comfort: nil, gut_signal: nil) @arousal = arousal.clamp(0.0, 1.0) if arousal @tension = tension.clamp(0.0, 1.0) if tension @comfort = comfort.clamp(0.0, 1.0) if comfort @gut_signal = gut_signal.clamp(-1.0, 1.0) if gut_signal end |