Class: Transition

Inherits:
Struct
  • Object
show all
Defined in:
lib/repositories/transition_graph.rb,
lib/repositories/transition_graph.rb

Overview

This is a unified concept of a transition. The TransitionGraph has a few utilities to search and infer a transition from other data types ( arrays and hashes for now).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#from_stateObject

Returns the value of attribute from_state

Returns:

  • (Object)

    the current value of from_state



4
5
6
# File 'lib/repositories/transition_graph.rb', line 4

def from_state
  @from_state
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/repositories/transition_graph.rb', line 4

def name
  @name
end

#probabilityObject

Returns the value of attribute probability

Returns:

  • (Object)

    the current value of probability



4
5
6
# File 'lib/repositories/transition_graph.rb', line 4

def probability
  @probability
end

#rewardObject

Returns the value of attribute reward

Returns:

  • (Object)

    the current value of reward



4
5
6
# File 'lib/repositories/transition_graph.rb', line 4

def reward
  @reward
end

#to_stateObject

Returns the value of attribute to_state

Returns:

  • (Object)

    the current value of to_state



4
5
6
# File 'lib/repositories/transition_graph.rb', line 4

def to_state
  @to_state
end

Instance Method Details

#update(obj) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/repositories/transition_graph.rb', line 6

def update(obj)
  case obj
  when Numeric
    if obj >= 0 and obj <= 1
      self.probability = obj
    else
      self.reward = obj
    end
  when Hash
    self.probability = obj[:probability] if obj[:probability]
    self.reward = obj[:reward] if obj[:reward]
  else
    self.reward = obj
  end
end