Module: Legion::Extensions::Agentic::Affect::Mood::Runners::Mood
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/affect/mood/runners/mood.rb
Instance Method Summary collapse
- #current_mood ⇒ Object
- #mood_history(limit: 20) ⇒ Object
- #mood_modulation(parameter:) ⇒ Object
- #mood_stats ⇒ Object
- #update_mood(tick_results: {}) ⇒ Object
Instance Method Details
#current_mood ⇒ Object
30 31 32 33 |
# File 'lib/legion/extensions/agentic/affect/mood/runners/mood.rb', line 30 def current_mood(**) log.debug("[mood] query: #{mood_state.current_mood}") mood_state.to_h end |
#mood_history(limit: 20) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/legion/extensions/agentic/affect/mood/runners/mood.rb', line 48 def mood_history(limit: 20, **) history = mood_state.history.last(limit) { entries: history.map { |h| { mood: h[:mood], valence: h[:valence], arousal: h[:arousal], at: h[:at] } }, trend: mood_state.mood_trend(window: limit), count: history.size } end |
#mood_modulation(parameter:) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/legion/extensions/agentic/affect/mood/runners/mood.rb', line 35 def mood_modulation(parameter:, **) mods = mood_state.modulations value = mods[parameter.to_sym] log.debug("[mood] modulation: #{parameter}=#{value} (mood=#{mood_state.current_mood})") { parameter: parameter.to_sym, modulation: value || 0.0, current_mood: mood_state.current_mood } end |
#mood_stats ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/legion/extensions/agentic/affect/mood/runners/mood.rb', line 57 def mood_stats(**) history = mood_state.history mood_counts = Hash.new(0) history.each { |h| mood_counts[h[:mood]] += 1 } dominant = mood_counts.max_by { |_, v| v }&.first { current_mood: mood_state.current_mood, stability: mood_state.stability, duration: mood_state.duration_in_current_mood, trend: mood_state.mood_trend, dominant_mood: dominant, mood_distribution: mood_counts, ticks_processed: mood_state.tick_counter } end |
#update_mood(tick_results: {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/legion/extensions/agentic/affect/mood/runners/mood.rb', line 13 def update_mood(tick_results: {}, **) inputs = extract_mood_inputs(tick_results) mood_state.update(inputs) log.debug("[mood] #{mood_state.current_mood} (v=#{mood_state.valence.round(2)} " \ "a=#{mood_state.arousal.round(2)} e=#{mood_state.energy.round(2)})") { mood: mood_state.current_mood, valence: mood_state.valence, arousal: mood_state.arousal, energy: mood_state.energy, stability: mood_state.stability, modulations: mood_state.modulations } end |