Class: Legion::Extensions::Agentic::Homeostasis::Tectonics::Helpers::BeliefPlate
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Homeostasis::Tectonics::Helpers::BeliefPlate
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb
Constant Summary
Constants included from Constants
Constants::AFTERSHOCK_DECAY, Constants::BOUNDARY_TYPES, Constants::COLLISION_THRESHOLD, Constants::MAGNITUDE_LABELS, Constants::MAX_DRIFT_RATE, Constants::MAX_PLATES, Constants::MAX_QUAKES, Constants::MIN_DRIFT_RATE, Constants::PLATE_STATES, Constants::STRESS_QUAKE_TRIGGER, Constants::SUBDUCTION_RATIO
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#drift_vector ⇒ Object
Returns the value of attribute drift_vector.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mass ⇒ Object
Returns the value of attribute mass.
-
#position ⇒ Object
Returns the value of attribute position.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#stress_accumulation ⇒ Object
Returns the value of attribute stress_accumulation.
-
#velocity ⇒ Object
Returns the value of attribute velocity.
Instance Method Summary collapse
- #accumulate_stress!(amount) ⇒ Object
- #active? ⇒ Boolean
- #distance_to(other_plate) ⇒ Object
- #dormant! ⇒ Object
- #drift!(delta_t = 1.0) ⇒ Object
-
#initialize(domain:, content:, mass: 0.5, drift_vector: nil, position: nil) ⇒ BeliefPlate
constructor
A new instance of BeliefPlate.
- #release_stress! ⇒ Object
- #subduct! ⇒ Object
- #subducted? ⇒ Boolean
- #to_h ⇒ Object
Methods included from Constants
Constructor Details
#initialize(domain:, content:, mass: 0.5, drift_vector: nil, position: nil) ⇒ BeliefPlate
Returns a new instance of BeliefPlate.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 17 def initialize(domain:, content:, mass: 0.5, drift_vector: nil, position: nil, **) @id = SecureRandom.uuid @domain = domain @content = content @mass = mass.clamp(0.0, 1.0) @drift_vector = drift_vector || { x: 0.0, y: 0.0 } @position = position || { x: rand(-10.0..10.0).round(10), y: rand(-10.0..10.0).round(10) } @velocity = { x: 0.0, y: 0.0 } @stress_accumulation = 0.0 @state = :active @created_at = Time.now.utc end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
14 15 16 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 14 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 14 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 14 def domain @domain end |
#drift_vector ⇒ Object
Returns the value of attribute drift_vector.
15 16 17 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 15 def drift_vector @drift_vector end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 14 def id @id end |
#mass ⇒ Object
Returns the value of attribute mass.
15 16 17 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 15 def mass @mass end |
#position ⇒ Object
Returns the value of attribute position.
15 16 17 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 15 def position @position end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
14 15 16 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 14 def state @state end |
#stress_accumulation ⇒ Object
Returns the value of attribute stress_accumulation.
15 16 17 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 15 def stress_accumulation @stress_accumulation end |
#velocity ⇒ Object
Returns the value of attribute velocity.
15 16 17 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 15 def velocity @velocity end |
Instance Method Details
#accumulate_stress!(amount) ⇒ Object
37 38 39 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 37 def accumulate_stress!(amount) @stress_accumulation = (@stress_accumulation + amount.abs).round(10) end |
#active? ⇒ Boolean
59 60 61 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 59 def active? @state == :active end |
#distance_to(other_plate) ⇒ Object
63 64 65 66 67 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 63 def distance_to(other_plate) dx = @position[:x] - other_plate.position[:x] dy = @position[:y] - other_plate.position[:y] Math.sqrt((dx**2) + (dy**2)).round(10) end |
#dormant! ⇒ Object
55 56 57 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 55 def dormant! @state = :dormant end |
#drift!(delta_t = 1.0) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 30 def drift!(delta_t = 1.0) return if @state != :active @position[:x] = (@position[:x] + (@drift_vector.fetch(:x, 0.0) * delta_t)).round(10) @position[:y] = (@position[:y] + (@drift_vector.fetch(:y, 0.0) * delta_t)).round(10) end |
#release_stress! ⇒ Object
41 42 43 44 45 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 41 def release_stress! released = @stress_accumulation @stress_accumulation = 0.0 released end |
#subduct! ⇒ Object
51 52 53 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 51 def subduct! @state = :subducted end |
#subducted? ⇒ Boolean
47 48 49 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 47 def subducted? @mass < Constants::SUBDUCTION_RATIO end |
#to_h ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb', line 69 def to_h { id: @id, domain: @domain, content: @content, mass: @mass, drift_vector: @drift_vector, position: @position, velocity: @velocity, stress_accumulation: @stress_accumulation, state: @state, created_at: @created_at } end |