20 Oct 2014

Ingress Intel Total Conversion - JavaScript Plugin

Ingress is a game where real world locations are defined as portals. These portals can be linked to other portals. When 3 portals are linked in a triangle a "field" is created. These fields score "points" for your team.

Ingress Intel Total Conversion is a browser add-on that modifies the standard ingress Intel map, offering more features. One feature it allows is new functionality in the form of JavaScript plug-ins.

The Objective

I thought it might be useful to see on the map, fields which have already 2 of their sides completed, and to indicate the link which would complete them.

For example: in the image below we can see existing fields, we can also see that linking portal 1 to 3 would create a field. Sometimes these fields links are less obvious.

One of the rules of linking portals is that a new link may not cross an existing link. So portal 4 could not be linked to 3 because it would cross the 1 to 2 link.

Test1

The Algorithm

To determine these "field finishing" links:

  • Make a list of all existing links between portals.
  • For each portal owned by your team move across all of its existing links(if it has any) to the next portal (e.g. 1 to 2), repeat from that portal to the next (e.g. 2 to 3)
  • For all of the paths found check if the link back to the first portal (e.g. 3 to 1) can be made without crossing any link in the list of portal links made earlier.

The complicated bit is determining if two line segments cross, thankfully Martin Thoma has a great site with some JavaScript code which I have included in the algorithm.

http://martin-thoma.com/how-to-check-if-two-line-segments-intersect/

The Plug-in

Once the required links have been determined they need to be represented on the map. This done by drawing on a new map layer called 'Field Finisher', the links are indicated using red dotted lines.

Plugin

The algorithm has been unit tested using Jasmine

The plug-in code can be download here field-finisher.user.js

blog comments powered by Disqus

About Me


My first computer was a Commodore VIC-20, I had great fun trying to code text adventures and side scrolling shoot ‘em ups in BASIC. This helped me lead the way as the first in my school to pass a computer exam.

Currently I work as a Senior Software Engineer in Bedford for a FTSE 100 Company. Coding daily in C#, JavaScript and SQL. Outside of work I work on whatever is interesting me at that time.