Class: Longjing::PDDL::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/longjing/pddl/action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params, precond, effect) ⇒ Action

Returns a new instance of Action.



8
9
10
11
12
13
# File 'lib/longjing/pddl/action.rb', line 8

def initialize(name, params, precond, effect)
  @name = name
  @params = params
  @precond = precond
  @effect = effect
end

Instance Attribute Details

#effectObject (readonly)

Returns the value of attribute effect.



6
7
8
# File 'lib/longjing/pddl/action.rb', line 6

def effect
  @effect
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/longjing/pddl/action.rb', line 6

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'lib/longjing/pddl/action.rb', line 6

def params
  @params
end

#precondObject (readonly)

Returns the value of attribute precond.



6
7
8
# File 'lib/longjing/pddl/action.rb', line 6

def precond
  @precond
end

Instance Method Details

#signatureObject



22
23
24
# File 'lib/longjing/pddl/action.rb', line 22

def signature
  "#{@name}(#{@params.map(&:name).map(&:to_s).join(' ')})"
end

#substitute(arguments) ⇒ Object



15
16
17
18
19
20
# File 'lib/longjing/pddl/action.rb', line 15

def substitute(arguments)
  variables = Hash[@params.zip(arguments)]
  return nil unless precond = @precond.substitute(variables)
  return nil unless effect = @effect.substitute(variables)
  Action.new(@name, arguments, precond, effect)
end

#to_sObject Also known as: inspect



26
27
28
# File 'lib/longjing/pddl/action.rb', line 26

def to_s
  "(action #{@name} :parameters #{@params.join(' ')} :precondition #{@precond} :effect #{@effect})"
end