Bit is a robot that understands a small amount of Javascript to move around its world.
The
bit object is pre-defined, and has the following functions:
bit.move() moves Bit one position forward. Bit cannot go past the outside of its world, nor can it move through the walls, which are black. Any attempts to move outside of the world or into walls causes an error. Bit's eyes always face in the direction Bit will travel in, if it receives a bit.move() call.
bit.right() turns Bit clockwise 90º. Bit can turn anywhere in the world.
bit.left() turns Bit counterclockwise 90º.
bit.paint(color), where color is either 'red', 'blue', or 'green', paints Bit's current location that color. Any other color strings cause an error.
bit.front_clear() returns true if bit can move forward (i.e. it is not blocked by a wall or the edge of the world), and false if Bit is blocked in the direction it is facing.
bit.left_clear() returns true if there is not a wall or the edge of the world to Bit's left, and false if there is a wall or edge of the world to Bit's left. Bit's "left" is actually above its eyes.
bit.right_clear() returns true if there is not a wall or the edge of the world to Bit's right, and false if there is a wall or edge of the world to Bit's right. Bit's "right" is actually below its front foot.
bit.get_color() returns either 'red', 'green', 'blue', or null, depending on the color of the location Bit is on (null indicates that there is no color at that location).
bit.erase() clears the current position of its color.
bit.reset() resets Bit to its original location when the world is loaded.
The Bit REPL window allows one-statement javascript code, e.g.,
bit.move() or
bit.get_color(). If the statement returns a value, it is printed in the terminal. It can also be used to run functions from the main Program window.