- Introduction
- Download
- Quick Start
- Mouse API
- Cell Walls
- Cell Color
- Cell Text
- Reset Button
- Maze Files
- Building From Source
- Acknowledgements
mms is a Micromouse simulator.
It makes it easy to write and test maze-solving code without a physical robot.
With it, you can:
- Test how your robot would behave in a real maze
- Visualize what your robot is thinking
- Show known/unknown walls
- Set the color of the cells
- Display ASCII text on the cells
- Simulate a crash-and-reset scenario
- Test your algorithm on custom maze files
- Write code in any language you want
Previous versions of mms exist in the old/
directory.
For information about Micromouse, see the Micromouse Wikipedia page.
You can download pre-compiled binaries from the releases page. Simply download the asset corresponding to your platform:
- Windows: Download and unzip
windows.zip
and run the "mms" exe - macOS: Download and unzip
macos.zip
and run the "mms" app- Note: you may get warnings about running an application from an unidentified developer. To get past those warnings, control-click on the app and select "Open" (as opposed to simply double-clicking on the app).
If pre-compiled binaries for your platform are unavailable, you'll have to build from source.
Writing a Micromouse algorithm is easy! Here are some available templates:
- C++: mackorone/mms-cpp
- Python: mackorone/mms-python
If a template for a particular language is missing, don't fret! Writing your own template is as easy as writing to stdout, reading from stdin, and implementing the mouse API below. If you have a template you'd like to share, please make a pull request!
Algorithms communicate with the simulator via stdin/stdout. To issue a command, simply print to stdout. To read a response, simply read from stdin. All valid commands are listed below. Invalid commands are simply ignored.
For commands that return a response, it's recommended to wait for the response before issuing additional commands.
int mazeWidth();
int mazeHeight();
bool wallFront();
bool wallRight();
bool wallLeft();
void moveForward(); // can result in "crash"
void turnRight();
void turnLeft();
void setWall(int x, int y, char direction);
void clearWall(int x, int y, char direction);
void setColor(int x, int y, char color);
void clearColor(int x, int y);
void clearAllColor();
void setText(int x, int y, const std::string& text);
void clearText(int x, int y);
void clearAllText();
bool wasReset();
void ackReset();
- Args: None
- Action: None
- Response: The height of the maze
- Args: None
- Action: None
- Response: The width of the maze
- Args: None
- Action: None
- Response:
true
if there is a wall in front of the robot, elsefalse
- Args: None
- Action: None
- Response:
true
if there is a wall to the right of the robot, elsefalse
- Args: None
- Action: None
- Response:
true
if there is a wall to the left of the robot, elsefalse
- Args: None
- Action: Move the robot forward by one cell
- Response:
crash
if there is a wall in front of the robot- else
ack
once the movement completes
- Args: None
- Action: Turn the robot ninty degrees to the right
- Response:
ack
once the movement completes
- Args: None
- Action: Turn the robot ninty degrees to the left
- Response:
ack
once the movement completes
- Args:
X
- The X coordinate of the cellY
- The Y coordinate of the cellD
- The direction of the wall:n
,e
,s
, orw
- Action: Display a wall at the given position
- Response: None
- Args:
X
- The X coordinate of the cellY
- The Y coordinate of the cellD
- The direction of the wall:n
,e
,s
, orw
- Action: Clear the wall at the given position
- Response: None
- Args:
X
- The X coordinate of the cellY
- The Y coordinate of the cellC
- The character of the desired color
- Action: Set the color of the cell at the given position
- Response: None
- Args:
X
- The X coordinate of the cellY
- The Y coordinate of the cell
- Action: Clear the color of the cell at the given position
- Response: None
- Args: None
- Action: Clear the color of all cells
- Response: None
- Args:
X
- The X coordinate of the cellY
- The Y coordinate of the cellTEXT
- The desired text, max length 10
- Action: Set the text of the cell at the given position
- Response: None
- Args:
X
- The X coordinate of the cellY
- The Y coordinate of the cell
- Action: Clear the text of the cell at the given position
- Response: None
- Args: None
- Action: Clear the text of all cells
- Response: None
- Args: None
- Action: None
- Response:
true
if the reset button was pressed, elsefalse
- Args: None
- Action: Allow the mouse to be moved back to the start of the maze
- Response:
ack
once the movement completes
Algorithm Request (stdout) Simulator Response (stdin)
-------------------------- --------------------------
mazeWidth 16
mazeWidth 16
wallLeft true
setWall 0 0 W <NO RESPONSE>
wallFront false
moveForward ack
turnLeft ack
wallFront true
moveForward crash
setColor 0 1 r <NO RESPONSE>
setText 0 1 whoops <NO RESPONSE>
wasReset false
...
wasReset true
clearAllColor <NO RESPONSE>
clearAllText <NO RESPONSE>
ackReset ack
Cell walls allow the robot to diplay where it thinks walls exist, and where it thinks they don't. At the beginning of each run, all walls are assumed non-existent. By default, the simulator will display walls that haven't been discovered as dark red. As the robot explores the maze, it should set walls as it discovers them.
The available colors are as follows:
Char | Color |
---|---|
k | Black |
b | Blue |
a | Gray |
c | Cyan |
g | Green |
o | Orange |
r | Red |
w | White |
y | Yellow |
B | Dark Blue |
C | Dark Cyan |
A | Dark Gray |
G | Dark Green |
R | Dark Red |
Y | Dark Yellow |
All printable ASCII characters,
except for <DEL>
, can be used as cell text. Any invalid characters, such as a
newline or tab, will be replaced with ?
.
When no algorithm is running, the simulator displays the distance of each cell from the center of the maze.
The reset button makes it possible to test crash handling code. Press the
button to simulate a crash. Your algorithm should periodically check if the
button was pressed via wasReset
. If so, your algorithm should reset any
internal state and then call ackReset
to send the robot back to the beginning
of the maze.
The simulator supports a few different maze file formats, as specified below. If your format isn't supported, feel free to put up a pull request.
Note that, in order to use a maze in the simulator, it must be:
- Nonempty
- Rectangular
- Fully enclosed
Also note that official Micromouse mazes have additional requirements:
- No inaccessible locations
- Exactly three starting walls
- Only one entrance to the center
- Has a hollow center, i.e., the center peg has no walls attached to it
- Has walls attached to every peg except the center peg
- Is unsolvable by a wall-following robot
Here are some links to collections of maze files:
Example:
+---+---+---+
| | |
+ + + +
| | |
+---+---+---+
- Each cell is 5 spaces wide and 3 spaces tall
- All characters besides spaces count as walls
- Walls are determined by checking the locations marked with an "x":
+ x +
x x
+ x +
Format:
X Y N E S W
- X: The X coordinate of the cell
- Y: The Y coordinate of the cell
- N:
1
if there is a wall on the north side, else0
- S:
1
if there is a wall on the east side, else0
- E:
1
if there is a wall on the south side, else0
- W:
1
if there is a wall on the west side, else0
Example:
0 0 0 1 1 1
0 1 1 0 0 1
1 0 0 0 1 1
1 1 1 1 0 0
2 0 0 1 1 0
2 1 1 1 0 1
Result:
+---+---+---+
| | |
+ + + +
| | |
+---+---+---+
If you want to write code for the simulator itself, you'll need to build the project from source. Below are some OS-specific instructions. If instructions for your platform are unavailable, you can probably still run the simulator, you'll just have to figure it out on your own for now.
Install Qt:
- Download the Qt open source installer: https://www.qt.io/download/
- If you don't already have a Qt account, you'll need to make one
- When prompted to select components, choose "MinGW 7.3.0 64-bit"
Build the project using QtCreator:
- Download or clone mms
- Run QtCreator and open
mms/src/mms.pro
- Configure the project to use "Desktop Qt 5.12.0 MinGW 64-bit"
- Build and run the project
Install Xcode: https://developer.apple.com/xcode/
Install Qt:
- Download the Qt open source installer: https://www.qt.io/download/
- If you don't already have a Qt account, you'll need to make one
- When prompted to select components, choose "macOS"
Build the project using QtCreator:
- Download or clone mms
- Run QtCreator and open
mms/src/mms.pro
- Configure the project to use "Desktop Qt 5.12.1 clang 64bit"
- Build and run the project
Qt installation option #1: use the command line
sudo apt-get install qt5-default
Qt installation option #2: use the installer
- Download the Qt open source installer: https://www.qt.io/download/
- Make the installer executable:
chmod +x qt-unified-linux-x64-3.0.6-online.run
- Run the installer executable:
./qt-unified-linux-x64-3.0.6-online.run
- If you don't already have a Qt account, you'll need to make one
- When prompted to select components, choose "Desktop gcc 64-bit"
- Once the installer finishes, the
qmake
binary can be found in the installation directory
More documentation:
Clone, build, and run the project:
# Clone the repo
git clone git@github.com:mackorone/mms.git
# Build the simulator
cd mms/src
qmake && make
# Run the simulator
../../bin/sim
Name | Author | Used For |
---|---|---|
polypartition | Ivan Fratric | Polygon Triangulation |
Qt | The Qt Company | Framework and GUI |