Class: Evolvable::EqualizeGoal
- Defined in:
- lib/evolvable/equalize_goal.rb
Overview
Prioritizes instances that equal the goal value.
The default goal value is 0
, but it can be reassigned to any numeric value.
Direct Known Subclasses
Instance Method Summary collapse
Methods inherited from Goal
Constructor Details
This class inherits a constructor from Evolvable::Goal
Instance Method Details
#evaluate(evolvable) ⇒ Object
14 15 16 |
# File 'lib/evolvable/equalize_goal.rb', line 14 def evaluate(evolvable) -(evolvable.value - value).abs end |
#met?(evolvable) ⇒ Boolean
18 19 20 |
# File 'lib/evolvable/equalize_goal.rb', line 18 def met?(evolvable) evolvable.value == value end |
#value ⇒ Object
10 11 12 |
# File 'lib/evolvable/equalize_goal.rb', line 10 def value @value ||= 0 end |