Package teamwork :: Package shell :: Module PsychShell :: Class PsychShell
[hide private]
[frames] | no frames]

Class PsychShell

source code

Known Subclasses:

The base API for the PsychSim engine

Instance Methods [hide private]
 
__init__(self, scenario=None, classes=None, agentClass=None, multiagentClass=None, debug=0) source code
 
setupScenario(self, agents, progress=None)
initialize PsychShell with given scenario
source code
multiagentClass
setupEntities(self, entities=None, progress=None, compileDynamics=True, compilePolicies=None, distill=False)
Creates a scenario instance from a list of entities and applies the default values across the board
source code
 
initEntities(self, progress=None)
A method, to be overridden by subclass, that is invoked whenever there is a new set of entities
source code
str
getCommand(self)
Abstract method for getting a command from user.
source code
 
executeCommand(self, cmd) source code
 
displayResult(self, cmd, result)
Abstract method for displaying a result to the user
source code
 
save(self, filename=None, results=None)
Saves the state of the current simulation to the named file
source code
 
saveSociety(self, filename=None, results=None)
Saves the current generic society to the named file
source code
 
load(self, filename=None, results=None)
Loads in a scenario object from the specified file
source code
 
loadSociety(self, filename=None, overwrite=True, results=None)
Loads in a GenericSociety object from the specified file
source code
 
export(self, filename=None, results=None)
Writes a Web page representation of the current scenario
source code
 
distill(self, filename=None, results=None)
Writes a lightweight representation of the current scenario
source code
 
revert(self)
Reverts the current scenario to the last loaded/saved scenario
source code
 
step(self, length=1, results=None)
Steps the simulation the specified number of micro-steps into the future (default is 1)
source code
 
goals(self, results=None) source code
 
send(self, sender, receiver, *content) source code
 
applyPolicy(self, name, results=None)
Returns the action that <entity> will perform, following its policy of behavior
source code
 
setDebugLevel(self, level, results=None)
Sets the debug level to the specified integer
source code
 
getEntities(self, results=None) source code
 
help(self, results=None)
Prints descriptions of available commands
source code
 
test(self, label, results=None) source code
 
undo(self, results=None) source code
 
getEntity(self, name, results=None)
Returns a string representation of the named entity.
source code
 
getBelief(self, entityName, beliefName, results=None)
Returns a string representation of the belief that the first entity has about the second.
source code
 
setModel(self, entityName, beliefName, modelName, results=None)
Sets the mental model that 'entityName' holds in regard to 'beliefName' to be 'modelName'
source code
 
performAct(self, name, actType, obj, results=None)
Performs the action of the specified type by the named entity on the specified object (use 'nil' if no object)
source code
 
doActions(self, actions, results=None)
Performs the actions, provided in dictionary form
source code
 
__act__(self, actList, results) source code
 
execute(self, cmd, results=None) source code
 
search(self, feature) source code
 
__search__(self, entity, feature) source code
 
setupSusceptibility(self, addr=None) source code
 
querySusceptibility(self, entity) source code
 
handleMsg(self, msgList) source code
 
handleSusceptibility(self, entity, themes) source code
 
iterateModels(self, eList, pIndex, cIndex, modelsUsed) source code
 
resetSociety(self)
Clears any classes in the current generic society
source code
 
mainloop(self) source code
 
stop(self) source code
Class Variables [hide private]
  __VERSION__ = '1.8beta'
the version of this shell
boolean __UNDO__ = False
flag indicating whether UNDO operations are supported
boolean __KQML__ = False
flag indicating whether KQML communication is supported
  actionFormat = [('actor', True), ('type', True), ('object', Fa...
Instance Variables [hide private]
  agentClass
the class of individual agents in the scenario (default is PsychEntity)
  multiagentClass
the class of the current scenario (default is SequentialAgents)
Method Details [hide private]

__init__(self, scenario=None, classes=None, agentClass=None, multiagentClass=None, debug=0)
(Constructor)

source code 
Parameters:

setupScenario(self, agents, progress=None)

source code 

initialize PsychShell with given scenario

Parameters:
  • agents (MultiagentSimulation) - the scenario to interact with
  • progress (lambda) - optional progress display command

setupEntities(self, entities=None, progress=None, compileDynamics=True, compilePolicies=None, distill=False)

source code 

Creates a scenario instance from a list of entities and applies the default values across the board

Parameters:
  • entities (Agent[]) - the entities to use in populating the scenario
  • progress (Queue) - optional Queue argument is used to give progress updates, in the form of (label,pct), where:
    • label: a string label to display for the current task
    • pct: an integer percentage (1-100) representing the amount of progress made since the last call

    The thread puts None into the queue when it has finished.

  • compileDynamics (boolean) - Flag indicating whether the scenario dynamics should be compiled as well (default is True)
  • compilePolicies (int) - The belief depth at which all agents will have their policies compiled, where 0 is the belief depth of the real agent. If the value of this flag is n, then all agents at belief depth≥n will have their policies compiled, while no agents at belief depth<n will. If omitted, no policies will be compiled
  • distill (bool) - If True, then create a distilled version of these agents (default is False
Returns: multiagentClass
a newly created scenario instance

displayResult(self, cmd, result)

source code 

Abstract method for displaying a result to the user

Parameters:
  • cmd (str) - the command executed
  • result (str[]) - the results of the command

loadSociety(self, filename=None, overwrite=True, results=None)

source code 

Loads in a GenericSociety object from the specified file

Parameters:
  • overwrite (boolean) - flag indicating, when True that the existing society should be erased before loading in the new one

doActions(self, actions, results=None)

source code 

Performs the actions, provided in dictionary form

Parameters:
  • actions (dict:str→Action[]) - dictionary of actions to be performed, indexed by actor, e.g.:
    • agent1: [act11, act12, ... ]
    • agent2: [act21, act22, ... ]
    • ...

Class Variable Details [hide private]

actionFormat

Value:
[('actor', True), ('type', True), ('object', False)]