class Fable::StatePatch

Attributes

changed_variables[RW]
globals[RW]
turn_indicies[RW]
visit_counts[RW]

Public Class Methods

new(state_patch_to_copy = nil) click to toggle source
# File lib/fable/state_patch.rb, line 5
def initialize(state_patch_to_copy = nil)
  if state_patch_to_copy.nil?
    self.globals = {}
    self.changed_variables = Set.new
    self.visit_counts = {}
    self.turn_indicies = {}
  else
    self.globals = Hash[state_patch_to_copy.globals]
    self.changed_variables = state_patch_to_copy.changed_variables.dup
    self.visit_counts = Hash[state_patch_to_copy.visit_counts]
    self.turn_indicies = Hash[state_patch_to_copy.turn_indicies]
  end
end

Public Instance Methods

add_changed_variable(name) click to toggle source
# File lib/fable/state_patch.rb, line 27
def add_changed_variable(name)
  self.changed_variables << name
end
get_global(name) click to toggle source
# File lib/fable/state_patch.rb, line 19
def get_global(name)
  return self.globals[name]
end
get_turn_index(container) click to toggle source
# File lib/fable/state_patch.rb, line 43
def get_turn_index(container)
  self.turn_indicies[container]
end
get_visit_count(container) click to toggle source
# File lib/fable/state_patch.rb, line 31
def get_visit_count(container)
  self.visit_counts[container]
end
set_global(name, value) click to toggle source
# File lib/fable/state_patch.rb, line 23
def set_global(name, value)
  self.globals[name] = value
end
set_turn_index(container, count) click to toggle source
# File lib/fable/state_patch.rb, line 39
def set_turn_index(container, count)
  self.turn_indicies[container] = count
end
set_visit_count(container, count) click to toggle source
# File lib/fable/state_patch.rb, line 35
def set_visit_count(container, count)
  self.visit_counts[container] = count
end