diff --git a/NOTES b/NOTES index becac1a..a5a78a5 100644 --- a/NOTES +++ b/NOTES @@ -5,42 +5,42 @@ THIS IS MOSTLY NOTES FOR MYSELF planner -planner sould be able to reasonably predict the cost of repeating actions +planner should be able to reasonably predict the cost of repeating actions agents: -in an rpg game, the player can expect to talk to NPC'sr and and to gather +in an rpg game, the player can expect to talk to NPC's and and to gather information about quests, items, other npc's, etc. i think that goap can become an engine of sorts, dictating every action in the game. basic play elements can be emulated through goap and would not have to be explicitly coded into the game. take simple "hello" meet/greet actions with an npc: - npc will have a insatable desire to talk to a player + npc will have a insatiable desire to talk to a player they will have a different thing to say depending on mood/state of player a side effect of this will that npc's could possibly become more lifelike as -they can move around the game world to satisfy goals. to moderate and conrol +they can move around the game world to satisfy goals. to moderate and control the npc's and to make the game more enjoyable, npc's can have goals that are only relevant at certain times of day or days of the week. in the harvest moon series for example, the nps do have certain schedules that they will loosely follow. this makes the game play predictable once their -simple schedule is learned. imo, giving the npc's too much freedom to act wiil -make the game world seem more random, and potentially frusterating to play. +simple schedule is learned. imo, giving the npc's too much freedom to act will +make the game world seem more random, and potentially frustrating to play. tying the speech system to goap agents could make the gameplay more immersive by allowing the player to ask unscripted questions. while developing a system that perfectly synthesizes english is not a viable option, giving the player -the option to ask canned questions, unrealted to the quet or story, with the -ability to choose specfic parts of the question is a definate cool thing. +the option to ask canned questions, unrelated to the quest or story, with the +ability to choose specific parts of the question is a definite cool thing. for example, the player might ask an npc "have you seen gary?". the goap agent can then search it's memories of gary and give a response to the player. because this would be based on the agent's memory, and not some canned -response, it will simotaniously make the make more immersive and releave the -game designers and writters the burden to creating dialog. +response, it will simultaneously make the make more immersive and relieve the +game designers and writers the burden to creating dialog. -a frusterating aspect of some games is dealing with faction alliances. for +a frustrating aspect of some games is dealing with faction alliances. for example, in some games, killing or doing some negative action against a member of a faction will cause all members of that faction to instantly become hostile toward the player. this is unrealistic in situations where the information @@ -48,7 +48,7 @@ that our your hostility could not have reached the other party. simulating the spread of information could also be simulated in goap by creating goals that one agent wants to tell other agents things that he saw the -player do. for example, they may be nuetral npc's that will gossip with other +player do. for example, they may be neutral npc's that will gossip with other npc's in distant towns. or, members of one faction may use radio, phones, letters, messengers, etc to tell other faction members about the player. diff --git a/npc/pirate/actions.py b/npc/pirate/actions.py index b71d52a..d254984 100644 --- a/npc/pirate/actions.py +++ b/npc/pirate/actions.py @@ -1,3 +1,20 @@ +""" +Copyright 2010, 2011 Leif Theden + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + """ This is an example module for programming actions for a pyGOAP agent. diff --git a/npc/pirate/actions.pyc b/npc/pirate/actions.pyc deleted file mode 100644 index 0b449ad..0000000 Binary files a/npc/pirate/actions.pyc and /dev/null differ diff --git a/pirate.prof b/pirate.prof new file mode 100644 index 0000000..8f1cd64 Binary files /dev/null and b/pirate.prof differ diff --git a/pirate.py b/pirate.py index d64d65a..9b2c336 100644 --- a/pirate.py +++ b/pirate.py @@ -1,5 +1,5 @@ """ -Copyright 2010, Leif Theden +Copyright 2010, 2011 Leif Theden This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,13 +20,13 @@ scenerio: the pirate begins by idling - soon....he spyies a woman + soon....he spies a woman he should attempt to get drunk and sleep with her... ...any way he knows how. """ -__version__ = ".008" +__version__ = ".009" from pygoap.agent import GoapAgent from pygoap.environment import ObjectBase @@ -130,13 +130,13 @@ def run_once(): run = False break - if not interactive: break - if event.type == KEYDOWN: if event.key == K_ESCAPE: run = False break + if not interactive: break + if event.type == KEYUP: break if interactive: diff --git a/pygoap/actions.py b/pygoap/actions.py index e7f1075..2506f5b 100644 --- a/pygoap/actions.py +++ b/pygoap/actions.py @@ -1,3 +1,20 @@ +""" +Copyright 2010, 2011 Leif Theden + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + """ These are the building blocks for creating pyGOAP agents that are able to interact with their environment in a meaningful way. @@ -10,14 +27,6 @@ to satisfy the current goal. They will be instanced and the the agent will execute the action in some way, one after another. -There is a delicate balance between the actions here and the "ActionEffects" -and "ActionPrereqs" that you will have to master. A simple way to mentally -distinguish them is that the prereqs and effects are clues to the planner to -behave in a certain way and will never change anything except a blackboard. -The action classes here are the 'guts' for the action and will modify the game -environment in some meaningful way. - - Actions need to be split into ActionInstances and ActionBuilders. An ActionInstance's job is to work in a planner and to carry out actions. @@ -35,7 +44,7 @@ class ActionBuilder(object): """ ActionBuilders examine a blackboard and return a list of actions - that can be succesfully completed at the the time. + that can be successfully completed at the the time. """ def get_actions(self, caller, bb): @@ -173,7 +182,7 @@ def pause(self): class CalledOnceAction(CallableAction): """ - Is finished imediatly when started. + Is finished immediately when started. """ def start(self): diff --git a/pygoap/agent.py b/pygoap/agent.py index a6d8cd1..fa3bbd6 100644 --- a/pygoap/agent.py +++ b/pygoap/agent.py @@ -1,5 +1,18 @@ """ -fill in later +Copyright 2010, 2011 Leif Theden + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . """ from environment import ObjectBase @@ -23,9 +36,7 @@ class GoapAgent(ObjectBase): """ AI Agent - every agent should have at least one goal (otherwise, why use it?) inventories will be implemented using precepts and a list. - currently, only one action running concurrently is supported. """ @@ -36,13 +47,12 @@ class GoapAgent(ObjectBase): def __init__(self): self.idle_timeout = 30 self.bb = Blackboard() - self.mem_manager = MemoryManager(self) + #self.mem_manager = MemoryManager(self) self.planner = plan self.current_goal = None self.goals = [] # all goals this instance can use - self.invalid_goals = [] # goals that cannot be satisfied now self.filters = [] # list of methods to use as a filter self.actions = [] # all actions this npc can perform self.plan = [] # list of actions to perform diff --git a/pygoap/blackboard.py b/pygoap/blackboard.py index 6007eb5..06c9021 100644 --- a/pygoap/blackboard.py +++ b/pygoap/blackboard.py @@ -1,7 +1,26 @@ +""" +Copyright 2010, 2011 Leif Theden + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + """ Memories are stored precepts. A blackboard is a device to share information amongst actions. This implementation uses sqlite3 as a backend for storing memories. + +The MemManager class is not used. """ import sqlite3 @@ -43,8 +62,8 @@ def __init__(self, owner, value): # initialize our database -engine = create_engine('sqlite://') -Base.metadata.create_all(engine) +#engine = create_engine('sqlite://') +#Base.metadata.create_all(engine) class MemoryManager(object): diff --git a/pygoap/environment.py b/pygoap/environment.py index 48a16df..1aa2710 100644 --- a/pygoap/environment.py +++ b/pygoap/environment.py @@ -1,6 +1,23 @@ +""" +Copyright 2010, 2011 Leif Theden + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + """ Since a pyGOAP agent relies on cues from the environment when planning, having -a stable and effecient virtual environment is paramount. +a stable and efficient virtual environment is paramount. When coding your game or simulation, you can think of the environment as the conduit that connects your actors on screen to their simulated thoughts. This @@ -13,7 +30,6 @@ """ from actionstates import * -from objectflags import * from itertools import chain, repeat, product, izip @@ -159,7 +175,7 @@ def update(self, time_passed): def broadcast_precepts(self, precepts, agents=None): """ - for effeciency, please use this for sending a list of precepts + for efficiency, please use this for sending a list of precepts """ if agents == None: @@ -174,12 +190,12 @@ def model_precept(self, precept, other): """ override this to model the way that precept objects move in the simulation. by default, all precept objects will be distributed - indiscrimitely to all agents. + indiscriminately to all agents. - while this behaviour may be desireable for some types of precepts, + while this behavior may be desirable for some types of precepts, it doesn't make sense in many. - the two big thigs to model here would be vision and sound. + the two big things to model here would be vision and sound. """ return precept diff --git a/pygoap/environment2d.py b/pygoap/environment2d.py index d6c3df2..98c4dd7 100644 --- a/pygoap/environment2d.py +++ b/pygoap/environment2d.py @@ -1,6 +1,23 @@ +""" +Copyright 2010, 2011 Leif Theden + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + """ Since a pyGOAP agent relies on cues from the environment when planning, having -a stable and effecient virtual environment is paramount. This environment is +a stable and efficient virtual environment is paramount. This environment is simply a placeholder and demonstration. When coding your game or simulation, you can think of the environment as the diff --git a/pygoap/goals.py b/pygoap/goals.py index d7b9b27..d43163d 100644 --- a/pygoap/goals.py +++ b/pygoap/goals.py @@ -1,3 +1,20 @@ +""" +Copyright 2010, 2011 Leif Theden + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + """ Goals in the context of a pyGOAP agent give the planner some direction when planning. Goals are known to the agent and are constantly monitored and @@ -7,6 +24,9 @@ See the modules effects.py and goals.py to see how these are used. +The Goal class has a lot of uses in the engine, see the pirate's actions for +an idea of what they are used for. Not all of the goals here are used/tested. + test() should return a float from 0-1 on how successful the action would be if carried out with the given state of the bb. diff --git a/pygoap/goaltests.py b/pygoap/goaltests.py deleted file mode 100644 index c5c2eee..0000000 --- a/pygoap/goaltests.py +++ /dev/null @@ -1,2 +0,0 @@ -import unittest - diff --git a/pygoap/objectflags.py b/pygoap/objectflags.py deleted file mode 100644 index 3ffcad0..0000000 --- a/pygoap/objectflags.py +++ /dev/null @@ -1,20 +0,0 @@ -states = """ -liquid -glowing -hot -frozen -burning -normal -dead -dying -bleeding -cracked -broken -hard -soft -sticky -ooze -gas -""".strip().split('\n') - - diff --git a/pygoap/planning.py b/pygoap/planning.py index d03c56a..dfab784 100644 --- a/pygoap/planning.py +++ b/pygoap/planning.py @@ -1,6 +1,35 @@ """ -Goals and prereqs are related. The Vaildator class system removes the need to -duplicate similar functions. +Copyright 2010, 2011 Leif Theden + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + +""" +Copyright 2010, 2011 Leif Theden + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . """ from blackboard import Blackboard diff --git a/pygoap/tiledenvironment.py b/pygoap/tiledenvironment.py index bbe6a23..3e3e370 100644 --- a/pygoap/tiledenvironment.py +++ b/pygoap/tiledenvironment.py @@ -1,3 +1,20 @@ +""" +Copyright 2010, 2011 Leif Theden + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + from environment2d import XYEnvironment import tmxloader from pygame import Surface diff --git a/pygoap/util.py b/pygoap/util.py deleted file mode 100644 index 2eb8b3b..0000000 --- a/pygoap/util.py +++ /dev/null @@ -1,10 +0,0 @@ - -DEBUG = False - - - -def dlog(text): - print text - - -