Package teamwork :: Package widgets :: Package PsychGUI :: Module Gui :: Class GuiShell
[hide private]
[frames] | no frames]

Class GuiShell

source code

shell.PsychShell.PsychShell --+
                              |
                             GuiShell
Known Subclasses:

Subclass for Tk interface to PsychSim

Key components for manipulating Generic Societies:

Key components for manipulating Instantiated Scenarios:

Instance Methods [hide private]
 
__init__(self, scenario=None, classes=None, agentClass=None, multiagentClass=None, expert=False, dev=False, debug=0)
Constructor
source code
 
drawTime(self)
Updates the simulation time in the toolbar display
source code
 
updateEditMenu(self, selection, window) source code
 
copy(self, event=None, cmd='copy') source code
 
cut(self, event=None) source code
 
paste(self, event=None) source code
 
setupScenario(self, agents, progress=None)
initialize PsychShell with given scenario
source code
 
showWindow(self, name)
Pops up an agent window for the named entity (creates the window if it has not already been drawn)
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
 
chooseObjectives(self)
Dialog box for fitting scenario to observed behavior
source code
 
viewMAID(self) source code
 
removeAgent(self, entity)
Removes the given entity from the simulation
source code
 
destroyAgentWin(self, window)
Cleans up after removing the window for a given entity
source code
 
renameAgent(self, old, new)
Changes the name and references to a given agent
source code
 
addAgent(self, entity, agent=None)
Adds an agent as a child of the given entity
source code
 
_addAgent(self, button, agent=None)
Callback from name dialog that actually adds the agent
source code
 
validateName(self, name)
Checks whether the new name being entered in the agent dialog is valid or not
source code
 
checkNameValidity(self)
Disables the OK button on the agent name dialog if the current text entry is invalid
source code
 
editOrder(self)
Edits the turn order
source code
 
_editOrder(self, button)
Callback from name dialog that actually adds the agent
source code
 
setState(self, state=None) source code
 
doFitting(self, actor, action, step)
Fits the agents' goal weights based on behavior in fit window
source code
 
__doFitting(self, name, action, step)
Fitting helper method (for running in background)
source code
 
doActions(self, actions, results=None)
Performs the actions, provided in dictionary form
source code
 
realStep(self, entity=None, choices=None, iterations=1)
Queries and performs the given entity for its hypothetical choice
source code
 
hypoStep(self, entity=None, choices=None, iterations=1)
Queries and displays the given entity for its hypothetical choice
source code
 
hypothetical(self, entity=None, real=False, choices=None, iterations=1, explain=False, suggest=False) source code
str[]
actionCheck(self)
Verifies that all agents in the current turn sequence have at least one action available to perform.
source code
 
singleHypothetical(self, entity=None, real=False, choices=None, history=None, explain=False, suggest=False) source code
 
validate(self) source code
 
modeSelect(self, but) source code
 
splash(self, soundFile=None) source code
 
drawMenubar(self) source code
 
viewSelect(self, view=None, alreadyLoaded=False)
Toggles between views of generic society and specific scenario
source code
 
toggleBalloon(self)
Toggles visibility of balloon helpIt might not be a good idea to toggle this off right now
source code
 
setExpert(self)
Sets the expert mode for the overall GUI
source code
 
createAgentWin(self, entity, x=0, y=0)
Creates an agent window for the given entity at the given point
source code
 
addToMenu(self, name, menu, index='end')
Adds a new entry to the given menu for an entity, and any descendents
source code
 
clear(self) source code
 
close(self, event=None, load=False) source code
 
setupSusceptibility(self, addr=None) source code
 
selectSusceptibility(self) source code
 
handleSusceptibility(self, entity, themes) source code
 
displayActions(self, fullresult, step=-1)
Displays any explanation from the performance of actions in the appropriate AAR windows
source code
 
background(self, target, event=None, label='Running', kwargs={})
Runs the target command in a background thread.
source code
 
stopBackground(self) source code
 
finishBackground(self)
Cleans up after a background simulation thread
source code
 
expectedValue(self, entity, world=None, description=None, initial=None, background=1, display=1)
Computes and displays the reward expected by the given entity
source code
 
__expectedValue(self, entity, world, description, initial, display=1)
Background computation of expected value
source code
 
step(self, length=1, results=None)
Step forward by a single round of actions by the entities
source code
 
__step(self)
Execution of a step intended for background running
source code
 
compilePolicy(self, entity)
Displays the rules of entity's policy in the given widget
source code
 
__compilePolicy(self, entity, options)
Displays the decision-tree of entity's policy using the given command
source code
 
displayPolicy(self, entity) source code
 
run(self, num=0) source code
 
msgSend(self, sender, receiver, subject, msg, force, overhear, evaluateOnly=None) source code
 
query(self, sender, receiver, subject, msg, force, overhear) source code
 
evaluateMsg(self, sender, receiver, subject, msg, force, overhear) source code
 
__msgSend(self, sender, receiver, subject, msg, force, overhear, world, background=1, hypothetical=None) source code
 
performMsg(self, world, msg, sender, receiver, overhear, subject, background=1, hypothetical=None) source code
 
view(self)
Pops up the properties dialog
source code
 
popupDynamics(self, key, action, dialog) 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
 
_distill(self, filename) source code
 
createScenario(self, args=None)
Pops up a wizard dialog to instantiate scenario
source code
 
saveBoth(self, event=None) source code
 
saveAs(self, filename=None) source code
 
saveScenario(self, filename=None) source code
 
_saveScenario(self, filename) source code
 
saveSociety(self, filename=None)
Saves the current generic society to the named file
source code
 
_saveSociety(self, filename) source code
 
load(self, event=None, filename=None, results=[])
Loads a scenario in from a file
source code
 
revert(self)
Reverts the current scenario back to the last saved version
source code
 
incUpdate(self, res=None, actType=None, actor=None) source code
 
seedMessage(self, name, args) source code
 
translateReward(self, rew, name) source code
 
mainloop(self) source code
 
poll(self) source code
 
handleCommand(self, args) source code
 
stop(self, event=None) source code

Inherited from shell.PsychShell.PsychShell: __act__, __search__, applyPolicy, displayResult, execute, executeCommand, getBelief, getCommand, getEntities, getEntity, goals, handleMsg, help, iterateModels, loadSociety, performAct, querySusceptibility, resetSociety, save, search, send, setDebugLevel, setModel, setupEntities, test, undo

Class Variables [hide private]
  titleLabel = 'PsychSim'
  simulationLabel = 'Simulation'
  explanationLabel = 'expcascade'

Inherited from shell.PsychShell.PsychShell: __KQML__, __UNDO__, __VERSION__, actionFormat

Instance Variables [hide private]
bool dev
flag, iff True, then show development features
str→Menu menus
dictionary of all of the individual pulldown menus (indexed by label of menu

Inherited from shell.PsychShell.PsychShell: agentClass, multiagentClass

Method Details [hide private]

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

source code 

Constructor

Parameters:
  • scenario - initial scenario
  • classes - initial generic society
  • agentClass - object class used to create new agents
  • multiagentClass - object class used to create new scenarios
  • debug - level of detail in debugging messages
Overrides: shell.PsychShell.PsychShell.__init__

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
Overrides: shell.PsychShell.PsychShell.setupScenario

initEntities(self, progress=None)

source code 

A method, to be overridden by subclass, that is invoked whenever there is a new set of entities

Overrides: shell.PsychShell.PsychShell.initEntities
(inherited documentation)

renameAgent(self, old, new)

source code 

Changes the name and references to a given agent

Parameters:
  • old,new (str)

doActions(self, actions, results=None)

source code 

Performs the actions, provided in dictionary form

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

actionCheck(self)

source code 

Verifies that all agents in the current turn sequence have at least one action available to perform.

Returns: str[]
any agents who do not have any such actions

setupSusceptibility(self, addr=None)

source code 
Overrides: shell.PsychShell.PsychShell.setupSusceptibility

handleSusceptibility(self, entity, themes)

source code 
Overrides: shell.PsychShell.PsychShell.handleSusceptibility

displayActions(self, fullresult, step=-1)

source code 

Displays any explanation from the performance of actions in the appropriate AAR windows

Parameters:
  • fullresult (dict) - an explanation structure, in dictionary form:
    • explanation: a list of 3-tuples of strings, suitable for passing to JiveTalkingAAR.displayAAR
    • agent: explanation substructures for each actor, in dictionary form:
      • decision: the actions chosen by this actor, list format
  • step (int) - the current time step (defaults to the current scenario time

background(self, target, event=None, label='Running', kwargs={})

source code 

Runs the target command in a background thread. This handles the disabling/enabling of the relevant GUI elements.

Parameters:
  • label (str) - optional label that appears in the status bar
  • target (lambda) - the command to run in the background. It should call the finishBackground method when it is done (see __step method for a sample target).

expectedValue(self, entity, world=None, description=None, initial=None, background=1, display=1)

source code 

Computes and displays the reward expected by the given entity

The world defaults to the current scenario. The description is prepended to the AAR. The initial reward value is subtracted from the computed EV (to provide a differential result if desired).

step(self, length=1, results=None)

source code 

Step forward by a single round of actions by the entities

Overrides: shell.PsychShell.PsychShell.step

export(self, filename=None, results=None)

source code 

Writes a Web page representation of the current scenario

Overrides: shell.PsychShell.PsychShell.export

distill(self, filename=None, results=None)

source code 

Writes a lightweight representation of the current scenario

Overrides: shell.PsychShell.PsychShell.distill

saveSociety(self, filename=None)

source code 

Saves the current generic society to the named file

Overrides: shell.PsychShell.PsychShell.saveSociety
(inherited documentation)

load(self, event=None, filename=None, results=[])

source code 

Loads a scenario in from a file

Overrides: shell.PsychShell.PsychShell.load

revert(self)

source code 

Reverts the current scenario back to the last saved version

Overrides: shell.PsychShell.PsychShell.revert

mainloop(self)

source code 
Overrides: shell.PsychShell.PsychShell.mainloop

stop(self, event=None)

source code 
Overrides: shell.PsychShell.PsychShell.stop