Class: Legion::Extensions::Agentic::Attention::Kaleidoscope::Helpers::KaleidoscopeEngine
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Attention::Kaleidoscope::Helpers::KaleidoscopeEngine
- Defined in:
- lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb
Instance Method Summary collapse
- #add_facet_to_pattern(facet_id:, pattern_id:) ⇒ Object
- #all_facets ⇒ Object
- #all_patterns ⇒ Object
- #avg_brilliance ⇒ Object
- #avg_complexity ⇒ Object
- #brightest(limit: 5) ⇒ Object
- #create_facet(facet_type:, domain:, content:, brilliance: nil, transparency: nil, angle: nil) ⇒ Object
- #create_pattern(symmetry: :radial, complexity: nil, stability: nil) ⇒ Object
- #dark_facets ⇒ Object
- #dazzling_facets ⇒ Object
- #dimmest(limit: 5) ⇒ Object
- #facets_by_type ⇒ Object
-
#initialize ⇒ KaleidoscopeEngine
constructor
A new instance of KaleidoscopeEngine.
- #kaleidoscope_report ⇒ Object
- #most_complex_patterns(limit: 5) ⇒ Object
- #most_stable_patterns(limit: 5) ⇒ Object
- #polish_facet(facet_id:, rate: 0.1) ⇒ Object
- #rotate_facet(facet_id:, degrees: Constants::ROTATION_STEP * 360) ⇒ Object
- #rotate_pattern(pattern_id:, degrees: Constants::ROTATION_STEP * 360) ⇒ Object
- #tarnish_all! ⇒ Object
Constructor Details
#initialize ⇒ KaleidoscopeEngine
Returns a new instance of KaleidoscopeEngine.
10 11 12 13 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 10 def initialize @facets = {} @patterns = {} end |
Instance Method Details
#add_facet_to_pattern(facet_id:, pattern_id:) ⇒ Object
32 33 34 35 36 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 32 def add_facet_to_pattern(facet_id:, pattern_id:) fetch_facet(facet_id) pattern = fetch_pattern(pattern_id) pattern.add_facet(facet_id) end |
#all_facets ⇒ Object
115 116 117 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 115 def all_facets @facets.values end |
#all_patterns ⇒ Object
119 120 121 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 119 def all_patterns @patterns.values end |
#avg_brilliance ⇒ Object
91 92 93 94 95 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 91 def avg_brilliance return 0.0 if @facets.empty? (@facets.values.sum(&:brilliance) / @facets.size).round(10) end |
#avg_complexity ⇒ Object
97 98 99 100 101 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 97 def avg_complexity return 0.0 if @patterns.empty? (@patterns.values.sum(&:complexity) / @patterns.size).round(10) end |
#brightest(limit: 5) ⇒ Object
67 68 69 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 67 def brightest(limit: 5) @facets.values.sort_by { |f| -f.brilliance }.first(limit) end |
#create_facet(facet_type:, domain:, content:, brilliance: nil, transparency: nil, angle: nil) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 15 def create_facet(facet_type:, domain:, content:, brilliance: nil, transparency: nil, angle: nil) raise ArgumentError, 'facet limit reached' if @facets.size >= Constants::MAX_FACETS f = Facet.new(facet_type: facet_type, domain: domain, content: content, brilliance: brilliance, transparency: transparency, angle: angle) @facets[f.id] = f f end |
#create_pattern(symmetry: :radial, complexity: nil, stability: nil) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 24 def create_pattern(symmetry: :radial, complexity: nil, stability: nil) raise ArgumentError, 'pattern limit reached' if @patterns.size >= Constants::MAX_PATTERNS p = Pattern.new(symmetry: symmetry, complexity: complexity, stability: stability) @patterns[p.id] = p p end |
#dark_facets ⇒ Object
87 88 89 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 87 def dark_facets @facets.values.select(&:dark?) end |
#dazzling_facets ⇒ Object
83 84 85 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 83 def dazzling_facets @facets.values.select(&:dazzling?) end |
#dimmest(limit: 5) ⇒ Object
71 72 73 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 71 def dimmest(limit: 5) @facets.values.sort_by(&:brilliance).first(limit) end |
#facets_by_type ⇒ Object
61 62 63 64 65 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 61 def facets_by_type counts = Constants::FACET_TYPES.to_h { |t| [t, 0] } @facets.each_value { |f| counts[f.facet_type] += 1 } counts end |
#kaleidoscope_report ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 103 def kaleidoscope_report { total_facets: @facets.size, total_patterns: @patterns.size, by_type: facets_by_type, dazzling_count: dazzling_facets.size, dark_count: dark_facets.size, avg_brilliance: avg_brilliance, avg_complexity: avg_complexity } end |
#most_complex_patterns(limit: 5) ⇒ Object
75 76 77 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 75 def most_complex_patterns(limit: 5) @patterns.values.sort_by { |p| -p.complexity }.first(limit) end |
#most_stable_patterns(limit: 5) ⇒ Object
79 80 81 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 79 def most_stable_patterns(limit: 5) @patterns.values.sort_by { |p| -p.stability }.first(limit) end |
#polish_facet(facet_id:, rate: 0.1) ⇒ Object
44 45 46 47 48 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 44 def polish_facet(facet_id:, rate: 0.1) facet = fetch_facet(facet_id) facet.polish!(rate: rate) facet end |
#rotate_facet(facet_id:, degrees: Constants::ROTATION_STEP * 360) ⇒ Object
38 39 40 41 42 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 38 def rotate_facet(facet_id:, degrees: Constants::ROTATION_STEP * 360) facet = fetch_facet(facet_id) facet.rotate!(degrees: degrees) facet end |
#rotate_pattern(pattern_id:, degrees: Constants::ROTATION_STEP * 360) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 50 def rotate_pattern(pattern_id:, degrees: Constants::ROTATION_STEP * 360) pattern = fetch_pattern(pattern_id) pattern.rotate_all!(degrees: degrees) resolve_facets(pattern).each { |f| f.rotate!(degrees: degrees) } pattern end |
#tarnish_all! ⇒ Object
57 58 59 |
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/kaleidoscope_engine.rb', line 57 def tarnish_all! @facets.each_value(&:tarnish!) end |