public class VisualExplorer extends javax.swing.JFrame implements ShellObserver
Environment
.
States are
conveyed to the user through a 2D visualization and the user specifies actions
by either pressing keys that are mapped to actions or by typing the actions into the action command field.
Action parameters in the action field are specified by space delineated input. For instance: "stack block0 block1" will cause
the stack action to called with action parameters block0 and block1. The ` key
causes the environment to reset.
EnvironmentShell
that you can access using the "Show Shell" button. You can use the shell to modify the state (assuming the input
Environment
implements StateSettableEnvironment
,
record trajectories that you make in the environment, and any number of other tasks. The shell's "programs," specified with
ShellCommand
instances, may also be expanded so that you can create your own runtime tools.
See the BurlapShell
and EnvironmentShell
Java doc for more information on how
to use them. If you need access to the shell instance, you can get it with the getShell()
method. You can
also set shell commands to be executed when a key is pressed in the visualization. Set them with the
addKeyShellCommand(String, String)
method.
Modifier and Type | Class and Description |
---|---|
class |
VisualExplorer.LivePollCommand
Shell command that allow live polling of the
VisualExplorer to be polled. |
javax.swing.JFrame.AccessibleJFrame
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
java.awt.Container.AccessibleAWTContainer
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
ShellObserver.ShellCommandEvent
Modifier and Type | Field and Description |
---|---|
protected javax.swing.JButton |
actionButton |
protected java.awt.TextField |
actionField |
protected int |
cHeight |
protected javax.swing.JFrame |
consoleFrame |
protected EpisodeAnalysis |
currentEpisode |
protected int |
cWidth |
protected Domain |
domain |
protected Environment |
env |
protected boolean |
isRecording |
protected java.util.Map<java.lang.String,GroundedAction> |
keyActionMap |
protected java.util.Map<java.lang.String,java.lang.String> |
keyShellMap |
protected double |
lastReward |
protected int |
numSteps |
protected Visualizer |
painter |
protected long |
pollInterval |
protected java.awt.TextArea |
propViewer |
protected java.util.List<EpisodeAnalysis> |
recordedEpisodes |
protected boolean |
runLivePolling |
protected EnvironmentShell |
shell |
protected javax.swing.JTextArea |
stateConsole |
protected TextAreaStreams |
tstreams |
protected java.lang.String |
warningMessage |
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Constructor and Description |
---|
VisualExplorer(Domain domain,
Environment env,
Visualizer painter)
Initializes with a visualization canvas size set to 800x800.
|
VisualExplorer(Domain domain,
Environment env,
Visualizer painter,
int w,
int h)
Initializes.
|
VisualExplorer(Domain domain,
Visualizer painter,
State baseState)
Initializes with a domain and initial state, automatically creating a
SimulatedEnvironment
as the environment with which to interact. |
Modifier and Type | Method and Description |
---|---|
void |
addKeyAction(java.lang.String key,
GroundedAction action)
Specifies which action to execute for a given key press
|
void |
addKeyAction(java.lang.String key,
java.lang.String actionStringRep)
Specifies a string representation of an action to execute when the specified key is pressed.
|
void |
addKeyShellCommand(java.lang.String key,
java.lang.String shellCommand)
Cause a shell command to be executed when key is pressed with the visualizer highlighted.
|
protected void |
executeAction(GroundedAction ga)
Executes the provided
GroundedAction in the explorer's environment and records
the result if episodes are being recorded. |
protected void |
executeAction(java.lang.String[] comps)
Executes the action defined in string array with the first component being the action name and the rest the parameters.
|
protected GroundedAction |
getGroundedActionFromStringComps(java.lang.String[] comps)
Gets the
GroundedAction described by the
String components where the first component is the action name and the rest
are the string representations of the parameters. |
EnvironmentShell |
getShell()
Returns the
EnvironmentShell instance associated with this object. |
Visualizer |
getVisualizer()
Returns the
Visualizer used by this explorer. |
protected void |
handleExecute()
Handles action execute button.
|
protected void |
handleKeyPressed(java.awt.event.KeyEvent e)
Handles key presses
|
protected void |
init(Domain domain,
Environment env,
Visualizer painter,
int w,
int h) |
void |
initGUI()
Initializes the visual explorer GUI and presents it to the user.
|
void |
observeCommand(BurlapShell shell,
ShellObserver.ShellCommandEvent event)
Received whenever a
ShellCommand completes execution. |
void |
startLiveStatePolling(long msPollDelay)
Starts a thread that polls this explorer's
Environment every
msPollDelay milliseconds for its current state and updates the visualizer to that state. |
void |
stopLivePolling()
Stops this class from live polling this explorer's
Environment . |
protected void |
updatePropTextArea(State s)
Updates the propositional function evaluation text display for the given state.
|
void |
updateState(State s)
Updates the currently visualized state to the input state.
|
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected Environment env
protected Domain domain
protected java.util.Map<java.lang.String,GroundedAction> keyActionMap
protected java.util.Map<java.lang.String,java.lang.String> keyShellMap
protected Visualizer painter
protected java.awt.TextArea propViewer
protected java.awt.TextField actionField
protected javax.swing.JButton actionButton
protected int cWidth
protected int cHeight
protected int numSteps
protected javax.swing.JFrame consoleFrame
protected javax.swing.JTextArea stateConsole
protected EpisodeAnalysis currentEpisode
protected java.util.List<EpisodeAnalysis> recordedEpisodes
protected double lastReward
protected java.lang.String warningMessage
protected boolean isRecording
protected boolean runLivePolling
protected long pollInterval
protected EnvironmentShell shell
protected TextAreaStreams tstreams
public VisualExplorer(Domain domain, Visualizer painter, State baseState)
SimulatedEnvironment
as the environment with which to interact. The created SimulatedEnvironment
will
have a NullRewardFunction
and NullTermination
functions set.domain
- the domain to explorepainter
- the 2D state visualizerbaseState
- the initial state from which to explorepublic VisualExplorer(Domain domain, Environment env, Visualizer painter)
domain
- the domain to exploreenv
- the Environment
with which to interact.painter
- the 2D state visualizerpublic VisualExplorer(Domain domain, Environment env, Visualizer painter, int w, int h)
domain
- the domain to exploreenv
- the Environment
with which to interact.painter
- the 2D state visualizerw
- the width of the visualizer canvash
- the height of the visualizer canvasprotected void init(Domain domain, Environment env, Visualizer painter, int w, int h)
public Visualizer getVisualizer()
Visualizer
used by this explorer.Visualizer
used by this explorer.public EnvironmentShell getShell()
EnvironmentShell
instance associated with this object.EnvironmentShell
instance associated with this object.public void addKeyAction(java.lang.String key, java.lang.String actionStringRep)
key
- the key that is pressed by the useractionStringRep
- the GroundedAction
to take when the key is pressedpublic void addKeyAction(java.lang.String key, GroundedAction action)
key
- the key that is pressed by the useraction
- the GroundedAction
to take when the key is pressedpublic void addKeyShellCommand(java.lang.String key, java.lang.String shellCommand)
key
- the key to activate the shell command.shellCommand
- the shell command to execute.public void startLiveStatePolling(long msPollDelay)
Environment
every
msPollDelay milliseconds for its current state and updates the visualizer to that state.
Polling can be stopped with the stopLivePolling()
. If live polling is already running,
this method call will only change the poll rate.msPollDelay
- the number of milliseconds between environment polls and state updates.public void stopLivePolling()
Environment
.public void observeCommand(BurlapShell shell, ShellObserver.ShellCommandEvent event)
ShellObserver
ShellCommand
completes execution.observeCommand
in interface ShellObserver
shell
- the calling BurlapShell
event
- the command event, stored as a ShellObserver.ShellCommandEvent
public void initGUI()
public void updateState(State s)
s
- the state to visualize.protected void handleExecute()
protected void handleKeyPressed(java.awt.event.KeyEvent e)
e
- the key eventprotected void executeAction(java.lang.String[] comps)
comps
- the string array defining hte action to be executed.protected GroundedAction getGroundedActionFromStringComps(java.lang.String[] comps)
GroundedAction
described by the
String components where the first component is the action name and the rest
are the string representations of the parameters.comps
- the string components that define the GroundedAction
GroundedAction
or null if it cannot be constructed.protected void executeAction(GroundedAction ga)
GroundedAction
in the explorer's environment and records
the result if episodes are being recorded.ga
- the GroundedAction
to execute.protected void updatePropTextArea(State s)
s
- the input state on which propositional functions are to be evaluated.