Class: Legion::Extensions::Agentic::Executive::Inhibition::Helpers::InhibitionModel
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Executive::Inhibition::Helpers::InhibitionModel
- Defined in:
- lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb
Instance Attribute Summary collapse
-
#failed_count ⇒ Object
readonly
Returns the value of attribute failed_count.
-
#inhibition_log ⇒ Object
readonly
Returns the value of attribute inhibition_log.
-
#redirected_count ⇒ Object
readonly
Returns the value of attribute redirected_count.
-
#suppressed_count ⇒ Object
readonly
Returns the value of attribute suppressed_count.
-
#willpower ⇒ Object
readonly
Returns the value of attribute willpower.
Instance Method Summary collapse
- #apply_strategy(impulse, strategy) ⇒ Object
- #delay_discount(reward_value, delay_ticks) ⇒ Object
- #evaluate_impulse(impulse) ⇒ Object
-
#initialize ⇒ InhibitionModel
constructor
A new instance of InhibitionModel.
- #recover_willpower ⇒ Object
- #stroop_conflict?(automatic_response, controlled_response) ⇒ Boolean
- #success_rate ⇒ Object
- #willpower_status ⇒ Object
Constructor Details
#initialize ⇒ InhibitionModel
Returns a new instance of InhibitionModel.
12 13 14 15 16 17 18 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 12 def initialize @willpower = 0.8 @inhibition_log = [] @suppressed_count = 0 @failed_count = 0 @redirected_count = 0 end |
Instance Attribute Details
#failed_count ⇒ Object (readonly)
Returns the value of attribute failed_count.
10 11 12 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 10 def failed_count @failed_count end |
#inhibition_log ⇒ Object (readonly)
Returns the value of attribute inhibition_log.
10 11 12 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 10 def inhibition_log @inhibition_log end |
#redirected_count ⇒ Object (readonly)
Returns the value of attribute redirected_count.
10 11 12 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 10 def redirected_count @redirected_count end |
#suppressed_count ⇒ Object (readonly)
Returns the value of attribute suppressed_count.
10 11 12 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 10 def suppressed_count @suppressed_count end |
#willpower ⇒ Object (readonly)
Returns the value of attribute willpower.
10 11 12 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 10 def willpower @willpower end |
Instance Method Details
#apply_strategy(impulse, strategy) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 30 def apply_strategy(impulse, strategy) deplete_willpower(impulse.strength) unless strategy == :auto_suppress case strategy when :failed @failed_count += 1 when :redirect @redirected_count += 1 @suppressed_count += 1 else @suppressed_count += 1 end entry = { impulse_id: impulse.id, type: impulse.type, action: impulse.action, strength: impulse.strength, strategy: strategy, willpower: @willpower.round(4), at: Time.now.utc } @inhibition_log << entry @inhibition_log.shift while @inhibition_log.size > Constants::MAX_INHIBITION_LOG entry end |
#delay_discount(reward_value, delay_ticks) ⇒ Object
80 81 82 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 80 def delay_discount(reward_value, delay_ticks) reward_value / (1.0 + (Constants::DELAY_DISCOUNT_RATE * delay_ticks)) end |
#evaluate_impulse(impulse) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 20 def evaluate_impulse(impulse) if impulse.auto_suppressible? :auto_suppress elsif @willpower < Constants::WILLPOWER_THRESHOLD :failed else select_strategy(impulse) end end |
#recover_willpower ⇒ Object
59 60 61 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 59 def recover_willpower @willpower = [@willpower + Constants::FATIGUE_RECOVERY_RATE, 1.0].min end |
#stroop_conflict?(automatic_response, controlled_response) ⇒ Boolean
84 85 86 87 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 84 def stroop_conflict?(automatic_response, controlled_response) automatic_response != controlled_response && automatic_strength(automatic_response) >= Constants::STROOP_CONFLICT_THRESHOLD end |
#success_rate ⇒ Object
73 74 75 76 77 78 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 73 def success_rate total = @suppressed_count + @failed_count return 1.0 if total.zero? @suppressed_count.to_f / total end |
#willpower_status ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_model.rb', line 63 def willpower_status if @willpower >= 0.6 :healthy elsif @willpower >= Constants::WILLPOWER_THRESHOLD :depleted else :exhausted end end |