From RoboWiki
Jump to: navigation, search
FloodGrapher Sub-pages:
FloodGrapherDesign - Troubleshooting

package kawigi.tools;

Grapher back-end

  • class Scheme : Aggregate of GrapherSegmentations
public GrapherSegmentation segmentAt(int index)
public int size()
public void add(GrapherSegmentation seg)
  • class SegmentedData : A sort of database using the Scheme that can be "selected" from to collect actual data. It should be flexible enough that it should be unnecessary to subclass it. This class should be easily createable from the information saved by the Graphing bot, and may also have a constructor to take the array of data and scheme, so that it can be extended to analyze data from other bots.
private Scheme scheme
private Object statsbuffer : a multi-dimensional array of numbers whose dimensionality is one more than the size of the scheme. Shouldn't be jagged (so a finite number of buckets can be used to take any cross-section of the data).
public SegmentedData(Scheme scheme, Object stats) : Creates a new SegmentedData object. stats should be a non-jagged multi-dimensional array of doubles, the size of the scheme should be one less than the dimensionality of the stats (if not, expect crashes later).
public void createSelectionGUI(GraphControlWindow window) : Sets up the GraphControlWindow to have all the necessary widgets to select a graph. The components added to this window will come from the GrapherSegmentation objects in the Scheme. The window is also an ActionListener and ItemListener and should be added as a listener to the relevant components.
public GraphData getSelectedGraphData() : This is the main point of this class, to get the data selected through the various GUI components.
public void setData(SegmentedData reload) : sets the data in this object to the data in reload. This is used to "refresh" the graph and keep the same UI.
  • interface GrapherSegmentation : represents a SegmentationAxis.
public String getName() : gets the name of this segmentation axis
public void addSelectionWidget(GraphControlWindow window) : adds a component (most often a JComboBox) to select information from this segmentation, as well as necessary listeners, to the window. The object should keep a reference to this component and only one such widget should ever be associated with each GrapherSegmentation object.
public boolean accept(int index) : returns true if the current state of the widget accepts this segment index. Returns false if it does not or if the widget has not yet been created.
    • Some possible subclasses: DistanceGSegmentation, BFTGSegmentation, LateralVelocityGSegmentation, AccelerationGSegmentation, WallGSegmentation
  • class GraphData: contains the array of values to be graphed for a single line graph, and the intended color, which can occasionally be changed.
public GraphData(Color c, double[] data)
public GraphData(double[] data)
public Color getColor()
public void setColor(Color newcolor)
public double[] getData()
  • interface FileFormat: Represents the format a robot's data file is saved in. Implementations should have an empty constructor.
public SegmentedData getData(File datafile) throws IOException, InvalidFileException
public String getFormatName() : Used when the object is dynamically loaded with other FileFormat objects to create a list of possible objects to use on a given file.
  • Possible Subclasses: FloodGrapherFileFormat, FloodMini14FileFormat, Fhqwhgads11FileFormat, JekylFileFormat
  • class InvalidFileException extends Exception : Thrown when the wrong FileFormat is used to read a certain file.
public InvalidFileException(String message)

Grapher front-end

  • class GraphColorSelector: A simple widget with a spectrum of saturated, bright colors to choose from.

Color getSelectedColor()

  • class GraphDisplay extends JPanel: A widget that shows a series of GraphData objects in their respective colors. Only one graph will be kept for each GraphControlWindow to create the graphs.
public void addGraph(GraphData graph, GraphControlWindow source) : adds the new graph or replaces the old one from this source if one exists
public void removeGraph(GraphControlWindow source) : removes the graph associated with the given frame from the display. Called when the GraphControlWindow is closed.
    • This class may have more options like smoothing or something.
  • GraphControlWindow extends JInternalFrame implements ItemListener, ActionListener, InternalFrameListener
public GraphControlWindow(SegmentedData data, String name, GraphDisplayer ) : the name is set on the title bar of the window, the GUI components are added to it for the segmentation of the graph as well as a GraphColorSelector and a refresh button.
public void actionPerformed(ActionEvent event) : for interface ActionListener. Updates the GraphDisplayer.
public void itemStateChanged(ItemEvent event) : for interface ItemListener. Updates the GraphDisplayer
public void internalFrameClosing(InternalFrameEvent event) : disposes of the window after removing the graph associated with this window from the GraphDisplay
public void internalFrameDidWhatever(InternalFrameEvent event) : whatever else is necessary to satisfy interface InternalFrameListener, these probably won't do anything exciting.
  • NewGraphWindow extends JDialog : includes components to choose a file and a FileFormat to use to open it and OK/Cancel buttons, has some sort of callback mechanism to add a GraphControlWindow back into the main GUI when the OK button is pressed. The JDesktopPane will probably be passed into the constructor or something.
  • FloodGrapherGUI extends JFrame : This is the container for the entire Graphing utility. It contains mainly a GraphDisplayer, a JDesktopPane, and a JMenuBar. The menus have the ability to open files and select from available FileFormat objects, close the application, and possibly some other features with the display. The JDesktopPane will contain some number of GraphControlWindow which will control the GraphDisplayer.

Robot Design

  • FloodGrapher extends AdvancedRobot : robot that creates and uses the configured modules. If robots are allowed to do so, it should try to dynamically load these classes based on what it reads from a config file:
    • Config file info:
      • Movement class
      • PowerManagement class
      • Segmentation classes (comma seperated?)
      • Distancing algorithm (dynamic | min=xxx,max=yyy | uncontrolled)
      • Wave Timing (scan | fire)
      • Number of Guess Factors (default 31?)
  • class WaveBullet - pretty self-explanitory. Includes a "segment" (array of numbers) to return to, has an update/check method, probably like MiniBullet but more clear.
  • interface Movement : Represents a movement strategy. These should be easily dynamically loadable, i.e. - have a parameterless constructor.
public void onEvent(Event, AdvancedRobot)
public void run(AdvancedRobot) : called in the run loop of the robot
    • Subclasses: StationaryMovement : for TC-type tests, sort of an oxymoron, FloodMovement: Like FloodMini, FhqwhgadsMovement: Like Fhqwhgads, CigaretMovement: Like Cigaret, LinebackerMovement: Tries to corner you. Good to test against.
  • interface PowerManagement : Used to play with power management. These should be easily dynamically loadable, i.e. - have a parameterless constructor.
public double getPower(ScannedRobotEvent e, AdvancedRobot ar) : returns the power that should be used, or return <= 0 if no shot should be fired.
  • * Subclasses: Power3Only : Useful, also used for TC stuff

FloodMiniPower : The energy management I use in most of my bots, FloodHTPower : A little more complex and strategy oriented power management, ConservativePower : A power management scheme that favors lower powers than 3 most of the time, RandomPower : Might be worthwhile, SparkPower : Might also be interesting, LowPower : Shoots fast bullets

  • interface Segmentation: Robot's version of GrapherSegmentation.
public int numSegments() : returns the total number of possible segments that could be chosen
public GraphingSegmentation getGraphingSegmentation() : This information will probably be stored in the data files, the idea is to convert it directly into a GraphingSegmentation object. There should basically be a corresponding GraphingSegmentation class for each Segmentation class.
public int getSegmentIndex(ScannedRobotEvent e, AdvancedRobot ar, PowerManagement em) : Gets the index of the segment that should be used in the given situation.
    • Subclasses (possibilities are endless): DistanceSegmentation, BFTSegmentation, LateralVelocitySegmentation, AccelerationSegmentation, WallSegmentation, TimeSegmentation, LateralDirectionSegmentation, MeleeSegmentation, (Be creative)

While some of this design was changed by the time it was released (most notably that the GUI panels became plugins themselves), I really stuck to this design in general, not just for the design's sake, but because it just all fit together on paper, and fit together almost as well in code. I suspect that future changes to this design will allow better flexibility for modules and such. -- Kawigi

Personal tools