Class: Planner::State
- Inherits:
-
Hash
- Object
- Hash
- Planner::State
- Defined in:
- lib/sfpagent/sfplanner.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id) ⇒ State
constructor
A new instance of State.
Constructor Details
#initialize(id) ⇒ State
241 242 243 |
# File 'lib/sfpagent/sfplanner.rb', line 241 def initialize(id) @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
211 212 213 |
# File 'lib/sfpagent/sfplanner.rb', line 211 def id @id end |
Class Method Details
.read(i, lines, variables) ⇒ Object
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/sfpagent/sfplanner.rb', line 213 def self.read(i, lines, variables) state = State.new(lines[i] == 'begin_state' ? 'init' : 'goal') if state.id == 'init' i += 1 var_index = 0 i.upto(lines.length) do |j| i = j break if lines[j] == 'end_state' var = variables[var_index] state[var.sym] = var[lines[j].to_i] var_index += 1 end fail "Cannot find end_state" if lines[i] != 'end_state' [i, state] elsif state.id == 'goal' i += 2 i.upto(lines.length) do |j| i = j break if lines[j] == 'end_goal' parts = lines[j].split(' ') var = variables[parts[0].to_i] state[var.sym] = var[parts[1].to_i] end fail "Cannot find end_goal" if lines[i] != 'end_goal' [i, state] end end |