All Projects → mackorone → Mms

mackorone / Mms

Licence: mit
A Micromouse simulator: write and test maze-solving code without a physical robot

Projects that are alternatives of or similar to Mms

rcj-soccer-sim
The RoboCupJunior Soccer Simulator, based on Webots
Stars: ✭ 16 (-88.15%)
Mutual labels:  simulator, robot
SLAM Qt
My small SLAM simulator to study "SLAM for dummies"
Stars: ✭ 47 (-65.19%)
Mutual labels:  simulator, robot
Pythonrobotics
Python sample codes for robotics algorithms.
Stars: ✭ 13,934 (+10221.48%)
Mutual labels:  robot, algorithm
Hexapod Robot Simulator
A hexapod robot simulator built from first principles
Stars: ✭ 577 (+327.41%)
Mutual labels:  robot, simulator
Hexapod
Blazing fast hexapod robot simulator for the web.
Stars: ✭ 370 (+174.07%)
Mutual labels:  robot, simulator
gym-line-follower
Line follower robot simulator environment for Open AI Gym.
Stars: ✭ 46 (-65.93%)
Mutual labels:  simulator, robot
community-projects
Webots projects (PROTO files, controllers, simulation worlds, etc.) contributed by the community.
Stars: ✭ 20 (-85.19%)
Mutual labels:  simulator, robot
awesome-webots
Awesome Webots
Stars: ✭ 46 (-65.93%)
Mutual labels:  simulator, robot
Gym Duckietown
Self-driving car simulator for the Duckietown universe
Stars: ✭ 379 (+180.74%)
Mutual labels:  robot, simulator
Webots
Webots Robot Simulator
Stars: ✭ 1,324 (+880.74%)
Mutual labels:  robot, simulator
Edumips64
Free cross-platform educational MIPS64 CPU Simulator
Stars: ✭ 126 (-6.67%)
Mutual labels:  simulator
Codezilla
⚡️ codezilla ⚡️ One giant 🦖 collection of algorithms & design patterns.
Stars: ✭ 127 (-5.93%)
Mutual labels:  algorithm
Qipai algorithm
棋牌的胡牌算法,包括麻将、跑胡子、扑克。实现 lua 、c++ 、c# 、golang 、js 、java 、python 版本。( Mahjong algorithm )
Stars: ✭ 1,705 (+1162.96%)
Mutual labels:  algorithm
Simulator
Efficient Large-Scale Fleet Management via Multi-Agent Deep Reinforcement Learning
Stars: ✭ 133 (-1.48%)
Mutual labels:  simulator
Algorithms
📝 算法导论与JavaScript实现
Stars: ✭ 126 (-6.67%)
Mutual labels:  algorithm
Notes
Including JVM, Java concurrency, Spring framework, Data structure and Algorithm, Computer network, Design pattern, Python, C++, Linux, Mysql, Redis,MATLAB, Git and other tools, etc.
Stars: ✭ 131 (-2.96%)
Mutual labels:  algorithm
Bitmap
C++ Bitmap Library
Stars: ✭ 125 (-7.41%)
Mutual labels:  algorithm
Apachecn Algo Zh
ApacheCN 数据结构与算法译文集
Stars: ✭ 10,498 (+7676.3%)
Mutual labels:  algorithm
Java Ds Algorithms
Data Structures and Algorithms in Java
Stars: ✭ 125 (-7.41%)
Mutual labels:  algorithm
Data structure and algorithms library
A collection of classical algorithms and data-structures implementation in C++ for coding interview and competitive programming
Stars: ✭ 133 (-1.48%)
Mutual labels:  algorithm

mms

Table of Contents

  1. Introduction
  2. Download
  3. Quick Start
  4. Mouse API
  5. Scorekeeping
  6. Cell Walls
  7. Cell Color
  8. Cell Text
  9. Reset Button
  10. Maze Files
  11. Building From Source
  12. Related Projects
  13. Acknowledgements

Introduction

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.

Download

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.

Quick Start

Writing a Micromouse algorithm is easy! Here are some available templates:

Language Repo
Arduino mackorone/mms-arduino
C mackorone/mms-c
C++ mackorone/mms-cpp
Java mackorone/mms-java
JavaScript mackorone/mms-javascript
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!

Mouse API

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.

Summary

int mazeWidth();
int mazeHeight();

bool wallFront();
bool wallRight();
bool wallLeft();

void moveForward(int distance = 1); // 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, string text);
void clearText(int x, int y);
void clearAllText();

bool wasReset();
void ackReset();

int/float getStat(string stat);

mazeWidth

  • Args: None
  • Action: None
  • Response: The height of the maze

mazeHeight

  • Args: None
  • Action: None
  • Response: The width of the maze

wallFront

  • Args: None
  • Action: None
  • Response: true if there is a wall in front of the robot, else false

wallRight

  • Args: None
  • Action: None
  • Response: true if there is a wall to the right of the robot, else false

wallLeft

  • Args: None
  • Action: None
  • Response: true if there is a wall to the left of the robot, else false

moveForward [N]

  • Args:
    • N - (optional) The number of cells to move forward, default 1
  • Action: Move the robot forward the specified number of cells
  • Response:
    • crash if N < 1 or the mouse cannot complete the movement
    • else ack once the movement completes

turnRight

  • Args: None
  • Action: Turn the robot ninty degrees to the right
  • Response: ack once the movement completes

turnLeft

  • Args: None
  • Action: Turn the robot ninty degrees to the left
  • Response: ack once the movement completes

setWall X Y D

  • Args:
    • X - The X coordinate of the cell
    • Y - The Y coordinate of the cell
    • D - The direction of the wall: n, e, s, or w
  • Action: Display a wall at the given position
  • Response: None

clearWall X Y D

  • Args:
    • X - The X coordinate of the cell
    • Y - The Y coordinate of the cell
    • D - The direction of the wall: n, e, s, or w
  • Action: Clear the wall at the given position
  • Response: None

setColor X Y C

  • Args:
    • X - The X coordinate of the cell
    • Y - The Y coordinate of the cell
    • C - The character of the desired color
  • Action: Set the color of the cell at the given position
  • Response: None

clearColor X Y

  • Args:
    • X - The X coordinate of the cell
    • Y - The Y coordinate of the cell
  • Action: Clear the color of the cell at the given position
  • Response: None

clearAllColor

  • Args: None
  • Action: Clear the color of all cells
  • Response: None

setText X Y TEXT

  • Args:
    • X - The X coordinate of the cell
    • Y - The Y coordinate of the cell
    • TEXT - The desired text, max length 10
  • Action: Set the text of the cell at the given position
  • Response: None

clearText X Y

  • Args:
    • X - The X coordinate of the cell
    • Y - The Y coordinate of the cell
  • Action: Clear the text of the cell at the given position
  • Response: None

clearAllText

  • Args: None
  • Action: Clear the text of all cells
  • Response: None

wasReset

  • Args: None
  • Action: None
  • Response: true if the reset button was pressed, else false

ackReset

  • Args: None
  • Action: Allow the mouse to be moved back to the start of the maze
  • Response: ack once the movement completes

getStat

  • Args:
    • stat: A string representing the stat to query. Available stats are:
      • total-distance (int)
      • total-turns (int)
      • best-run-distance (int)
      • best-run-turns (int)
      • current-run-distance (int)
      • current-run-turns (int)
      • total-effective-distance (float)
      • best-run-effective-distance (float)
      • current-run-effective-distance (float)
      • score (float)
  • Action: None
  • Response: The value of the stat, or -1 if no value exists yet. The value will either be a float or integer, according to the types listed above.

Example

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

Scorekeeping

The Stats tab displays information that can be used to score an algorithm's efficiency. This tab displays stats such as the total distance and total number of turns. It also displays the distance and number of turns for the algorithm's best start-to-finish run, if the algorithm makes multiple runs from the start tile to the goal. The distance and number of turns for the current start-to-finish run is also displayed.

There is another value displayed, called Effective Distance. This number may differ from Distance if moveForward is called with the optional distance parameter. If moveForward is called with an integer greater than 2, each tile after the second tile will add only half a point to the effective distance. This simulates a mouse driving faster if it can drive in a straight line for more than a few tiles. For example, moveForward(5) will increase the distance by 5 but will increase the effective distance by only 3.5. A mouse will incur a 15-point penalty on its next run's Effective Distance if it uses ackReset to return to the start tile.

A final score is computed for the algorithm after it terminates. A lower score is better. The final score depends on the best start-to-finish run and on the overall run, according to the following equation.

score = best run turns + best run effective distance + 0.1 * (total turns + total effective distance)

The mouse must reach the goal to receive a score. If the mouse never reaches the goal, the score will be 2000.

Cell Walls

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.

Cell Color

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

Cell Text

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.

Reset Button

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.

Maze Files

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:

Map format

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 +

Num format

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, else 0
  • S: 1 if there is a wall on the east side, else 0
  • E: 1 if there is a wall on the south side, else 0
  • W: 1 if there is a wall on the west side, else 0

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:

+---+---+---+
|       |   |
+   +   +   +
|   |       |
+---+---+---+

Building From Source

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.

Windows

Install Qt:

  1. Download the Qt open source installer: https://www.qt.io/download/
  2. If you don't already have a Qt account, you'll need to make one
  3. When prompted to select components, choose "MinGW 7.3.0 64-bit"

Build the project using QtCreator:

  1. Download or clone mms
  2. Run QtCreator and open mms/src/mms.pro
  3. Configure the project to use "Desktop Qt 5.12.0 MinGW 64-bit"
  4. Build and run the project

macOS

Install Xcode: https://developer.apple.com/xcode/

Install Qt:

  1. Download the Qt open source installer: https://www.qt.io/download/
  2. If you don't already have a Qt account, you'll need to make one
  3. When prompted to select components, choose "macOS"

Build the project using QtCreator:

  1. Download or clone mms
  2. Run QtCreator and open mms/src/mms.pro
  3. Configure the project to use "Desktop Qt 5.12.1 clang 64bit"
  4. Build and run the project

Linux (Ubuntu)

Qt installation option #1: use the command line

sudo apt-get install qt5-default

Qt installation option #2: use the installer

  1. Download the Qt open source installer: https://www.qt.io/download/
  2. Make the installer executable: chmod +x qt-unified-linux-x64-3.0.6-online.run
  3. Run the installer executable: ./qt-unified-linux-x64-3.0.6-online.run
  4. If you don't already have a Qt account, you'll need to make one
  5. When prompted to select components, choose "Desktop gcc 64-bit"
  6. 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 [email protected]:mackorone/mms.git

# Build the simulator
cd mms/src
qmake && make

# Run the simulator
../../bin/mms

Related Projects

Acknowledgements

Name Author Used For
polypartition Ivan Fratric Polygon Triangulation
Qt The Qt Company Framework and GUI
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].