diff --git a/VGDL/Cakybaky/cakybaky.txt b/VGDL/Cakybaky/cakybaky.txt index 4bd2c31..a7cf7fe 100644 --- a/VGDL/Cakybaky/cakybaky.txt +++ b/VGDL/Cakybaky/cakybaky.txt @@ -1,37 +1,35 @@ BasicGame SpriteSet - floor > Immovable img=newset/floor6 hidden=True chef > Chaser img=newset/chef frameRate=8 color=ORANGE stype=avatar speed=0.1 maxDistance=200 table > Immovable img=newset/table1 inc > Resource shrinkfactor=0.9 - inc1 > img=newset/flour limit=1 - inc2 > img=newset/milk limit=1 - inc3 > img=newset/egg limit=1 - inc4 > img=newset/sugar limit=1 - inc5 > img=newset/butter limit=1 - inc6 > img=newset/cherries limit=1 + inca > img=newset/flour limit=1 + incb > img=newset/milk limit=1 + incc > img=newset/egg limit=1 + incd > img=newset/sugar limit=1 + ince > img=newset/butter limit=1 + incf > img=newset/cherries limit=1 avatar > OrientedAvatar img=newset/man4 rotateInPlace=false frameRate=8 wall > Immovable color=BLACK img=newset/floor4 LevelMapping - 1 > inc1 floor - 2 > inc2 floor - 3 > inc3 floor - 4 > inc4 floor - 5 > inc5 floor - 6 > inc6 floor - t > table floor - C > avatar inc1 inc2 floor - A > avatar floor - c > chef floor - . > floor + 1 > inca + 2 > incb + 3 > incc + 4 > incd + 5 > ince + 6 > incf + t > table + C > avatar inca incb + A > avatar + c > chef TerminationSet Timeout limit=1500 win=False SpriteCounter stype=avatar win=False - SpriteCounter stype=inc6 limit=0 win=True + SpriteCounter stype=incf limit=0 win=True InteractionSet avatar wall table > stepBack @@ -39,9 +37,9 @@ BasicGame avatar chef > killSprite scoreChange=-1 - inc1 avatar > collectResource scoreChange=1 - inc2 avatar > collectResourceIfHeld heldResource=inc1 scoreChange=1 - inc3 avatar > collectResourceIfHeld heldResource=inc2 scoreChange=1 - inc4 avatar > collectResourceIfHeld heldResource=inc3 scoreChange=1 - inc5 avatar > collectResourceIfHeld heldResource=inc4 scoreChange=1 - inc6 avatar > collectResourceIfHeld heldResource=inc5 scoreChange=1 + inca avatar > collectResource scoreChange=1 + incb avatar > collectResourceIfHeld heldResource=inca scoreChange=1 + incc avatar > collectResourceIfHeld heldResource=incb scoreChange=1 + incd avatar > collectResourceIfHeld heldResource=incc scoreChange=1 + ince avatar > collectResourceIfHeld heldResource=incd scoreChange=1 + incf avatar > collectResourceIfHeld heldResource=ince scoreChange=1 diff --git a/config/simplified-version/cakybaky.yaml b/config/simplified-version/cakybaky.yaml new file mode 100644 index 0000000..87a717b --- /dev/null +++ b/config/simplified-version/cakybaky.yaml @@ -0,0 +1,67 @@ +domainFile: domains/simplified-version/cakybaky.pddl +problemFile: problem.pddl +domainName: VGDLGame +gameElementsCorrespondence: + avatar: + - (at ?x ?y ?avatar) + chef: + - (is-chef ?x ?y) + table: + - (is-table ?x ?y) + inca: + - (at ?x ?y ?inca) + incb: + - (at ?x ?y ?incb) + incc: + - (at ?x ?y ?incc) + incd: + - (at ?x ?y ?incd) + ince: + - (at ?x ?y ?ince) + incf: + - (at ?x ?y ?incf) + wall: + - (is-wall ?x ?y) +variablesTypes: + ?inca: inca + ?incb: incb + ?incc: incc + ?incd: incd + ?ince: ince + ?incf: incf + ?avatar: avatar + ?x: num + ?y: num +avatarVariable: ?avatar +orientation: + avatar: FIND +orientationCorrespondence: + UP: (oriented-up ?object) + DOWN: (oriented-down ?object) + LEFT: (oriented-left ?object) + RIGHT: (oriented-right ?object) +fluentsPredicates: + next: (next ?n0 ?n1) + previous: (previous ?n1 ?n0) +actionsCorrespondence: + AVATAR_ACTION_MOVE_UP: ACTION_UP + AVATAR_ACTION_MOVE_DOWN: ACTION_DOWN + AVATAR_ACTION_MOVE_LEFT: ACTION_LEFT + AVATAR_ACTION_MOVE_RIGHT: ACTION_RIGHT + AVATAR_ACTION_TURN_UP: ACTION_UP + AVATAR_ACTION_TURN_DOWN: ACTION_DOWN + AVATAR_ACTION_TURN_LEFT: ACTION_LEFT + AVATAR_ACTION_TURN_RIGHT: ACTION_RIGHT +additionalPredicates: +- (turn-avatar) +- (got-resource-inca n0) +- (got-resource-incb n0) +- (got-resource-incc n0) +- (got-resource-incd n0) +- (got-resource-ince n0) +- (got-resource-incf n0) +addDeadObjects: {} +goals: +- goalPredicate: (at n14 n12 avatar) + priority: 1 + saveGoal: no diff --git a/domains/simplified-version/cakybaky.pddl b/domains/simplified-version/cakybaky.pddl new file mode 100644 index 0000000..45a8edc --- /dev/null +++ b/domains/simplified-version/cakybaky.pddl @@ -0,0 +1,502 @@ + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; PDDL domain for a VGDL game +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define (domain VGDLGame) + (:requirements + :adl + :negative-preconditions + ) + + ; Types --------------------------------------------------------------------- + + (:types + num + chef - Chaser + table - Immovable + inc - Resource + inca - inc + incb - inc + incc - inc + incd - inc + ince - inc + incf - inc + avatar - OrientedAvatar + wall - Immovable + OrientedAvatar Immovable Chaser Resource - Object + ) + + ; Predicates ---------------------------------------------------------------- + + (:predicates + ; Orientation + (oriented-up ?o - Object) + (oriented-down ?o - Object) + (oriented-left ?o - Object) + (oriented-right ?o - Object) + (oriented-none ?o - Object) + ; Game turn order + (turn-avatar) + (turn-sprites) + (turn-interactions) + ; Numerics + (next ?x ?y - num) + (previous ?x ?y - num) + ; Position + (at ?x ?y - num ?o - Object) + (object-dead ?o - Object) + ; Game specific + (is-wall ?x ?y - num) + (is-table ?x ?y - num) + (is-chef ?x ?y - num) + (got-resource-inc ?n - num) + (got-resource-inca ?n - num) + (got-resource-incb ?n - num) + (got-resource-incc ?n - num) + (got-resource-incd ?n - num) + (got-resource-ince ?n - num) + (got-resource-incf ?n - num) + ) + + ; Actions ------------------------------------------------------------------- + + (:action AVATAR_ACTION_MOVE_UP + :parameters (?a - OrientedAvatar ?x - num ?y - num ?new_y - num) + :precondition (and + (turn-avatar) + (or (oriented-up ?a) (oriented-none ?a)) + (at ?x ?y ?a) + (previous ?y ?new_y) + (not (is-wall ?x ?new_y)) + (not (is-table ?x ?new_y)) + (not (is-chef ?x ?new_y)) + ) + :effect (and + (not (at ?x ?y ?a)) + (at ?x ?new_y ?a) + (not (turn-avatar)) + (turn-interactions) + ; Change orientation + (when + (oriented-down ?a ) + (not (oriented-down ?a)) + ) + + (when + (oriented-right ?a ) + (not (oriented-right ?a)) + ) + + (when + (oriented-left ?a ) + (not (oriented-left ?a)) + ) + (oriented-up ?a) + ) + ) + + (:action AVATAR_ACTION_MOVE_DOWN + :parameters (?a - OrientedAvatar ?x - num ?y - num ?new_y - num) + :precondition (and + (turn-avatar) + (or (oriented-down ?a) (oriented-none ?a)) + (at ?x ?y ?a) + (next ?y ?new_y) + (not (is-wall ?x ?new_y)) + (not (is-table ?x ?new_y)) + (not (is-chef ?x ?new_y)) + ) + :effect (and + (not (at ?x ?y ?a)) + (at ?x ?new_y ?a) + (not (turn-avatar)) + (turn-interactions) + ; Change orientation + (when + (oriented-up ?a ) + (not (oriented-up ?a)) + ) + (when + (oriented-right ?a ) + (not (oriented-right ?a)) + ) + (when + (oriented-left ?a ) + (not (oriented-left ?a)) + ) + (oriented-down ?a) + ) + ) + + (:action AVATAR_ACTION_MOVE_LEFT + :parameters (?a - OrientedAvatar ?x - num ?y - num ?new_x - num) + :precondition (and + (turn-avatar) + (or (oriented-left ?a) (oriented-none ?a)) + (at ?x ?y ?a) + (previous ?x ?new_x) + (not (is-wall ?new_x ?y)) + (not (is-table ?new_x ?y)) + (not (is-chef ?new_x ?y)) + ) + :effect (and + (not (at ?x ?y ?a)) + (at ?new_x ?y ?a) + (not (turn-avatar)) + (turn-interactions) + ; Change orientation + (when + (oriented-up ?a ) + (not (oriented-up ?a)) + ) + (when + (oriented-down ?a ) + (not (oriented-down ?a)) + ) + (when + (oriented-right ?a ) + (not (oriented-right ?a)) + ) + (oriented-left ?a) + ) + ) + + (:action AVATAR_ACTION_MOVE_RIGHT + :parameters (?a - OrientedAvatar ?x - num ?y - num ?new_x - num) + :precondition (and + (turn-avatar) + (or (oriented-right ?a) (oriented-none ?a)) + (at ?x ?y ?a) + (next ?x ?new_x) + (not (is-wall ?new_x ?y)) + (not (is-table ?new_x ?y)) + (not (is-chef ?new_x ?y)) + ) + :effect (and + (not (at ?x ?y ?a)) + (at ?new_x ?y ?a) + (not (turn-avatar)) + (turn-interactions) + ; Change orientation + (when + (oriented-up ?a ) + (not (oriented-up ?a)) + ) + (when + (oriented-down ?a ) + (not (oriented-down ?a)) + ) + (when + (oriented-left ?a ) + (not (oriented-left ?a)) + ) + (oriented-right ?a) + ) + ) + + (:action AVATAR_ACTION_TURN_UP + :parameters (?a - OrientedAvatar) + :precondition (and + (turn-avatar) + (not (oriented-up ?a)) + ) + :effect (and + + (when + (oriented-down ?a ) + (not (oriented-down ?a)) + ) + + (when + (oriented-right ?a ) + (not (oriented-right ?a)) + ) + + (when + (oriented-left ?a ) + (not (oriented-left ?a)) + ) + (oriented-up ?a) + (not (turn-avatar)) + (turn-interactions) + ) + ) + + (:action AVATAR_ACTION_TURN_DOWN + :parameters (?a - OrientedAvatar) + :precondition (and + (turn-avatar) + (not (oriented-down ?a)) + ) + :effect (and + + (when + (oriented-left ?a ) + (not (oriented-left ?a)) + ) + + (when + (oriented-right ?a ) + (not (oriented-right ?a)) + ) + + (when + (oriented-up ?a ) + (not (oriented-up ?a)) + ) + (oriented-down ?a) + (not (turn-avatar)) + (turn-interactions) + ) + ) + + (:action AVATAR_ACTION_TURN_LEFT + :parameters (?a - OrientedAvatar) + :precondition (and + (turn-avatar) + (not (oriented-left ?a)) + ) + :effect (and + + (when + (oriented-down ?a ) + (not (oriented-down ?a)) + ) + + (when + (oriented-right ?a ) + (not (oriented-right ?a)) + ) + + (when + (oriented-up ?a ) + (not (oriented-up ?a)) + ) + (oriented-left ?a) + (not (turn-avatar)) + (turn-interactions) + ) + ) + + (:action AVATAR_ACTION_TURN_RIGHT + :parameters (?a - OrientedAvatar) + :precondition (and + (turn-avatar) + (not (oriented-right ?a)) + ) + :effect (and + + (when + (oriented-down ?a ) + (not (oriented-down ?a)) + ) + + (when + (oriented-left ?a ) + (not (oriented-left ?a)) + ) + + (when + (oriented-up ?a ) + (not (oriented-up ?a)) + ) + (oriented-right ?a) + (not (turn-avatar)) + (turn-interactions) + ) + ) + + (:action INCA_AVATAR_COLLECTRESOURCE + :parameters (?o1 - inca ?o2 - avatar ?x - num ?y - num ?r - num ?r_next - num) + :precondition (and + (turn-interactions) + (not (= ?o1 ?o2)) + (at ?x ?y ?o1) + (at ?x ?y ?o2) + (got-resource-inca ?r) + (next ?r ?r_next) + ) + :effect (and + (not (at ?x ?y ?o1)) + (object-dead ?o1) + (not (got-resource-inca ?r)) + (got-resource-inca ?r_next) + ) + ) + + (:action INCB_AVATAR_COLLECTRESOURCEIFHELD + :parameters (?o1 - incb ?o2 - avatar ?x - num ?y - num ?r - num ?r_next - num) + :precondition (and + (turn-interactions) + (not (= ?o1 ?o2)) + (at ?x ?y ?o1) + (at ?x ?y ?o2) + (got-resource-incb ?r) + (next ?r ?r_next) + (not (got-resource-inca n0)) + ) + :effect (and + (not (at ?x ?y ?o1)) + (object-dead ?o1) + (not (got-resource-incb ?r)) + (got-resource-incb ?r_next) + ) + ) + + (:action INCC_AVATAR_COLLECTRESOURCEIFHELD + :parameters (?o1 - incc ?o2 - avatar ?x - num ?y - num ?r - num ?r_next - num) + :precondition (and + (turn-interactions) + (not (= ?o1 ?o2)) + (at ?x ?y ?o1) + (at ?x ?y ?o2) + (got-resource-incc ?r) + (next ?r ?r_next) + (not (got-resource-incb n0)) + ) + :effect (and + (not (at ?x ?y ?o1)) + (object-dead ?o1) + (not (got-resource-incc ?r)) + (got-resource-incc ?r_next) + ) + ) + + (:action INCD_AVATAR_COLLECTRESOURCEIFHELD + :parameters (?o1 - incd ?o2 - avatar ?x - num ?y - num ?r - num ?r_next - num) + :precondition (and + (turn-interactions) + (not (= ?o1 ?o2)) + (at ?x ?y ?o1) + (at ?x ?y ?o2) + (got-resource-incd ?r) + (next ?r ?r_next) + (not (got-resource-incc n0)) + ) + :effect (and + (not (at ?x ?y ?o1)) + (object-dead ?o1) + (not (got-resource-incd ?r)) + (got-resource-incd ?r_next) + ) + ) + + (:action INCE_AVATAR_COLLECTRESOURCEIFHELD + :parameters (?o1 - ince ?o2 - avatar ?x - num ?y - num ?r - num ?r_next - num) + :precondition (and + (turn-interactions) + (not (= ?o1 ?o2)) + (at ?x ?y ?o1) + (at ?x ?y ?o2) + (got-resource-ince ?r) + (next ?r ?r_next) + (not (got-resource-incd n0)) + ) + :effect (and + (not (at ?x ?y ?o1)) + (object-dead ?o1) + (not (got-resource-ince ?r)) + (got-resource-ince ?r_next) + ) + ) + + (:action INCF_AVATAR_COLLECTRESOURCEIFHELD + :parameters (?o1 - incf ?o2 - avatar ?x - num ?y - num ?r - num ?r_next - num) + :precondition (and + (turn-interactions) + (not (= ?o1 ?o2)) + (at ?x ?y ?o1) + (at ?x ?y ?o2) + (got-resource-incf ?r) + (next ?r ?r_next) + (not (got-resource-ince n0)) + ) + :effect (and + (not (at ?x ?y ?o1)) + (object-dead ?o1) + (not (got-resource-incf ?r)) + (got-resource-incf ?r_next) + ) + ) + + (:action END-TURN-INTERACTIONS + :parameters () + :precondition (and + (turn-interactions) + (not (exists (?o1 - ince ?o2 - avatar ?x ?y - num) + (and + (not (= ?o1 ?o2)) + (at ?x ?y ?o1) + (at ?x ?y ?o2) + ) + ) + ) + (not (exists (?o1 - incb ?o2 - avatar ?x ?y - num) + (and + (not (= ?o1 ?o2)) + (at ?x ?y ?o1) + (at ?x ?y ?o2) + ) + ) + ) + (not (exists (?o1 - incc ?o2 - avatar ?x ?y - num) + (and + (not (= ?o1 ?o2)) + (at ?x ?y ?o1) + (at ?x ?y ?o2) + ) + ) + ) + (not (exists (?o1 - incd ?o2 - avatar ?x ?y - num) + (and + (not (= ?o1 ?o2)) + (at ?x ?y ?o1) + (at ?x ?y ?o2) + ) + ) + ) + (not (exists (?o1 - incf ?o2 - avatar ?x ?y - num) + (and + (not (= ?o1 ?o2)) + (at ?x ?y ?o1) + (at ?x ?y ?o2) + ) + ) + ) + (not (exists (?o1 - inca ?o2 - avatar ?x ?y - num) + (and + (not (= ?o1 ?o2)) + (at ?x ?y ?o1) + (at ?x ?y ?o2) + ) + ) + ) + ) + :effect (and + (turn-sprites) + (not (turn-interactions)) + ) + ) + + (:action TURN-SPRITES + :parameters () + :precondition (and + (turn-sprites) + ) + :effect (and + (not (turn-sprites)) + ) + ) + + (:action END-TURN-SPRITES + :parameters () + :precondition (and + (not (turn-interactions)) + ) + :effect (and + (turn-avatar) + ) + ) + +) \ No newline at end of file diff --git a/examples/gridphysics/cakybaky.txt b/examples/gridphysics/cakybaky.txt index 8bc8416..fd522e2 100755 --- a/examples/gridphysics/cakybaky.txt +++ b/examples/gridphysics/cakybaky.txt @@ -5,25 +5,25 @@ BasicGame table > Immovable img=newset/table1 inc > Resource shrinkfactor=0.9 - inc1 > img=newset/flour limit=1 - inc2 > img=newset/milk limit=1 - inc3 > img=newset/egg limit=1 - inc4 > img=newset/sugar limit=1 - inc5 > img=newset/butter limit=1 - inc6 > img=newset/cherries limit=1 + inca > img=newset/flour limit=1 + incb > img=newset/milk limit=1 + incc > img=newset/egg limit=1 + incd > img=newset/sugar limit=1 + ince > img=newset/butter limit=1 + incf > img=newset/cherries limit=1 avatar > OrientedAvatar img=newset/man4 rotateInPlace=false frameRate=8 wall > Immovable color=BLACK img=newset/floor4 LevelMapping - 1 > inc1 floor - 2 > inc2 floor - 3 > inc3 floor - 4 > inc4 floor - 5 > inc5 floor - 6 > inc6 floor + 1 > inca floor + 2 > incb floor + 3 > incc floor + 4 > incd floor + 5 > ince floor + 6 > incf floor t > table floor - C > avatar inc1 inc2 floor + C > avatar inca incb floor A > avatar floor c > chef floor . > floor @@ -31,7 +31,7 @@ BasicGame TerminationSet Timeout limit=1500 win=False SpriteCounter stype=avatar win=False - SpriteCounter stype=inc6 limit=0 win=True + SpriteCounter stype=incf limit=0 win=True InteractionSet avatar wall table > stepBack @@ -39,9 +39,9 @@ BasicGame avatar chef > killSprite scoreChange=-1 - inc1 avatar > collectResource scoreChange=1 - inc2 avatar > collectResourceIfHeld heldResource=inc1 scoreChange=1 - inc3 avatar > collectResourceIfHeld heldResource=inc2 scoreChange=1 - inc4 avatar > collectResourceIfHeld heldResource=inc3 scoreChange=1 - inc5 avatar > collectResourceIfHeld heldResource=inc4 scoreChange=1 - inc6 avatar > collectResourceIfHeld heldResource=inc5 scoreChange=1 + inca avatar > collectResource scoreChange=1 + incb avatar > collectResourceIfHeld heldResource=inca scoreChange=1 + incc avatar > collectResourceIfHeld heldResource=incb scoreChange=1 + incd avatar > collectResourceIfHeld heldResource=incc scoreChange=1 + ince avatar > collectResourceIfHeld heldResource=incd scoreChange=1 + incf avatar > collectResourceIfHeld heldResource=ince scoreChange=1 diff --git a/parser/src/pddl/configurationGenerator.py b/parser/src/pddl/configurationGenerator.py index b1c5f5a..ed600fa 100644 --- a/parser/src/pddl/configurationGenerator.py +++ b/parser/src/pddl/configurationGenerator.py @@ -108,8 +108,10 @@ def config_add_gameElementsCorrespondence_variablesTypes(spritesPDDL, avatar_pre # Create empty list config["gameElementsCorrespondence"][name] = [] - # Add objects with parents (that have been "simplified") - if parent in parents and name != "avatar": + + # Add objects with parents (that have been "simplified") and don't have + # any particular predicate + if parent in parents and name != "avatar" and not sprite.predicates: config["variablesTypes"]["?%s" % parent] = parent config["gameElementsCorrespondence"][name].append( "(at ?x ?y ?%s)" % parent, diff --git a/parser/src/pddl/interactionPDDL.py b/parser/src/pddl/interactionPDDL.py index c0f5eef..00ffe5e 100644 --- a/parser/src/pddl/interactionPDDL.py +++ b/parser/src/pddl/interactionPDDL.py @@ -132,6 +132,10 @@ def __init__( "collectResource": [self.collectResource], + # Increment resource (sprite) in the object (partner) if another resource is held + "collectResourceIfHeld": + [self.collectResourceIfHeld], + # [GVGAI] Decrease speed of all objects of the type of the sprite "decreaseSpeedToAll": [self.decreaseSpeedToAll], @@ -568,6 +572,41 @@ def collectResource(self): # ------------------------------------------------------------------------- + def collectResourceIfHeld(self): + # Find the other resource needed + parameters = [p for p in self.interaction.parameters if "heldResource=" in p] + other = parameters[0].replace("heldResource=",'') + + name = ( + self.sprite.name.upper() + + "_" + + self.partner.name.upper() + + "_COLLECTRESOURCEIFHELD" + ) + + # Resource as number + parameters = [["o1", self.sprite.name], ["o2", self.partner.name], ["x", "num"], ["y", "num"], ["r", "num"], ["r_next", "num"]] + preconditions = [ + "(turn-interactions)", + "(not (= ?o1 ?o2))", + "(at ?x ?y ?o1)", + "(at ?x ?y ?o2)", + "(got-resource-" + self.sprite.name + " ?r)", + "(next ?r ?r_next)", + "(not (got-resource-" + other + " n0))" + ] + effects = [ + "(not (at ?x ?y ?o1))", + "(object-dead ?o1)", + "(not (got-resource-" + self.sprite.name + " ?r))", + "(got-resource-" + self.sprite.name + " ?r_next)" + + ] + + return Action(name, parameters, preconditions, effects) + + # ------------------------------------------------------------------------- + def decreaseSpeedToAll(self): pass # name = ( diff --git a/parser/src/pddl/spritePDDL.py b/parser/src/pddl/spritePDDL.py index 44cafd0..a50ee81 100644 --- a/parser/src/pddl/spritePDDL.py +++ b/parser/src/pddl/spritePDDL.py @@ -43,7 +43,7 @@ def get_level_predicates(self) -> list: # ------------------------------------------------------------------------- def get_predicates(self) -> list: - self.predicates = SpritePredicates(self.sprite).predicates + self.predicates = SpritePredicates(self.sprite, self.hierarchy).predicates ############################################################################### # ----------------------------------------------------------------------------- @@ -348,8 +348,9 @@ def flee(self, partner): class SpritePredicates: """ Returns different predicates depending of the sprite """ - def __init__(self, sprite): + def __init__(self, sprite, hierarchy): self.sprite = sprite + self.hierarchy = hierarchy self.predicates = [] self.get_predicates() @@ -425,7 +426,8 @@ def get_predicates(self): # Resource as object # "Resource": ["(got-resource-" + self.sprite.name + " ?o - " + self.sprite.name + ")"], # Resource as number - "Resource": ["(got-resource-" + self.sprite.name + " ?n - num)"], + "Resource": [], + # ["(got-resource-" + self.sprite.name + " ?n - num)"], # Produces sprites following a specific ratio "SpawnPoint": [ @@ -451,6 +453,13 @@ def get_predicates(self): # "FIX", but better try to include all keys manually if possible self.predicates.extend(sprite_predicates_list.get(self.sprite.stype, [])) + self.is_resource() + + # ------------------------------------------------------------------------- + + def is_resource(self): + if self.sprite.stype == "Resource" or "Resource" in self.hierarchy[self.sprite.stype]: + self.predicates.append("(got-resource-" + self.sprite.name + " ?n - num)") ############################################################################### # -----------------------------------------------------------------------------