From 2c9134b13f36e45f11a686c7436febb4dd1f6f04 Mon Sep 17 00:00:00 2001 From: bitcraft Date: Mon, 22 Apr 2013 19:28:28 -0500 Subject: [PATCH] added some debug print statements, actions seem to work --- npc/pirate/actions.py | 11 +++++++---- pathfinding/astar.py | 1 - pygoap/agent.py | 2 +- pygoap/tiledenvironment.py | 1 - 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/npc/pirate/actions.py b/npc/pirate/actions.py index a4f4b04..eb187cb 100644 --- a/npc/pirate/actions.py +++ b/npc/pirate/actions.py @@ -39,7 +39,8 @@ def update(self, time): pos = self.path.pop() self.parent.environment.set_position(self.parent, (self.parent.environment, pos)) - else: + + if not self.path: self.finish() def setStartpoint(self, pos): @@ -58,11 +59,13 @@ class PickupAction(CalledOnceContext): class DrinkRumAction(ActionContext): def enter(self): + print "drinking!" self.drunkness = 1 def update(self, time): self.drunkness += 1 - if self.drunkness == 5: + if self.drunkness >= 3: + print "DRUNK!" self.finish() exported_actions = [] @@ -90,7 +93,6 @@ def get_actions(self, caller, memory): action.setStartpoint(here) action.setEndpoint(pct.position[1]) action.effects.append(PositionGoal(caller, pct.position)) - print ">>> MOVE >>>", action, action.startpoint, action.endpoint yield action exported_actions.append(move_to_entity) @@ -118,10 +120,11 @@ class drink_rum(ActionBuilder): """ def get_actions(self, caller, memory): for pct in memory.of_class(PositionPrecept): + print "looking for rum", pct if pct.position[0] == 'self' and pct.entity.name == "rum": action = DrinkRumAction(caller) action.effects.append(SimpleGoal(is_drunk=True)) - action.effects.append(EvalGoal("charisma = charisma + 10")) + #action.effects.append(EvalGoal("charisma = charisma + 10")) yield action diff --git a/pathfinding/astar.py b/pathfinding/astar.py index c371429..1ebe0e3 100644 --- a/pathfinding/astar.py +++ b/pathfinding/astar.py @@ -60,7 +60,6 @@ def search(start, finish, factory): finishNode = factory(finish) startNode = factory(start) - print finishNode, startNode startNode.h = calcH(startNode, finishNode) # used to locate nodes in the heap and modify their f scores diff --git a/pygoap/agent.py b/pygoap/agent.py index 33f8c3c..097821e 100644 --- a/pygoap/agent.py +++ b/pygoap/agent.py @@ -97,7 +97,7 @@ def replan(self): s = [ g for g in s if g[0] > 0.0 ] s.sort(reverse=True) - debug("[agent] goals %s", s) + debug("[agent] %s goals %s", self, s) start_action = NullAction diff --git a/pygoap/tiledenvironment.py b/pygoap/tiledenvironment.py index 59894f0..d88d885 100644 --- a/pygoap/tiledenvironment.py +++ b/pygoap/tiledenvironment.py @@ -29,7 +29,6 @@ def render(self, surface): for t in self.entities: env, (x, y) = self.get_position(t) - print env, x, y x *= self.tiledmap.tilewidth y *= self.tiledmap.tileheight