Skip to content

Commit

Permalink
misc documentation cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bitcraft committed Jan 20, 2012
1 parent d25d6d3 commit 238837d
Show file tree
Hide file tree
Showing 16 changed files with 197 additions and 75 deletions.
24 changes: 12 additions & 12 deletions NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,50 @@ 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
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.

Expand Down
17 changes: 17 additions & 0 deletions npc/pirate/actions.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
"""

"""
This is an example module for programming actions for a pyGOAP agent.
Expand Down
Binary file removed npc/pirate/actions.pyc
Binary file not shown.
Binary file added pirate.prof
Binary file not shown.
10 changes: 5 additions & 5 deletions pirate.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
29 changes: 19 additions & 10 deletions pygoap/actions.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
"""

"""
These are the building blocks for creating pyGOAP agents that are able to
interact with their environment in a meaningful way.
Expand All @@ -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.
Expand All @@ -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):
Expand Down Expand Up @@ -173,7 +182,7 @@ def pause(self):

class CalledOnceAction(CallableAction):
"""
Is finished imediatly when started.
Is finished immediately when started.
"""

def start(self):
Expand Down
20 changes: 15 additions & 5 deletions pygoap/agent.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
"""

from environment import ObjectBase
Expand All @@ -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.
"""

Expand All @@ -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
Expand Down
23 changes: 21 additions & 2 deletions pygoap/blackboard.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
"""

"""
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
Expand Down Expand Up @@ -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):
Expand Down
28 changes: 22 additions & 6 deletions pygoap/environment.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
"""

"""
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
Expand All @@ -13,7 +30,6 @@
"""

from actionstates import *
from objectflags import *
from itertools import chain, repeat, product, izip


Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
19 changes: 18 additions & 1 deletion pygoap/environment2d.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
"""

"""
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
Expand Down
20 changes: 20 additions & 0 deletions pygoap/goals.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
"""

"""
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
Expand All @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions pygoap/goaltests.py

This file was deleted.

20 changes: 0 additions & 20 deletions pygoap/objectflags.py

This file was deleted.

Loading

0 comments on commit 238837d

Please sign in to comment.