public class VisualExplorer
extends javax.swing.JFrame
StateGenerator
object.
Other special kinds of actions
not described in the domain can be added and executed by pressing corresponding keys for them. The episodes of action taken by a user may also be recorded
to a list of recorded episodes and then subsequently polled by a client object. To enable episode recording, use the method
enableEpisodeRecording(String, String)
or enableEpisodeRecording(String, String, RewardFunction)
. To check if the user
is still recording episodes, use the method isRecording()
. To retrieve the recorded episodes, use the method getRecordedEpisodes()
.
setTrackingRewardFunction(burlap.oomdp.singleagent.RewardFunction)
and
setTerminalFunction(burlap.oomdp.core.TerminalFunction)
methods. Once set, the console for the visualizer
will report the last reward received and whether the current state is a terminal state.Modifier and Type | Class and Description |
---|---|
protected class |
VisualExplorer.SaveEpisodeAction
Class for receiving key presses from a
VisualExplorer
that handles it as ending episode recoding and saving all recorded episodes to disk. |
javax.swing.JFrame.AccessibleJFrame
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
Modifier and Type | Field and Description |
---|---|
protected javax.swing.JButton |
actionButton |
protected java.awt.TextField |
actionField |
protected State |
baseState |
protected int |
cHeight |
protected javax.swing.JFrame |
consoleFrame |
protected EpisodeAnalysis |
currentEpisode |
protected State |
curState |
protected int |
cWidth |
protected Domain |
domain |
protected boolean |
isRecording |
protected java.util.Map<java.lang.String,java.lang.String> |
keyActionMap |
protected java.util.Map<java.lang.String,SpecialExplorerAction> |
keySpecialMap |
protected GroundedAction |
lastAction |
protected double |
lastReward |
protected int |
numSteps |
protected Visualizer |
painter |
protected java.awt.TextArea |
propViewer |
protected java.util.List<EpisodeAnalysis> |
recordedEpisodes |
protected java.awt.TextArea |
stateConsole |
protected TerminalFunction |
terminalFunction |
protected RewardFunction |
trackingRewardFunction |
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,
Visualizer painter,
State baseState)
Initializes the visual explorer with the domain to explorer, the visualizer to use, and the base state from which to explore.
|
VisualExplorer(Domain domain,
Visualizer painter,
StateGenerator initialStateGenerator,
int w,
int h)
Initializes the visual explorer with the domain to explorer, the visualizer to use, and an initial state generator from which to explore,
and the dimensions of the visualizer.
|
VisualExplorer(Domain domain,
Visualizer painter,
State baseState,
int w,
int h)
Initializes the visual explorer with the domain to explorer, the visualizer to use, the base state from which to explore,
and the dimensions of the visualizer.
|
Modifier and Type | Method and Description |
---|---|
void |
addKeyAction(java.lang.String key,
java.lang.String action)
Specifies which action to execute for a given key press
|
void |
addSpecialAction(java.lang.String key,
SpecialExplorerAction action)
Specifies which special non-domain action to take for a given key press
|
void |
enableEpisodeRecording(java.lang.String recordLastEpisodeKey,
java.lang.String finishedRecordingKey)
Enables episodes recording of actions taken.
|
void |
enableEpisodeRecording(java.lang.String recordLastEpisodeKey,
java.lang.String finishedRecordingKey,
RewardFunction rewardFunction)
Enables episodes recording of actions taken.
|
void |
enableEpisodeRecording(java.lang.String recordLastEpisodeKey,
java.lang.String finishedRecordingKey,
RewardFunction rewardFunction,
java.lang.String saveDirectory,
StateParser sp)
Enables episodes recording of actions taken.
|
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 java.lang.String |
getConsoleText(State s)
Returns the text that will be printed to the console for the given input state.
|
java.util.List<EpisodeAnalysis> |
getRecordedEpisodes()
Returns the list of episodes recorded by a user.
|
StateResetSpecialAction |
getResetSpecialAction()
Returns a special action that causes the state to reset to the initial state.
|
TerminalFunction |
getTerminalFunction() |
RewardFunction |
getTrackingRewardFunction() |
protected void |
handleExecute()
Handles action execute button.
|
protected void |
handleKeyPressed(java.awt.event.KeyEvent e)
Handles key presses
|
protected void |
init(Domain domain,
Visualizer painter,
StateGenerator stateGeneratorForReset,
int w,
int h) |
void |
initGUI()
Initializes the visual explorer GUI and presents it to the user.
|
boolean |
isRecording()
Returns whether episodes are still be recorded by a user.
|
void |
setTerminalFunction(TerminalFunction terminalFunction) |
void |
setTrackingRewardFunction(RewardFunction trackingRewardFunction) |
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 Domain domain
protected java.util.Map<java.lang.String,java.lang.String> keyActionMap
protected java.util.Map<java.lang.String,SpecialExplorerAction> keySpecialMap
protected State baseState
protected State curState
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 java.awt.TextArea stateConsole
protected EpisodeAnalysis currentEpisode
protected java.util.List<EpisodeAnalysis> recordedEpisodes
protected RewardFunction trackingRewardFunction
protected TerminalFunction terminalFunction
protected GroundedAction lastAction
protected double lastReward
protected java.lang.String warningMessage
protected boolean isRecording
public VisualExplorer(Domain domain, Visualizer painter, State baseState)
domain
- the domain to explorepainter
- the 2D state visualizerbaseState
- the initial state from which to explorepublic VisualExplorer(Domain domain, Visualizer painter, State baseState, int w, int h)
domain
- the domain to explorepainter
- the 2D state visualizerbaseState
- the initial state from which to explorew
- the width of the visualizer canvash
- the height of the visualizer canvaspublic VisualExplorer(Domain domain, Visualizer painter, StateGenerator initialStateGenerator, int w, int h)
domain
- the domain to explorepainter
- the 2D state visualizerinitialStateGenerator
- a generator for initial states that is polled everytime the special reset action is calledw
- the width of the visualizer canvash
- the height of the visualizer canvasprotected void init(Domain domain, Visualizer painter, StateGenerator stateGeneratorForReset, int w, int h)
public RewardFunction getTrackingRewardFunction()
public void setTrackingRewardFunction(RewardFunction trackingRewardFunction)
public TerminalFunction getTerminalFunction()
public void setTerminalFunction(TerminalFunction terminalFunction)
public StateResetSpecialAction getResetSpecialAction()
public void addKeyAction(java.lang.String key, java.lang.String action)
key
- the key that is pressed by the useraction
- the action to take when the key is pressedpublic void addSpecialAction(java.lang.String key, SpecialExplorerAction action)
key
- the key that is pressed by the useraction
- the special non-domain action to take when the key is pressedpublic void enableEpisodeRecording(java.lang.String recordLastEpisodeKey, java.lang.String finishedRecordingKey)
isRecording()
flag
is set to false to let any client objects know that the list of recorded episodes can be safely polled. The list of
recorded episodes can be polled using the method getRecordedEpisodes()
. Rewards stored in the recorded episode will
all be zero.recordLastEpisodeKey
- the key to press to indidcate that the last episode should be recorded/saved.finishedRecordingKey
- the key to press to indicate that no more episodes will be recorded so that the list of recorded episodes can be safely polled by a client object.public void enableEpisodeRecording(java.lang.String recordLastEpisodeKey, java.lang.String finishedRecordingKey, RewardFunction rewardFunction)
isRecording()
flag
is set to false to let any client objects know that the list of recorded episodes can be safely polled. The list of
recorded episodes can be polled using the method getRecordedEpisodes()
.recordLastEpisodeKey
- the key to press to indidcate that the last episode should be recorded/saved.finishedRecordingKey
- the key to press to indicate that no more episodes will be recorded so that the list of recorded episodes can be safely polled by a client object.rewardFunction
- the reward function to use to record the reward received for each action taken.public void enableEpisodeRecording(java.lang.String recordLastEpisodeKey, java.lang.String finishedRecordingKey, RewardFunction rewardFunction, java.lang.String saveDirectory, StateParser sp)
isRecording()
flag
is set to false to let any client objects know that the list of recorded episodes can be safely polled. The list of
recorded episodes is saved to disk in the directory saveDirectory with states parsed using sp.
The list of
recorded episodes can be polled using the method getRecordedEpisodes()
.recordLastEpisodeKey
- the key to press to indidcate that the last episode should be recorded/saved.finishedRecordingKey
- the key to press to indicate that no more episodes will be recorded so that the list of recorded episodes can be safely polled by a client object.rewardFunction
- the reward function to use to record the reward received for each action taken.saveDirectory
- the directory in which all episodes will be savedsp
- the StateParser
to use for parsing states to strings.public boolean isRecording()
public java.util.List<EpisodeAnalysis> getRecordedEpisodes()
public void initGUI()
public void updateState(State s)
s
- the state to visualize.protected java.lang.String getConsoleText(State s)
s
- the state for which the current console text will be generated.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 void updatePropTextArea(State s)
s
- the input state on which propositional functions are to be evaluated.