Pathfinding.js in Microsoft Engage

The project done by my team and I in the Mars Colonisation Program, as part of the Microsoft Engage 2020.

Ruthu S Sanketh
5 min readJul 28, 2020

If you haven’t read my article on the Mars Colonisation Program With Microsoft, go read that first!

Table of Contents

  1. Introduction
  2. Problem Statement
  3. Evaluation Criteria
  4. Brainstorming Sessions
  5. The Example Code
  6. Our Project
  7. Low Level Usage
  8. Online Demo of the Final Project
  9. Submission
  10. Future Possibilities
  11. Important Links

Introduction

This article mainly talks about the overall project implementations we did, the software we used, the algorithms we deployed, and the functionalities we added to our project, in the Mars Colonisation Program, as part of Microsoft Engage 2020, which was held in the months of June-July.

Problem Statement

We could choose any project from the two choices, whose example code was also given -

  1. Navigate the Mars Rover

Help the Mars Curiosity Rover find the shortest path between two points while avoiding obstacles on the way.

2. Entertain the Crew

Engage your Crew by Using Minmax algorithm to build an unbeatable Tic Tac Toe game powered by AI.

We were allowed to form teams, and my team consisted of 4 members -Nikita, Jagriti, Gauranshi, and I. Since we all had some previous experience with path finding algorithms, we decided to go with the first project, the Mars Rover Navigation one.

Project Misson
Project Mission

Evaluation Criteria

We would be evaluated on a number of criteria -

  1. Uniqueness of Solution -How did our solution differ from the example code provided to us?
  2. Technical Achievement -What were the programming approaches we took in our project?
  3. Code Quality -Did we have optimum size, consistency, structure, and complexity of our code base on GitHub?
  4. Relevance to Theme -How close did we stay to the problem statement and the overall theme of the project?
Code quality was an important evaluation criteria
Code quality was an important evaluation criteria

Brainstorming Sessions

The team, now named Code_Brewers, did a bunch of brainstorming sessions, where we came up with ideas in sync with the evaluation criteria, discarded them due to infeasibility, or because they were too difficult to implement, or because they were not in accordance with the theme of the project, and came up with even more ideas. We had had to figure out how we were going to incorporate unique code, since the example code was nearly completely optimised and perfect. We sat down over many days, spoke to our mentor, Richa Agarwal, a software engineer at Microsoft, and hashed out a plan of action and deliverables of the project.

The Example Code

The code that was shared with us as an example was a GitHub repository, and was made as a pathfinding library to incorporate into grid based games and the like. It used multiple path finding algorithms to find the shortest path between two points, and also plotted the path found on a virtual grid, with animations. It also allowed for user -input obstacles, which the algorithm would then avoid.

Example Code Repository

Virtual demo of the example code
Virtual demo of the example code

Example Code Demonstration

Our Project

The following were the implementations we decided to go ahead with, in order to gain points in the evaluation criteria -

  1. Introduce multiple possible destination points, where the pathfinder has to find the closest destination and find the shortest path to that point too.
  2. Introduce stop points, which stand for data collection points on Mars, and the pathfinder has to find the shortest route covering all the points, like a circuit.
  3. Introduce visitation points, and the pathfinder has to find the shortest path from the start to the end which is the shuttle boarding point, and hence has to be the final point visited, and visit all the points.
  4. Optimise the code in algorithms by using OOP and data structures that enhance speed (for example, binary heaps in A * algorithm)

Low Level Usage

The algorithms we used in our project -

  1. Breadth First Search
  2. A* Search
  3. Dijkstra Search
  4. Prim’s Algorithm

We also incorporated the bi-directional approaches of these algorithms, along with diagonal movement of the nodes.

The programming languages we used -

  1. Javascript
  2. CSS
  3. HTML

The existing libraries we used -

  1. Node.js was used to run the application
  2. State Machine.js -to process various inputs and states
  3. Raphael.js -to create the SVG (scalable vector graphics)

Most of the visual part of the project was borrowed from the example code, though a few changes were made on the interaction, design, and ease of usage. The web application was built to run on Microsoft Edge, Safari, Chrome, and Firefox. It was hosted using Git Pages.

High Level diagram
High Level diagram
Low Level diagram
Low Level diagram

Online Demo of the Final Project

The online demo working with visitation and stop points -

Standard functionality to find the shortest path between two points
Standard functionality to find the shortest path between two points
Finding the closest destination point
Finding the closest destination point
Multiple stop nodes, completing a circuit of all nodes visited
Multiple stop nodes, completing a circuit and all nodes are visited
Multiple visitation nodes, while ending at the destination point only
Multiple visitation nodes, while ending at the destination point only

Online demonstration

Submission

The team was able to successfully implement all our strategies with the supporting documents, and submit the project before the deadline in the last week of July -4 minutes before, to be exact, but who’s counting? ;)

Results were announced in the second week of August, and our team placed 4th amongst all 4-member teams! It came as a delightful surprise, and we felt like all our hard work paid off.

Program results — 4th place!
Program results — 4th place!

Project repository

Future Possibilities

Possible functionalities which couldn’t be implemented due to the short duration of the program -

  1. Weighted points, where the weights stand for the safety of that position on Mars, For example, a crater, or a very hot area will have higher weight, as it is more dangerous for the rover to go over such terrain. An algorithm may then be implemented to optimise for the weighted path, leading to finding the safest path for the rover to follow.
  2. Treasure points, where rich samples of sand, etc., can be found, but where the rover need not necessarily go. An algorithm can be implemented to maximise the rover’s reward/treasure, while also minimising the distance travelled, basically find an optimum path by varying 2 parameters.

Important Links

  1. Example Code Repository
  2. Example Code Demonstration
  3. Project repository
  4. Online demonstration
  5. Mars Colonization Program -Microsoft (Precedes this article)

--

--

Ruthu S Sanketh
Ruthu S Sanketh

Written by Ruthu S Sanketh

IIT Kharagpur grad passionate about all things tech x entrepreneurship! https://ruthussanketh.com/

No responses yet