인공지능/Agent

ALFWorld 뜯어보기

이게될까 2025. 4. 8. 00:02
728x90
728x90

https://alfworld.github.io/

 

ALFWorld

Aligning Text and Embodied Environments for Interactive Learning

alfworld.github.io

 

https://github.com/alfworld/alfworld

 

GitHub - alfworld/alfworld: ALFWorld: Aligning Text and Embodied Environments for Interactive Learning

ALFWorld: Aligning Text and Embodied Environments for Interactive Learning - alfworld/alfworld

github.com

여기서 다운받을 수 있습니다.

 

alfred.pddl에서는 각 task와 그 task의 조건들이 작성되어 있습니다. 그래서 각종 조건을 넘어가야 그 행동이 진행되고, 결과가 나옵니다.

alfred.twl2는 각 행동과, 그 행동에 대한 결과를 출력해줍니다. 

이렇게 액션을 지정해주면

피드백이 이렇게 나옵니다. 

 

이렇게 하면 훈련 데이터랑 다 설치됩니다.

 

일단 pddl기반으로 돌아가는 것은 알겠는데 어디서 제대로 돌아가는 건지.....

텍스트 월드에서 한번 확인하는게 빠르긴 하겠네요...

 

모든 것은 텍스트 월드에 구현되어 있다....

Step 함수가 이건데 왜 Action을 넣어서 나오는게 아니지...?

여기서 진행됩니다.

 

https://github.com/microsoft/jericho

 

GitHub - microsoft/jericho: A learning environment for man-made Interactive Fiction games.

A learning environment for man-made Interactive Fiction games. - microsoft/jericho

github.com

 

결국 C가 나와버렸네요....

 

이 환경에서 진행되는 것으로 파싱 확인해봐야 겠습니다...

 

https://github.com/microsoft/TextWorld

 

GitHub - microsoft/TextWorld: ​TextWorld is a sandbox learning environment for the training and evaluation of reinforcement le

​TextWorld is a sandbox learning environment for the training and evaluation of reinforcement learning (RL) agents on text-based games. - microsoft/TextWorld

github.com

 

결국 alfworld는 textworld에서 gericho 라이브러리의 영향을 받고, 이미 컴파일된 C파일이라서 뜯어볼 수 없다././../

 

일단 pddl 파일 

더보기
;; Specification in PDDL of the Alfred domain
;; Intended to be used with Fast Downward which supports PDDL 2.2 level 1 plus the :action-costs requirement from PDDL 3.1.

(define (domain alfred)
 (:requirements
    :adl
    :action-costs
    :typing
 )
 (:types
  agent
  location
  receptacle
  object
  rtype
  otype
  )


 (:predicates
    (atLocation ?a - agent ?l - location)                     ; true if the agent is at the location
    (receptacleAtLocation ?r - receptacle ?l - location)      ; true if the receptacle is at the location (constant)
    (objectAtLocation ?o - object ?l - location)              ; true if the object is at the location
    (openable ?r - receptacle)                                ; true if a receptacle is openable
    (opened ?r - receptacle)                                  ; true if a receptacle is opened
    (inReceptacle ?o - object ?r - receptacle)                ; object ?o is in receptacle ?r
    (isReceptacleObject ?o - object)                          ; true if the object can have things put inside it
    (inReceptacleObject ?innerObject - object ?outerObject - object)                ; object ?innerObject is inside object ?outerObject
    (isReceptacleObjectFull ?o - object)                      ; true if the receptacle object contains something
    (wasInReceptacle ?o - object ?r - receptacle)             ; object ?o was or is in receptacle ?r now or some time in the past
    (checked ?r - receptacle)                                 ; whether the receptacle has been looked inside/visited
    (examined ?l - location)                                  ; TODO
    (receptacleType ?r - receptacle ?t - rtype)               ; the type of receptacle (Cabinet vs Cabinet|01|2...)
    (canContain ?rt - rtype ?ot - otype)                      ; true if receptacle can hold object
    (objectType ?o - object ?t - otype)                       ; the type of object (Apple vs Apple|01|2...)
    (holds ?a - agent ?o - object)                            ; object ?o is held by agent ?a
    (holdsAny ?a - agent)                                     ; agent ?a holds an object
    (holdsAnyReceptacleObject ?a - agent)                        ; agent ?a holds a receptacle object
    (full ?r - receptacle)                                    ; true if the receptacle has no remaining space
    (isClean ?o - object)                                     ; true if the object has been clean in sink
    (cleanable ?o - object)                                   ; true if the object can be placed in a sink
    (isHot ?o - object)                                       ; true if the object has been heated up
    (heatable ?o - object)                                    ; true if the object can be heated up in a microwave
    (isCool ?o - object)                                      ; true if the object has been cooled
    (coolable ?o - object)                                    ; true if the object can be cooled in the fridge
    (pickupable ?o - object)                                   ; true if the object can be picked up
    (moveable ?o - object)                                      ; true if the object can be moved
    (toggleable ?o - object)                                  ; true if the object can be turned on/off
    (isOn ?o - object)                                        ; true if the object is on
    (isToggled ?o - object)                                   ; true if the object has been toggled
    (sliceable ?o - object)                                   ; true if the object can be sliced
    (isSliced ?o - object)                                    ; true if the object is sliced
 )

  (:functions
    (distance ?from ?to)
    (total-cost) - number
   )

;; All actions are specified such that the final arguments are the ones used
;; for performing actions in Unity.


(:action look
    :parameters (?a - agent ?l - location)
    :precondition
        (and
            (atLocation ?a ?l)
        )
    :effect
        (and
            (checked ?l)
        )
)

(:action inventory
    :parameters (?a - agent)
    :precondition
        ()
    :effect
        (and
            (checked ?a)
        )
)

(:action examineReceptacle
    :parameters (?a - agent ?r - receptacle)
    :precondition
        (and
            (exists (?l - location)
                (and
                    (atLocation ?a ?l)
                    (receptacleAtLocation ?r ?l)
                )
            )
        )
    :effect
        (and
            (checked ?r)
        )
)

(:action examineObject
    :parameters (?a - agent ?o - object)
    :precondition
        (or
            ;(exists (?l - location)
            ;    (and
            ;        (atLocation ?a ?l)
            ;        (objectAtLocation ?o ?l)
            ;    )
            ;)
            (exists (?l - location, ?r - receptacle)
                (and
                    (atLocation ?a ?l)
                    (receptacleAtLocation ?r ?l)
                    ; (objectAtLocation ?o ?l)
                    (inReceptacle ?o ?r)
                    (or (not (openable ?r)) (opened ?r))  ; receptacle is opened if it is openable.
              )
            )
            (holds ?a ?o)
        )
    :effect
        (and
            (checked ?o)
        )
)

;; agent goes to receptacle
 (:action GotoLocation
    :parameters (?a - agent ?lStart - location ?lEnd - location ?r - receptacle)
    :precondition (and
                    (atLocation ?a ?lStart)
                    (receptacleAtLocation ?r ?lEnd)
                    ;(exists (?r - receptacle) (receptacleAtLocation ?r ?lEnd))
                  )
    :effect (and
                (not (atLocation ?a ?lStart))
                (atLocation ?a ?lEnd)
                ; (forall (?r - receptacle)
                ;     (when (and (receptacleAtLocation ?r ?lEnd)
                ;                (or (not (openable ?r)) (opened ?r)))
                ;         (checked ?r)
                ;     )
                ; )
                ; (increase (total-cost) (distance ?lStart ?lEnd))
                (increase (total-cost) 1)
            )
 )

;; agent opens receptacle
 (:action OpenObject
    :parameters (?a - agent ?l - location ?r - receptacle)
    :precondition (and
            (openable ?r)
            (atLocation ?a ?l)
            (receptacleAtLocation ?r ?l)
            (not (opened ?r))
            )
    :effect (and
                (opened ?r)
                (checked ?r)
                (increase (total-cost) 1)
            )
 )
;; agent closes receptacle
 (:action CloseObject
    :parameters (?a - agent ?l - location ?r - receptacle)
    :precondition (and
            (openable ?r)
            (atLocation ?a ?l)
            (receptacleAtLocation ?r ?l)
            (opened ?r)
            )
    :effect (and
                (not (opened ?r))
                (increase (total-cost) 1)
            )

 )

 ;; agent picks up object from a receptacle
 (:action PickupObject
    :parameters (?a - agent ?l - location ?o - object ?r - receptacle)
    :precondition
        (and
            (pickupable ?o)
            (atLocation ?a ?l)
            (receptacleAtLocation ?r ?l)
            ; (objectAtLocation ?o ?l)
            (inReceptacle ?o ?r)
            (not (holdsAny ?a))  ; agent's hands are empty.
            ;(not (holdsAnyReceptacleObject ?a))
            (or (not (openable ?r)) (opened ?r))  ; receptacle is opened if it is openable.
            ;(not (isReceptacleObject ?o))
        )
    :effect
        (and
            (not (inReceptacle ?o ?r))
            (holds ?a ?o)
            (holdsAny ?a)
            (not (objectAtLocation ?o ?l))
            ;(not (full ?r))
            (increase (total-cost) 1)
        )
 )


; ;; agent picks up object from a receptacle
; (:action PickupObjectFromReceptacleObject
;    :parameters (?a - agent ?l - location ?o - object ?outerR - object ?r - receptacle)
;    :precondition
;        (and
;            (atLocation ?a ?l)
;            (receptacleAtLocation ?r ?l)
;            (inReceptacle ?o ?r)
;            (pickupable ?o)
;            (not (holdsAny ?a))  ; agent's hands are empty.
;            (not (holdsAnyReceptacleObject ?a))
;            (or (not (openable ?r)) (opened ?r))  ; receptacle is opened if it is openable.
;            (not (isReceptacleObject ?o))
;            (isReceptacleObject ?outerR)
;            (inReceptacleObject ?o ?outerR)
;        )
;    :effect
;        (and
;            (not (inReceptacle ?o ?r))
;            (holds ?a ?o)
;            (holdsAny ?a)
;            (not (objectAtLocation ?o ?l))
;            (not (full ?r))
;            (increase (total-cost) 1)
;
;            (not (inReceptacleObject ?o ?outerR))
;            (not (isReceptacleObjectFull ?outerR))
;        )
; )
;
; ;; agent picks up object from a receptacle
; (:action PickupEmptyReceptacleObject
;    :parameters (?a - agent ?l - location ?o - object ?r - receptacle)
;    :precondition
;        (and
;            (atLocation ?a ?l)
;            (receptacleAtLocation ?r ?l)
;            ; (objectAtLocation ?o ?l)
;            (inReceptacle ?o ?r)
;            (pickupable ?o)
;            (not (holdsAny ?a))  ; agent's hands are empty.
;            (not (holdsAnyReceptacleObject ?a))
;            (or (not (openable ?r)) (opened ?r))  ; receptacle is opened if it is openable.
;            (isReceptacleObject ?o)
;            (not (isReceptacleObjectFull ?o))
;        )
;    :effect
;        (and
;            (not (inReceptacle ?o ?r))
;            (holds ?a ?o)
;            (holdsAny ?a)
;            (not (objectAtLocation ?o ?l))
;            (not (full ?r))
;            (increase (total-cost) 1)
;            (holdsAnyReceptacleObject ?a)
;        )
; )
;
; ;; agent picks up object from a receptacle
; (:action PickupFullReceptacleObject
;    :parameters (?a - agent ?l - location ?o - object ?outerR - object ?r - receptacle)
;    :precondition
;        (and
;            (atLocation ?a ?l)
;            (receptacleAtLocation ?r ?l)
;            (inReceptacle ?outerR ?r)
;            (pickupable ?outerR)
;            (not (holdsAny ?a))  ; agent's hands are empty.
;            (not (holdsAnyReceptacleObject ?a))
;            (or (not (openable ?r)) (opened ?r))  ; receptacle is opened if it is openable.
;            (not (isReceptacleObject ?o))
;            (isReceptacleObject ?outerR)
;            (inReceptacleObject ?o ?outerR)
;        )
;    :effect
;        (and
;            (not (inReceptacle ?o ?r))
;            (not (inReceptacle ?outerR ?r))
;            (holds ?a ?outerR)
;            (holdsAny ?a)
;            (not (objectAtLocation ?o ?l))
;            (not (objectAtLocation ?outerR ?l))
;            (not (full ?r))
;            (increase (total-cost) 1)
;            (holdsAnyReceptacleObject ?a)
;        )
; )


;; agent puts down an object
 (:action PutObject
    :parameters (?a - agent ?l - location ?o - object ?r - receptacle ?ot - otype ?rt - rtype)
    :precondition (and
            (holds ?a ?o)
            (atLocation ?a ?l)
            (receptacleAtLocation ?r ?l)
            (or (not (openable ?r)) (opened ?r))    ; receptacle is opened if it is openable
            ;(not (full ?r))
            (objectType ?o ?ot)
            (receptacleType ?r ?rt)
            (canContain ?rt ?ot)
            ;(not (holdsAnyReceptacleObject ?a))
            )
    :effect (and
                (inReceptacle ?o ?r)
                (objectAtLocation ?o ?l)
                ;(full ?r)
                (not (holds ?a ?o))
                (not (holdsAny ?a))
                (increase (total-cost) 1)
            )
 )

;;; agent puts down an object
; (:action PutObjectInReceptacleObject
;    :parameters (?a - agent ?l - location ?ot - otype ?o - object ?outerO - object ?outerR - receptacle)
;    :precondition (and
;            (atLocation ?a ?l)
;            (objectAtLocation ?outerO ?l)
;            (isReceptacleObject ?outerO)
;            (not (isReceptacleObject ?o))
;            (objectType ?o ?ot)
;            (holds ?a ?o)
;            (not (holdsAnyReceptacleObject ?a))
;            (inReceptacle ?outerO ?outerR)
;            (not (isReceptacleObjectFull ?outerO))
;            )
;    :effect (and
;                (inReceptacleObject ?o ?outerO)
;                (inReceptacle ?o ?outerR)
;                (not (holds ?a ?o))
;                (not (holdsAny ?a))
;                (objectAtLocation ?o ?l)
;                (isReceptacleObjectFull ?outerO)
;                (increase (total-cost) 1)
;            )
; )
;
;;; agent puts down an object
; (:action PutEmptyReceptacleObjectinReceptacle
;    :parameters (?a - agent ?l - location ?ot - otype ?o - object ?r - receptacle)
;    :precondition (and
;            (atLocation ?a ?l)
;            (receptacleAtLocation ?r ?l)
;            (or (not (openable ?r)) (opened ?r))    ; receptacle is opened if it is openable
;            (not (full ?r))
;            (objectType ?o ?ot)
;            (holds ?a ?o)
;            (holdsAnyReceptacleObject ?a)
;            (isReceptacleObject ?o)
;            (not (isReceptacleObjectFull ?o))
;            )
;    :effect (and
;                (inReceptacle ?o ?r)
;                (objectAtLocation ?o ?l)
;                (full ?r)
;                (not (holds ?a ?o))
;                (not (holdsAny ?a))
;                (not (holdsAnyReceptacleObject ?a))
;                (increase (total-cost) 1)
;            )
; )
;
;;; agent puts down a receptacle object in a receptacle
; (:action PutFullReceptacleObjectInReceptacle
;    :parameters (?a - agent ?l - location ?ot - otype ?innerO - object ?outerO - object ?r - receptacle) ; ?rt - rtype)
;    :precondition (and
;            (atLocation ?a ?l)
;            (receptacleAtLocation ?r ?l)
;            (objectType ?outerO ?ot)
;            (holds ?a ?outerO)
;            (holdsAnyReceptacleObject ?a)
;            (isReceptacleObject ?outerO)
;            (isReceptacleObjectFull ?outerO)
;            (inReceptacleObject ?innerO ?outerO)
;            )
;    :effect (and
;                (not (holdsAny ?a))
;                (not (holdsAnyReceptacleObject ?a))
;                (objectAtLocation ?outerO ?l)
;                (objectAtLocation ?innerO ?l)
;                (inReceptacle ?outerO ?r)
;                (inReceptacle ?innerO ?r)
;                (not (holds ?a ?outerO))
;                (increase (total-cost) 1)
;            )
; )

;; agent cleans some object
 (:action CleanObject
    :parameters (?a - agent ?l - location ?r - receptacle ?o - object)
    :precondition (and
            (cleanable ?o)
            (or
                ;(receptacleType ?r SinkType)
                (receptacleType ?r SinkBasinType)
            )
            (atLocation ?a ?l)
            (receptacleAtLocation ?r ?l)
            (holds ?a ?o)
            )
    :effect (and
                (increase (total-cost) 5)
                (isClean ?o)
            )
 )


;; agent heats-up some object
 (:action HeatObject
    :parameters (?a - agent ?l - location ?r - receptacle ?o - object)
    :precondition (and
            (heatable ?o)
            (or
                (receptacleType ?r MicrowaveType)
            )
            (atLocation ?a ?l)
            (receptacleAtLocation ?r ?l)
            (holds ?a ?o)
            )
    :effect (and
                (increase (total-cost) 5)
                (isHot ?o)
                (not (isCool ?o))
            )
 )

;; agent cools some object
 (:action CoolObject
    :parameters (?a - agent ?l - location ?r - receptacle ?o - object)
    :precondition (and
            (coolable ?o)
            (or
                (receptacleType ?r FridgeType)
            )
            (atLocation ?a ?l)
            (receptacleAtLocation ?r ?l)
            (holds ?a ?o)
            )
    :effect (and
                (increase (total-cost) 5)
                (isCool ?o)
                (not (isHot ?o))
            )
 )


;; agent toggle object
 (:action ToggleObject
    :parameters (?a - agent ?l - location ?o - object ?r - receptacle)
    :precondition (and
            (toggleable ?o)
            (atLocation ?a ?l)
            (receptacleAtLocation ?r ?l)
            (inReceptacle ?o ?r)
            )
    :effect (and
                (increase (total-cost) 5)
                (when (isOn ?o)
                    (not (isOn ?o)))
                (when (not (isOn ?o))
                    (isOn ?o))
                (isToggled ?o)
            )
 )


;; agent slices some object with a knife
 (:action SliceObject
    :parameters (?a - agent ?l - location ?co - object ?ko - object)
    :precondition
            (and
                (sliceable ?co)
                (or
                    (objectType ?ko KnifeType)
                    (objectType ?ko ButterKnifeType)
                )
                (atLocation ?a ?l)
                (objectAtLocation ?co ?l)
                (holds ?a ?ko)
            )
    :effect (and
                (increase (total-cost) 5)
                (isSliced ?co)
            )
 )


(:action help
    :parameters (?a - agent)
    :precondition
        ()
    :effect
        (and
            (checked ?a)
        )
)

)

 

이건 twl2 파일 

더보기
grammar :: """
    {
        "intro": [
            {
                "rhs": "-= Welcome to TextWorld, ALFRED! =-\n\n#look.feedback#\n\n#task#"
            }
        ],

        "notImplemented": [
            {
                "rhs": "TODO"
            }
        ],

        "task": [
            {
                "rhs": "Your task is to: UNKNOWN GOAL."
            }
        ],

        "GotoLocation.feedback": [
            {
                "rhs": "You arrive at {r.name}. #examineReceptacle.feedback#"
            }
        ],

        "OpenObject.feedback": [
            {
                "rhs": "You open the {r.name}. #examineReceptacle.feedback#"
            }
        ],

        "CloseObject.feedback": [
            {
                "rhs": "You close the {r.name}."
            }
        ],

        "PickupObject.feedback": [
            {
                "rhs": "You pick up the {o.name} from the {r.name}."
            }
        ],

        "PickupObjectFromReceptacleObject.feedback": [
            {
                "rhs": "PickupObjectFromReceptacleObject: You pick up the {o.name}."
            }
        ],

        "PickupEmptyReceptacleObject.feedback": [
            {
                "rhs": "PickupEmptyReceptacleObject: You pick up the {o.name}."
            }
        ],

        "PickupFullReceptacleObject.feedback": [
            {
                "rhs": "PickupFullReceptacleObject: You pick up the {outerr.name}."
            }
        ],

        "PutObject.feedback": [
            {
                "rhs": "You move the {o.name} to the {r.name}."
            }
        ],

        "PutObjectInReceptacleObject.feedback": [
            {
                "rhs": "PutObjectInReceptacleObject: You put the {o.name} in the {outero.name}."
            }
        ],

        "PutEmptyReceptacleObjectinReceptacle.feedback": [
            {
                "rhs": "PutEmptyReceptacleObjectinReceptacle: You put the {o.name} in the {r.name}."
            }
        ],

        "PutFullReceptacleObjectInReceptacle.feedback": [
            {
                "rhs": "PutFullReceptacleObjectInReceptacle: You put the {outero.name} in the {r.name}."
            }
        ],

        "inventory.feedback": [
            {
                "condition": "holdsany(a:agent)",
                "rhs": "You are carrying: [{o.indefinite + ' ' + o.name | holds(a:agent, o:object)}]."
            },
            {
                "rhs": "You are not carrying anything."
            }
        ],

        "examineReceptacle.feedback": [
            {
                "condition": "openable(r:receptacle) & opened(r:receptacle)",
                "rhs": "The {r.name} is open. In it, you see [{o.indefinite + ' ' + o.name | inreceptacle(o:object, r:receptacle)}]."
            },
            {
                "condition": "openable(r:receptacle)",
                "rhs": "The {r.name} is closed."
            },
            {
                "rhs": "On the {r.name}, you see [{o.indefinite + ' ' + o.name | inreceptacle(o:object, r:receptacle)}]."
            }
        ],

        "examineObject.feedback": [
            {
                "condition": "isreceptacleobject(o:object)",
                "rhs": "This is a normal {o.name}. In it, you see [{o2.indefinite + ' ' + o2.name | inreceptacleobject(o2:object, o:object)}]."
            },
            {
                "condition": "isclean(o:object) & ishot(o:object) & issliced(o:object)",
                "rhs": "This is a hot and clean sliced {o.name}."
            },
            {
                "condition": "isclean(o:object) & iscool(o:object) & issliced(o:object)",
                "rhs": "This is a cool and clean sliced {o.name}."
            },
            {
                "condition": "isclean(o:object) & issliced(o:object)",
                "rhs": "This is a clean sliced {o.name}."
            },
            {
                "condition": "ishot(o:object) & issliced(o:object)",
                "rhs": "This is a hot sliced {o.name}."
            },
            {
                "condition": "iscool(o:object) & issliced(o:object)",
                "rhs": "This is a cool sliced {o.name}."
            },
            {
                "condition": "isclean(o:object) & ishot(o:object)",
                "rhs": "This is a hot and clean {o.name}."
            },
            {
                "condition": "isclean(o:object) & iscool(o:object)",
                "rhs": "This is a cool and clean {o.name}."
            },
            {
                "condition": "ishot(o:object)",
                "rhs": "This is a hot {o.name}."
            },
            {
                "condition": "isclean(o:object)",
                "rhs": "This is a clean {o.name}."
            },
            {
                "condition": "iscool(o:object)",
                "rhs": "This is a cold {o.name}."
            },
            {
                "condition": "toggleable(o:object) & istoggled(o:object)",
                "rhs": "This {o.name} is on."
            },
            {
                "condition": "toggleable(o:object) & not_istoggled(o:object)",
                "rhs": "This {o.name} is off."
            },
            {
                "condition": "sliceable(o:object) & issliced(o:object)",
                "rhs": "This is a sliced {o.name}."
            },
            {
                "rhs": "There's nothing special about {o.name}."
            }
        ]
    }
""";

action GotoLocation {
    template :: "go to [{r.name | receptacleatlocation(r:receptacle, lend:location)}]";
    feedback :: "#GotoLocation.feedback#";
}

action OpenObject {
    template :: "open {r}";
    feedback :: "#OpenObject.feedback#";
}

action CloseObject {
    template :: "close {r}";
    feedback :: "#CloseObject.feedback#";
}

action PickupObject {
    template :: "take {o} from {r}";
    feedback :: "#PickupObject.feedback#";
}

action PickupObjectFromReceptacleObject {
    template :: "take {o} from {r}";
    feedback :: "#PickupObjectFromReceptacleObject.feedback#";
}

action PickupEmptyReceptacleObject {
    template :: "take {o} from {r}";
    feedback :: "#PickupEmptyReceptacleObject.feedback#";
}

action PickupFullReceptacleObject {
    template :: "take {outerr} from {r}";
    feedback :: "#PickupFullReceptacleObject.feedback#";
}

action PutObject {
    template :: "move {o} to {r}";
    feedback :: "#PutObject.feedback#";
}

action PutObjectInReceptacleObject {
    template :: "put {o} into {outero}";
    feedback :: "#PutObjectInReceptacleObject.feedback#";
}

action PutEmptyReceptacleObjectinReceptacle {
    template :: "move {o} to {r}";
    feedback :: "#PutEmptyReceptacleObjectinReceptacle.feedback#";
}

action PutFullReceptacleObjectInReceptacle {
    template :: "put {outero} in {r}";
    feedback :: "#PutFullReceptacleObjectInReceptacle.feedback#";
}

action inventory {
    template :: "inventory";
    feedback :: "#inventory.feedback#";
}

action examineReceptacle {
    template :: "examine {r}";
    feedback :: "#examineReceptacle.feedback#";
}

action examineObject {
    template :: "examine {o}";
    feedback :: "#examineObject.feedback#";
}

action ToggleObject {
    template :: "use {o}";
    feedback :: "#toggleObject.feedback#";

    grammar :: """
        {
            "toggleObject.feedback": [
                {
                    "condition": "toggleable(o:object) & istoggled(o:object)",
                    "rhs": "You turn on the {o.name}."
                },
                {
                    "condition": "toggleable(o:object)",
                    "rhs": "You turn off the {o.name}."
                },
                {
                    "rhs": "You don't see any switch on the {o.name}."
                }
            ]
        }
    """;
}

action HeatObject {
    template :: "heat {o} with {r}";
    feedback :: "#heatObject.feedback#";

    grammar :: """
        {
            "heatObject.feedback": [
                {
                    "rhs": "You heat the {o.name} using the {r.name}."
                }
            ]
        }
    """;
}

action CleanObject {
    template :: "clean {o} with {r}";
    feedback :: "#cleanObject.feedback#";

    grammar :: """
        {
            "cleanObject.feedback": [
                {
                    "rhs": "You clean the {o.name} using the {r.name}."
                }
            ]
        }
    """;
}

action CoolObject {
    template :: "cool {o} with {r}";
    feedback :: "#coolObject.feedback#";

    grammar :: """
        {
            "coolObject.feedback": [
                {
                    "rhs": "You cool the {o.name} using the {r.name}."
                }
            ]
        }
    """;
}

action SliceObject {
    template :: "slice {co} with {ko}";
    feedback :: "#sliceObject.feedback#";

    grammar :: """
        {
            "sliceObject.feedback": [
                {
                    "rhs": "You sliced the {co.name} with the {ko.name}."
                }
            ]
        }
    """;
}

action look {
    template :: "look";
    feedback :: "#look.feedback#";

    grammar :: """
        {
            "look.feedback": [
                {
                   "condition": "atlocation(a:agent, l:location) & receptacleatlocation(r:receptacle, l:location)",
                   "rhs": "#look-variations#. Next to it, you see #list_objects_on_the_floor#."
                },
                {
                    "rhs": "You are in the middle of a room. Looking quickly around you, you see #list_appliances#."
                }
            ],

            "look-variations": [
                {
                    "rhs": "You are facing the [{r.name | atlocation(a:agent, l:location) & receptacleatlocation(r:receptacle, l:location)}]"
                }
            ],

            "list_objects_on_the_floor": [
                {
                    "condition": "atlocation(a:agent, l:location) & objectatlocation(o:object, l:location) & receptacleatlocation(r:receptacle, l:location) & not_inreceptacle(o:object, r:receptacle)",
                    "rhs": "[{#overview(o)# | atlocation(a:agent, l:location) & objectatlocation(o:object, l:location) & receptacleatlocation(r:receptacle, l:location) & not_inreceptacle(o:object, r:receptacle)}]"
                },
                {
                    "rhs": "nothing"
                }
            ],

            "list_appliances": [
                {
                    "condition": "receptacleatlocation(r:receptacle, l:location)",
                    "rhs": "[{#overview(r)# | receptacleatlocation(r:receptacle, l:location)}]"
                },
                {
                    "rhs": "nothing"
                }
            ],

            "overview(o, r)": [
                {
                    "rhs": "{o.indefinite} {o.name} (in/on the {r.name})}"
                }
            ],

            "overview(o)": [
                {
                    "rhs": "{o.indefinite} {o.name}"
                }
            ],
            "overview(r)": [
                {
                    "rhs": "{r.indefinite} {r.name or r.id}"
                }
            ],
            "overview_with_state(r)": [
                {
                    "rhs": "{r.indefinite} {r.name or r.id}#overview_state(r)#"
                }
            ],
            "overview_state(r)": [
                {
                    "condition": "openable(r:receptacle) & opened(r:receptacle)",
                    "rhs": " (it is open)"
                },
                {
                    "condition": "openable(r:receptacle)",
                    "rhs": " (it is closed)"
                },
                {
                    "rhs": ""
                }
            ],

            "list_empty": [
                {
                    "rhs": "nothing"
                }
            ],
            "list_separator": [
                {
                    "rhs": ", "
                }
            ],
            "list_last_separator": [
                {
                    "rhs": ", and "
                }
            ]
        }
    """;
}

action help {
    template :: "help";
    feedback :: "#help.feedback#";

    grammar :: """
        {
            "help.feedback": [
                {
                    "rhs": "\nAvailable commands:\n  look:                             look around your current location\n  inventory:                        check your current inventory\n  go to (receptacle):               move to a receptacle\n  open (receptacle):                open a receptacle\n  close (receptacle):               close a receptacle\n  take (object) from (receptacle):  take an object from a receptacle\n  move (object) to (receptacle):  place an object in or on a receptacle\n  examine (something):              examine a receptacle or an object\n  use (object):                     use an object\n  heat (object) with (receptacle):  heat an object using a receptacle\n  clean (object) with (receptacle): clean an object using a receptacle\n  cool (object) with (receptacle):  cool an object using a receptacle\n  slice (object) with (object):     slice an object using a sharp object\n"
                }
            ]
        }
    """;
}

 

 

 

 

728x90

'인공지능 > Agent' 카테고리의 다른 글

Negotiation AI 2  (1) 2024.12.12
Negotiation AI 1  (4) 2024.12.10
Agent-Pro와 GITM 비교  (0) 2024.11.28