Class: Evolvable::EqualizeGoal

Inherits:
Goal
  • Object
show all
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

Goal::Equalize

Instance Method Summary collapse

Methods inherited from Goal

#initialize

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

Returns:

  • (Boolean)

18
19
20
# File 'lib/evolvable/equalize_goal.rb', line 18

def met?(evolvable)
  evolvable.value == value
end

#valueObject


10
11
12
# File 'lib/evolvable/equalize_goal.rb', line 10

def value
  @value ||= 0
end