Class: Legion::Extensions::Agentic::Integration::Tessellation::Helpers::Tile
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Integration::Tessellation::Helpers::Tile
show all
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb
Constant Summary
Constants included
from Constants
Constants::COVERAGE_DECAY, Constants::COVERAGE_GROWTH, Constants::COVERAGE_LABELS, Constants::DEFAULT_COVERAGE, Constants::DENSITY_LABELS, Constants::DOMAINS, Constants::FIT_LABELS, Constants::FIT_TOLERANCE, Constants::FULL_COVERAGE_THRESHOLD, Constants::GAP_THRESHOLD, Constants::MAX_MOSAICS, Constants::MAX_TILES, Constants::OVERLAP_PENALTY, Constants::OVERLAP_THRESHOLD, Constants::TILE_SHAPES, Constants::TILE_TYPES
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Constants
label_for
Constructor Details
#initialize(tile_type:, shape:, domain:, coverage: nil, fit_score: nil) ⇒ Tile
Returns a new instance of Tile.
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 15
def initialize(tile_type:, shape:, domain:, coverage: nil, fit_score: nil)
@id = SecureRandom.uuid
@tile_type = tile_type.to_sym
@shape = shape.to_sym
@domain = domain.to_sym
@coverage = (coverage || DEFAULT_COVERAGE).to_f.clamp(0.0, 1.0)
@fit_score = (fit_score || 0.5).to_f.clamp(0.0, 1.0)
@adjacent_ids = []
@created_at = Time.now.utc
end
|
Instance Attribute Details
#adjacent_ids ⇒ Object
Returns the value of attribute adjacent_ids.
12
13
14
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 12
def adjacent_ids
@adjacent_ids
end
|
#coverage ⇒ Object
Returns the value of attribute coverage.
12
13
14
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 12
def coverage
@coverage
end
|
#created_at ⇒ Object
Returns the value of attribute created_at.
12
13
14
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 12
def created_at
@created_at
end
|
#domain ⇒ Object
Returns the value of attribute domain.
12
13
14
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 12
def domain
@domain
end
|
#fit_score ⇒ Object
Returns the value of attribute fit_score.
12
13
14
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 12
def fit_score
@fit_score
end
|
#id ⇒ Object
Returns the value of attribute id.
12
13
14
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 12
def id
@id
end
|
#shape ⇒ Object
Returns the value of attribute shape.
12
13
14
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 12
def shape
@shape
end
|
#tile_type ⇒ Object
Returns the value of attribute tile_type.
12
13
14
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 12
def tile_type
@tile_type
end
|
Instance Method Details
#adjust_fit!(new_fit) ⇒ Object
34
35
36
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 34
def adjust_fit!(new_fit)
@fit_score = new_fit.to_f.clamp(0.0, 1.0).round(10)
end
|
#connect!(other_id) ⇒ Object
38
39
40
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 38
def connect!(other_id)
@adjacent_ids << other_id unless @adjacent_ids.include?(other_id)
end
|
#effective_coverage ⇒ Object
49
50
51
52
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 49
def effective_coverage
penalty = overlapping? ? OVERLAP_PENALTY * @adjacent_ids.size : 0.0
(@coverage - penalty).clamp(0.0, 1.0).round(10)
end
|
#expand!(amount = COVERAGE_GROWTH) ⇒ Object
26
27
28
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 26
def expand!(amount = COVERAGE_GROWTH)
@coverage = (@coverage + amount).clamp(0.0, 1.0).round(10)
end
|
#full_coverage? ⇒ Boolean
42
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 42
def full_coverage? = @coverage >= FULL_COVERAGE_THRESHOLD
|
#gapped? ⇒ Boolean
43
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 43
def gapped? = @fit_score < GAP_THRESHOLD
|
#isolated? ⇒ Boolean
45
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 45
def isolated? = @adjacent_ids.empty?
|
#overlapping? ⇒ Boolean
44
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 44
def overlapping? = @fit_score > OVERLAP_THRESHOLD && @adjacent_ids.size > 3
|
#seamless? ⇒ Boolean
47
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 47
def seamless? = @fit_score >= 0.8
|
#shrink!(amount = COVERAGE_DECAY) ⇒ Object
30
31
32
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 30
def shrink!(amount = COVERAGE_DECAY)
@coverage = (@coverage - amount).clamp(0.0, 1.0).round(10)
end
|
#to_h ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 54
def to_h
{
id: @id,
tile_type: @tile_type,
shape: @shape,
domain: @domain,
coverage: @coverage.round(10),
fit_score: @fit_score.round(10),
effective_coverage: effective_coverage,
adjacent_count: @adjacent_ids.size,
full_coverage: full_coverage?,
gapped: gapped?,
seamless: seamless?,
created_at: @created_at.iso8601
}
end
|
#well_connected? ⇒ Boolean
46
|
# File 'lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb', line 46
def well_connected? = @adjacent_ids.size >= 3
|