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

Module responsible for executing probe actions

Link to this section Summary

Functions

Moves the probe forward

Turns the probe left

Turns the probe right

Link to this section Types

Specs

t() :: %MarsExplorer.Probe{
  direction: :west | :north | :east | :south,
  east: integer(),
  north: integer()
}

Link to this section Functions

Specs

move(t()) :: t()
move(t()) :: t()
move(t()) :: t()

Moves the probe forward

Examples

iex> alias MarsExplorer.Probe
MarsExplorer.Probe
iex> probe =  %Probe{north: 0, direction: :north}
%Probe{north: 0, direction: :north}
iex> probe |> Probe.move
%Probe{north: 1}
iex> probe |> Probe.move |> Probe.move
%Probe{north: 2}

Turns the probe left

Examples

iex> alias MarsExplorer.Probe
MarsExplorer.Probe
iex> probe = %Probe{direction: :north}
%Probe{direction: :north}
iex> probe |> Probe.turn_left
%Probe{direction: :west}

Turns the probe right

Examples

iex> alias MarsExplorer.Probe
MarsExplorer.Probe
iex> probe = %Probe{direction: :north}
%Probe{direction: :north}
iex> probe |> Probe.turn_right
%Probe{direction: :east}