Draw the Ingress glyphs

16

3

In the location-based AR mobile game way of life Ingress the player can hack things called portals in order to get items. (If you are interested in Ingress, you can ping me in chat for more info. Trust me, it's better than Pokémon. If you end up downloading it, remember to choose the Resistance.)

A way to increase hack output significantly is the glyph hacking minigame, in which the player has to draw glyphs on a hexagonal grid.

the glyph grid

In total, there are about 115 glyphs with about 130 names that are actually used in the game.

Glyphs

For the purposes of this challenge we will number each point of the grid like so:

the glyph grid, numbered

Here is the list of all the glyphs for the purposes of this challenge. The list is a JSON object, containing each glyph as a list of edges.

{
"ABANDON": [[1, 6], [3, 4], [4, 8], [6, 10], [8, 10]],
"ACCEPT": [[3, 7], [3, 8], [7, 8]],
"ADVANCE": [[0, 9], [4, 9]],
"AFTER": [[1, 2], [1, 6], [2, 7], [6, 10], [7, 10]],
"AGAIN": [[4, 9], [6, 7], [6, 10], [8, 9], [8, 10]],
"ALL": [[0, 1], [0, 5], [1, 2], [2, 3], [3, 4], [4, 5]],
"ANSWER": [[6, 7], [6, 9], [7, 10]],
"ATTACK": [[0, 6], [0, 9], [2, 6], [4, 9]],
"AVOID": [[0, 5], [0, 6], [1, 6], [1, 7]],
"BALANCE": [[0, 10], [2, 3], [2, 7], [3, 4], [4, 8], [7, 10], [8, 10]],
"BARRIER": [[0, 10], [2, 7], [7, 10]],
"BEFORE": [[4, 5], [4, 8], [5, 9], [8, 10], [9, 10]],
"BEGIN": [[0, 8], [3, 7], [3, 8]],
"BODY": [[6, 9], [6, 10], [9, 10]],
"BREATHE": [[1, 6], [5, 9], [6, 10], [9, 10]],
"CAPTURE": [[1, 7], [3, 4], [4, 8], [7, 10], [8, 10]],
"CHANGE": [[3, 7], [3, 10], [8, 10]],
"CHAOS": [[0, 1], [0, 5], [1, 6], [3, 8], [4, 5], [6, 10], [8, 10]],
"CIVILIZATION": [[1, 6], [5, 9], [6, 7], [7, 8], [8, 9]],
"CLEAR": [[0, 10], [3, 10]],
"CLEAR ALL": [[0, 1], [0, 5], [0, 10], [1, 2], [2, 3], [3, 4], [3, 10], [4, 5]],
"COMPLEX": [[6, 9], [8, 10], [9, 10]],
"CONFLICT": [[2, 6], [4, 9], [6, 7], [7, 8], [8, 9]],
"CONTEMPLATE": [[0, 1], [1, 2], [2, 3], [3, 8], [6, 10], [8, 9], [9, 10]],
"COURAGE": [[4, 9], [7, 8], [8, 9]],
"CREATE": [[1, 6], [4, 8], [6, 10], [8, 10]],
"DANGER": [[0, 9], [3, 10], [9, 10]],
"DATA": [[0, 6], [3, 8], [6, 10], [8, 10]],
"DEFEND": [[1, 7], [3, 7], [3, 8], [5, 8]],
"DESTINY": [[3, 8], [6, 7], [6, 10], [7, 8], [9, 10]],
"DESTROY": [[2, 7], [5, 9], [7, 10], [9, 10]],
"DETERIORATE": [[4, 8], [8, 10], [9, 10]],
"DIE": [[2, 7], [4, 8], [7, 10], [8, 10]],
"DIFFICULT": [[1, 6], [6, 7], [7, 10], [8, 10]],
"DISCOVER": [[1, 2], [2, 3], [3, 4]],
"DISTANCE": [[0, 5], [4, 5]],
"EASY": [[3, 8], [6, 10], [8, 10]],
"END": [[0, 1], [0, 10], [1, 7], [3, 7], [3, 10]],
"ENLIGHTENED": [[0, 1], [0, 9], [1, 2], [2, 3], [6, 9], [6, 10], [9, 10]],
"ENLIGHTENMENT": [[0, 1], [0, 9], [1, 2], [2, 3], [6, 9], [6, 10], [9, 10]],
"EQUAL": [[6, 7], [6, 9], [8, 9]],
"ESCAPE": [[0, 1], [1, 6], [6, 9], [8, 9]],
"EVOLUTION": [[0, 10], [8, 9], [9, 10]],
"FAILURE": [[0, 10], [6, 7], [6, 10]],
"FEAR": [[1, 7], [6, 7], [6, 9]],
"FOLLOW": [[0, 6], [1, 2], [1, 6]],
"FORGET": [[4, 8]],
"FUTURE": [[1, 6], [2, 7], [6, 7]],
"GAIN": [[5, 8]],
"GROW": [[4, 9], [8, 9]],
"HARM": [[0, 6], [0, 9], [2, 7], [6, 10], [7, 10], [9, 10]],
"HARMONY": [[0, 6], [0, 9], [3, 7], [3, 8], [6, 10], [7, 10], [8, 10], [9, 10]],
"HAVE": [[3, 8], [7, 10], [8, 10]],
"HELP": [[5, 9], [7, 8], [8, 10], [9, 10]],
"HIDE": [[1, 6], [1, 7], [6, 9], [7, 8]],
"HUMAN": [[3, 7], [3, 8], [6, 7], [6, 9], [8, 9]],
"IDEA": [[1, 2], [1, 6], [2, 7], [4, 5], [4, 8], [5, 9], [7, 10], [9, 10]],
"IGNORE": [[2, 7]],
"IMPERFECT": [[6, 8], [6, 10], [8, 9], [8, 10], [9, 10]],
"IMPROVE": [[1, 6], [6, 10], [7, 10]],
"IMPURE": [[3, 10], [8, 9], [8, 10], [9, 10]],
"INSIDE": [[6, 7], [6, 9]],
"INTELLIGENCE": [[1, 6], [4, 8], [6, 10], [8, 9], [9, 10]],
"INTERRUPT": [[0, 10], [3, 10], [4, 5], [4, 8], [5, 9], [8, 10], [9, 10]],
"JOURNEY": [[1, 6], [2, 3], [3, 4], [4, 5], [5, 9], [6, 10], [9, 10]],
"KNOWLEDGE": [[3, 6], [3, 9], [6, 10], [9, 10]],
"LEAD": [[0, 5], [3, 8], [4, 5], [4, 8]],
"LEGACY": [[0, 1], [0, 5], [1, 6], [2, 7], [4, 8], [5, 9], [6, 7], [8, 9]],
"LESS": [[6, 10], [9, 10]],
"LIBERATE": [[0, 1], [1, 6], [4, 9], [6, 10], [9, 10]],
"LIE": [[6, 7], [6, 10], [7, 10], [8, 9], [9, 10]],
"LOSE": [[1, 7]],
"MESSAGE": [[1, 7], [4, 9], [7, 10], [9, 10]],
"MIND": [[3, 8], [3, 10], [8, 9], [9, 10]],
"MORE": [[7, 10], [8, 10]],
"MYSTERY": [[0, 6], [0, 9], [5, 9], [6, 9], [8, 9]],
"N'ZEER": [[0, 6], [0, 9], [0, 10], [3, 10], [6, 10], [9, 10]],
"NATURE": [[2, 7], [4, 8], [6, 7], [6, 9], [8, 9]],
"NEW": [[2, 7], [6, 7]],
"NO": [[6, 7], [6, 9]],
"NOT": [[6, 7], [6, 9]],
"NOURISH": [[3, 4], [3, 10], [4, 8], [8, 10]],
"NOW": [[6, 7], [7, 8], [8, 9]],
"OLD": [[5, 9], [8, 9]],
"OPEN": [[3, 7], [3, 8], [7, 8]],
"OPEN ALL": [[0, 1], [0, 5], [1, 2], [2, 3], [3, 4], [3, 7], [3, 8], [4, 5], [7, 8]],
"OUTSIDE": [[0, 5], [4, 5]],
"PAST": [[4, 8], [5, 9], [8, 9]],
"PATH": [[0, 10], [4, 8], [8, 10]],
"PEACE": [[0, 6], [0, 9], [3, 7], [3, 8], [6, 10], [7, 10], [8, 10], [9, 10]],
"PERFECTION": [[0, 10], [2, 3], [2, 7], [3, 4], [4, 8], [7, 10], [8, 10]],
"PERSPECTIVE": [[0, 6], [0, 9], [2, 7], [4, 8], [6, 10], [7, 10], [8, 10], [9, 10]],
"PORTAL": [[1, 2], [1, 6], [2, 7], [4, 5], [4, 8], [5, 9], [6, 9], [7, 8]],
"POTENTIAL": [[0, 10], [1, 2], [2, 7], [7, 10]],
"PRESENT": [[6, 7], [7, 8], [8, 9]],
"PURE": [[0, 10], [6, 7], [6, 10], [7, 10]],
"PURSUE": [[0, 6], [0, 9], [5, 9]],
"QUESTION": [[0, 6], [6, 9], [8, 9]],
"REACT": [[2, 7], [6, 9], [7, 10], [9, 10]],
"REBEL": [[1, 2], [1, 6], [5, 8], [6, 10], [8, 10]],
"RECHARGE": [[0, 5], [0, 10], [5, 9], [9, 10]],
"REPAIR": [[0, 5], [0, 10], [5, 9], [9, 10]],
"REPEAT": [[4, 9], [6, 7], [6, 10], [8, 9], [8, 10]],
"RESISTANCE": [[0, 9], [0, 10], [3, 8], [3, 10], [6, 9]],
"RESTRAINT": [[2, 3], [2, 7], [5, 9], [7, 10], [9, 10]],
"RETREAT": [[0, 6], [2, 6]],
"SAFETY": [[2, 6], [4, 9], [6, 9]],
"SAVE": [[1, 7], [7, 10], [8, 10]],
"SEARCH": [[6, 9], [6, 10], [7, 8], [8, 9]],
"SEE": [[0, 9]],
"SEPARATE": [[2, 7], [5, 9], [6, 7], [6, 10], [8, 9], [8, 10]],
"SHAPER": [[0, 6], [0, 9], [2, 7], [4, 8], [6, 7], [8, 9]],
"SIMPLE": [[7, 8]],
"SOUL": [[3, 7], [3, 10], [6, 7], [6, 10]],
"STABILITY": [[2, 7], [4, 8], [7, 8]],
"STAY": [[2, 7], [4, 8], [7, 8]],
"STRONG": [[6, 7], [6, 9], [7, 8], [8, 9]],
"STRUGGLE": [[0, 9], [0, 10], [3, 8], [3, 10], [6, 9]],
"SUCCESS": [[0, 10], [8, 9], [9, 10]],
"TECHNOLOGY": [[1, 6], [2, 7], [6, 10], [7, 10], [8, 9], [8, 10], [9, 10]],
"THOUGHT": [[1, 2], [1, 6], [2, 7], [4, 5], [4, 8], [5, 9], [7, 10], [9, 10]],
"TOGETHER": [[4, 8], [6, 9], [6, 10], [8, 10], [9, 10]],
"TRUTH": [[6, 7], [6, 10], [7, 10], [8, 9], [8, 10], [9, 10]],
"UNBOUNDED": [[0, 1], [0, 5], [1, 7], [2, 3], [3, 4], [4, 5], [6, 9], [6, 10], [7, 8], [8, 9]],
"US": [[3, 6], [6, 9]],
"USE": [[1, 7], [7, 10]],
"WANT": [[3, 7], [3, 8], [4, 8]],
"WAR": [[0, 6], [0, 9], [2, 6], [4, 9]],
"WEAK": [[5, 9], [6, 7], [6, 9]],
"XM": [[6, 7], [6, 9], [7, 10], [8, 9], [8, 10]],
"YOU": [[0, 7], [0, 8], [7, 8]],
"YOUR": [[0, 7], [0, 8], [7, 8]]
}

Some glyphs have multiple names (e.g. NO, NOT, INSIDE); you must support them all.

Disclaimer: I couldn't find a good list of all of the glyphs, so I combined multiple sources and finally ended up drawing all of them in a hacked-together JS application to get the list of them. I may be missing some and there may be a couple of aliases not used in the game; I hope I didn't misdraw some of the glyphs, though.

Edit the next morning when it's not 4am: I already noticed VICTORY is missing. Oh well, it's left for the best golfer then.

Challenge

Your task is to create a program or function that takes in a name of a glyph, and outputs the glyph as an image.

The image must contain the grid points and the lines connecting the points in question.

This is , so the shortest answer in bytes wins. Standard rules apply.

I/O

You will take as input, in a format of your choice, a name of a glyph exactly as found in the keys of the above JSON object. Any other input is undefined behavior.

You will output an image in any common format with the glyph rendered to the grid.

Grid proportions

These proportions must be accurate to five pixels (to allow for rounding etc.)

  • The outer points (0-5) must form a regular hexagon.
  • The center point (10) must be in the center of the hexagon.
  • The intermediate points (6-9) must be halfway between the center point and the corresponding outer points.
  • The grid must be oriented like the original.
  • The height of the outer hexagon must be at least 100 pixels.

Other rules

  • The background must be either transparent or filled with a solid color.
  • The lines and points must be clearly distinct from the background and each other; they cannot be of the same solid color.
    • For example, solid blue lines and solid pink points is fine.
    • Solid black lines and white points with black borders is fine.
    • Red and white striped lines and footballs as points is fine.
    • Solid green lines and solid green points is not fine.
  • The radius of the points must be larger than the width of the lines.
  • You may draw the lines in front of or behind the points.
  • You may include any amount of padding (in the background color) in the image.
  • You may combine consecutive lines into one line, since it doesn't affect the outcome.

Examples

The colors and object widths in these images are just examples that somewhat resemble the appearance of the game.

UNBOUNDED

unbounded glyph

PEACE

peace glyph

RESISTANCE

resistance glyph

PurkkaKoodari

Posted 2017-02-08T02:32:07.557

Reputation: 16 699

Had to upvote for the nostalgia (and the Resistance suggestion :P). I wish I still had time for this game! Some of the most fun (and exercise) I've had in a long time. And did you actually manually create that JSON? – Carcigenicate – 2017-02-08T05:47:26.913

@Carcigenate No. I wrote a piece of code that gave me a grid and a name of a glyph and had me draw it, and collected the glyphs in an array as lists of nodes. Then it was just ten lines of python and some find-and-replace. That app is also where the examples come from. – PurkkaKoodari – 2017-02-08T06:07:50.483

while compressing the list of graph plays a big part in the challenge, i don't think the kolmogorov tag feat here as you have more than hundred different output – Sefa – 2017-02-08T09:01:05.463

@Pietu1998 Oh, cool. Guess I should have trusted that a programmer would have written a program to help with something like that. – Carcigenicate – 2017-02-08T14:54:22.377

Answers

7

Mathematica, 228 + 184 + 365 + 13 = 790 bytes

Graphics@{v=255#+##&~Fold~BinaryReadList@#~IntegerDigits~#2&;p=#~Partition~2&;c=p["c"~v~25-12][[#+1]]&;Array[Disk@*c,11,0],Red,Line[c/@<|Thread["a"~v~2293->First/@p@SplitBy["b"~v~12,#>10&]]|>@Mod[1##&@@ToCharacterCode@#,2293]]}&

The above 228-byte command defines an unnamed function that takes as input one of the glyph names above, and returns an image. For example, here is the output for "UNBOUNDED":

UNBOUNDED

The command reads three binary files—"a", "b", and "c"—which have 184, 365, and 13 bytes, respectively. An easier-to-read version:

1  Graphics@{
2    v = 255#+##&~Fold~BinaryReadList@#~IntegerDigits~#2 &;
3    p = #~Partition~2 &;
4    c = p["c"~v~25-12][[#+1]] &;
5    Array[Disk@*c, 11, 0], Red, 
6    Line[c /@
7      <| Thread[ "a"~v~2293 -> First/@p@SplitBy["b"~v~12, #>10&] ] |>
8        @ Mod[1##& @@ ToCharacterCode@#, 2293]]
9  } &

Line 2 defines a handmade uncompression function: it reads in a stream of bytes from the file #, converts it into a base-256 integer, and then expands that integer into its list of digits in base #2. Lines 3 and 4 define a function (using the third binary file) that converts an integer from 0 to 10 into the coordinates of the corresponding grid point; all these coordinates were chosen to be integers between –12 and 12, which makes compression convenient (though not so convenient that I saw it for my initial submission).

Line 5 draws the grid points (in default color black), then switches to the color red for the lines. Line 7 creates an association (using the first two binary files) that converts certain input integers between 0 and 2292 into a list of grid-point integers such as {2, 3, 4, 5, 0, 1, 7, 8, 9, 6, 10}, which represents a path joining point 2 to 3 to 4 to ... to 10. (This is an "Eulerian path", one that visits each edge exactly once; all the glyphs in the table have an Eulerian path, so this representation is shorter than listing the set of edges explicitly.) The command after the -> on line 7 creates this list of Eulerian paths, by reading in a base-12 integer using v and then splitting it at every occurrence of the digit 11.

Finally, line 8 hashes the input string by converting all its letters to their ASCII codes and taking their product modulo 2293 (the smallest modulus for which the answers are all distinct). That integer is fed into the association in the line above, resulting in the appropriate Eulerian path, and line 6 draws the resulting path over the grid points.

Hex dumps of files "a", "b", and "c", in that order:

09d5f27cd2246e0cb06aa243b442d761ac3a5604439f1767a202c4d3fc4fc1b24ce59acfc65a05235cc46354af8820d6733001e1f25ea01479cee027d62e8b1be10891c693ed5887942ca461c461d458a7676bfcd866a70263ad1833b3e836895ce121153c451ad327086e2bd30d6bad7097a9e71c2fc67c2c57716e5ada6907d99f42702dfb8b88c6d26799aa01f42fb89394e00b0752825f2740903276e20ec405473f309cc978aea187da24749d0a44319cd7322dd542

02d9ebf5fc94183ce50f0fc84e88a27bd21a3b3665d54949608c75c86c4507eed3072e02657822bfb83dbca8a708e07d1382c2b6c3c8fcddc88fa7244281a918b3a8aa823048d4a7e070a336c1e5ab83ec4950fc1960f34c6b89c541c9401607882418cac7f79f4edb164b775ecbb97947470016cadea4d06f93a958713b8c23d11be3c9ce8a2824a458d151ac3cafc6d7bb1557e55868434bd5c0da4bd71e66a3f7711018ae5e7f2941a949a85b6e65aebcc2fe43a89cb0479fa9474fe5102cfbf7da8a455f46ac5409dfdc79970ed8dbfc6b84df78c9c19df4d16bda298dca445ad510bf32e14ca5c91ce58e7521492f6e79e05624ab4a4c02c66c22ef670a06d5c5a3dfdf8ccc8c40c353f3aecf17bbb5cb911baefa3ce80e41551376838c166153a1038d83e171077a3f260ccd70358917eeceb5722b58ad6900a40b5b1512b292fb7a7e0d2cbe2bac2a48a4e343e8f2a338808ec9957c64778aba412bec47bcabb2a2789f01c2d5fdd993

254c40dac61bb215386b7361a8

Greg Martin

Posted 2017-02-08T02:32:07.557

Reputation: 13 940

Nice answer! You should post the hexdumps of your data files, though. – PurkkaKoodari – 2017-02-08T07:30:22.427

Done ... and meanwhile I realized that I might as well just compress the list of grid-point coordinates as well, since all the relevant commands are already present. – Greg Martin – 2017-02-08T08:07:32.830