Project #1: RoboAnt

Using this applet:


If the applet above does not show up, or you see an error, keep reading - you will need to set up the Java Runtime Environment on your computer (dont worry, it's very simple). Otherwise, if you see a text panel and something resembling a maze above, skip down to Section 2 titled "Interface" for instructions on how to program your ant.

1. Instructions for setting up Java

If you have Windows, you can simply go to http://www.java.com/en/download/index.jsp and click on the green "Free Java Download" button:

Here's another helpful link that walks you through installing the Java Runtime Environment (and verifying that it installed correctly) on Windows/Macs/Linux systems:
http://kb.mozillazine.org/Java
Please note that you may also have to change some settings in your web browser to "enable Java;" this is mentioned in the link above.

On Windows machines, the applet should work in Internet Explorer as well as Mozilla Firefox.
On Macs, it should run in Safari and Firefox.

If you're still having trouble, feel free to stop by Nick's office during office hours with your laptop, or drop him an email (see his contact info on the Course Main Page).


2. Interface

Programming Roboant (left side):

Each line of text in the RoboAnt program corresponds to a row in the state machine's lookup table, as discussed in lecture. All text following a semicolon is considered a comment and the remaninder of the line is ingored. Comments are used to improve the readablity of a program by humans (the ant doesn't care).

Each line of the program can be broken down into 11 regions called fields. Each field is separated from the next by spaces or tab characters. The first four fields specify the input conditions, and their order is:

CurrentState LeftInput RightInput SenseInput |

The bar chracter "|" is required to separate the inputs on the program line from the outputs. CurrentState can be any label (sequence of characters), however, it is advantageous to choose meaningful state names. The remaining three inputs can be one of {'0', '1', or '-'}. The values '0' and '1' correspond to digital inputs from the corresponding sensor. The value '-' means that the input can be ignored (i.e. the program step takes place if the input is either '0' or '1'). Note that using -'s can significantly shorten your program.

The remander of the line is composed of six fields as follows:

NextState TurnLeftOutput TurnRightOutput MoveForwardOutput ScentMarkOutput EraseMarkOutput

The NextState output should always correspond to the CurrentState label on some program line. The remaining outputs can be either {'0' or '1'}, where '1' activates the output, causing the speicifed action to occur (i.e. turning, moving, marking or erasing). Some combinations of outputs might generate unpredictable results such as turning left and right at the same time, or marking and erasing scent marks on the same step. You can try these ambiguous output combinations if you are curious of what they do. You will not hurt, damage, or break, either the applet or the ant.

Along the bottom of the editing panel there are two buttons as described below:
Reload: Loads the default State Machine configuration
Clear: Clears the current configuration

Changing the State Machine can be done right inside the applet; any changes that you make in the text area (such as replacing a 0 by a 1 somewhere in the table to alter the desing of your state machine) will be reflected during the execution of the simulation. To save a configuration for later use or for homework submisssion, select the entire text with your mouse, copy it (in Windows, pressing Ctrl-A, Ctrl+C as well as highlighting all text, right-clicking, and selecting 'Copy' will work). You can then paste your modified code into your favorite text editor. You can also copy from an editor into the applet as well. You can clear the text area by hitting the Clear button, and then paste one of your saved configurations back into the text area (in Windows, pressing Ctrl+V as well as rightclicking inside the editing panel and selecting 'Paste' will work).


Roboant Simulator Buttons (right side):

Reset: Resets the simulation to its starting configuration
Step: Moves the Ant one step forward
Run: Runs the simulation at a natural speed (automatically incrementing the "steps")
Stop: Pauses the Ant at the current "step"
Slider marked with "Slow" and "Fast": Controls the ant's speed

During a simulation the values of the current state and inputs will be displayed in the status line across the bottom of the applet.

3. Hints

Hint #1 (1/24/07): I would suggest that you play around with the "Marker" output to get some sense of how you might approach the "island" mazes. Here's a simple experiment that you can try. For each CurrentState=Wall1, set the "M" output to 1, and leave M as 0 for all other states. This will have the effect of marking maze floor everywhere that the ant moved while it was hugging the wall. You might even notice when it gets into a loop. The figure below highlights the suggested modification and the results from this change after the ant runs for a while:



Stay tuned... more hints to come.



Last updated 1/24/07