MarsExplorer.InstructionsInterpreter (SWAP - Mars Explorer v0.1.0) View Source

Module responsible for interpreting the exploration instructions

Link to this section Summary

Functions

Interprets instructions from a instructions list.

Link to this section Functions

Interprets instructions from a instructions list.

Examples

iex> alias MarsExplorer.InstructionsInterpreter
MarsExplorer.InstructionsInterpreter
iex> instructions = ["5 5", "1 2 N", "LMLMLMLMM", "3 3 E", "MMRMMRMRRM"]
["5 5", "1 2 N", "LMLMLMLMM", "3 3 E", "MMRMMRMRRM"]
iex> instructions |> InstructionsInterpreter.interpret()
[
  {:grid, %{north: 5, east: 5}},
  {:place, %{north: 2, east: 1, direction: :north}},
  [
    :turn_left,
    :move,
    :turn_left,
    :move,
    :turn_left,
    :move,
    :turn_left,
    :move,
    :move
  ],
  {:place, %{north: 3, east: 3, direction: :east}},
  [
    :move,
    :move,
    :turn_right,
    :move,
    :move,
    :turn_right,
    :move,
    :turn_right,
    :turn_right,
    :move
  ]
]