Class: Legion::Extensions::Agentic::Attention::Kaleidoscope::Helpers::Pattern
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Attention::Kaleidoscope::Helpers::Pattern
- Defined in:
- lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb
Instance Attribute Summary collapse
-
#complexity ⇒ Object
Returns the value of attribute complexity.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#facet_ids ⇒ Object
readonly
Returns the value of attribute facet_ids.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#stability ⇒ Object
Returns the value of attribute stability.
-
#symmetry ⇒ Object
readonly
Returns the value of attribute symmetry.
Instance Method Summary collapse
- #add_facet(facet_id) ⇒ Object
- #chaotic? ⇒ Boolean
- #complexity_label ⇒ Object
- #destabilize!(rate: 0.05) ⇒ Object
- #facet_count ⇒ Object
- #fractal? ⇒ Boolean
-
#initialize(symmetry: :radial, complexity: nil, stability: nil) ⇒ Pattern
constructor
A new instance of Pattern.
- #minimal? ⇒ Boolean
- #remove_facet(facet_id) ⇒ Object
- #rotate_all!(degrees: Constants::ROTATION_STEP * 360) ⇒ Object
- #stabilize!(rate: 0.1) ⇒ Object
- #stable? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(symmetry: :radial, complexity: nil, stability: nil) ⇒ Pattern
Returns a new instance of Pattern.
13 14 15 16 17 18 19 20 21 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 13 def initialize(symmetry: :radial, complexity: nil, stability: nil) validate_symmetry!(symmetry) @id = SecureRandom.uuid @symmetry = symmetry.to_sym @complexity = (complexity || 0.5).to_f.clamp(0.0, 1.0).round(10) @stability = (stability || 0.7).to_f.clamp(0.0, 1.0).round(10) @facet_ids = [] @created_at = Time.now.utc end |
Instance Attribute Details
#complexity ⇒ Object
Returns the value of attribute complexity.
11 12 13 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 11 def complexity @complexity end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 10 def created_at @created_at end |
#facet_ids ⇒ Object (readonly)
Returns the value of attribute facet_ids.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 10 def facet_ids @facet_ids end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 10 def id @id end |
#stability ⇒ Object
Returns the value of attribute stability.
11 12 13 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 11 def stability @stability end |
#symmetry ⇒ Object (readonly)
Returns the value of attribute symmetry.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 10 def symmetry @symmetry end |
Instance Method Details
#add_facet(facet_id) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 23 def add_facet(facet_id) return :already_present if @facet_ids.include?(facet_id) @facet_ids << facet_id recalculate_complexity! :added end |
#chaotic? ⇒ Boolean
64 65 66 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 64 def chaotic? @stability < 0.3 end |
#complexity_label ⇒ Object
68 69 70 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 68 def complexity_label Constants.label_for(Constants::COMPLEXITY_LABELS, @complexity) end |
#destabilize!(rate: 0.05) ⇒ Object
48 49 50 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 48 def destabilize!(rate: 0.05) @stability = (@stability - rate.abs).clamp(0.0, 1.0).round(10) end |
#facet_count ⇒ Object
72 73 74 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 72 def facet_count @facet_ids.size end |
#fractal? ⇒ Boolean
52 53 54 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 52 def fractal? @complexity >= 0.8 end |
#minimal? ⇒ Boolean
56 57 58 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 56 def minimal? @complexity < 0.2 end |
#remove_facet(facet_id) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 31 def remove_facet(facet_id) return :not_found unless @facet_ids.include?(facet_id) @facet_ids.delete(facet_id) recalculate_complexity! :removed end |
#rotate_all!(degrees: Constants::ROTATION_STEP * 360) ⇒ Object
39 40 41 42 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 39 def rotate_all!(degrees: Constants::ROTATION_STEP * 360) @stability = (@stability - (degrees.abs / 3600.0)).clamp(0.0, 1.0).round(10) degrees end |
#stabilize!(rate: 0.1) ⇒ Object
44 45 46 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 44 def stabilize!(rate: 0.1) @stability = (@stability + rate.abs).clamp(0.0, 1.0).round(10) end |
#stable? ⇒ Boolean
60 61 62 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 60 def stable? @stability >= 0.7 end |
#to_h ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/pattern.rb', line 76 def to_h { id: @id, symmetry: @symmetry, complexity: @complexity, stability: @stability, complexity_label: complexity_label, facet_count: facet_count, fractal: fractal?, chaotic: chaotic?, created_at: @created_at } end |