# `Monty.Frameworks.Models.MotorPolicies.JumpToGoal`
[🔗](https://github.com/d-led/ex.tbp.monty/blob/v0.1.0/packages/ex_tbp_monty_core/lib/monty/frameworks/models/motor_policies/jump_to_goal.ex#L1)

A policy that teleports the agent to a goal, and takes it back if that lands
somewhere useless.

Mirrors `tbp/monty/frameworks/models/motor_policies.py::JumpToGoal`, the
policy a distant agent's selector reaches for when a learning module has a
hypothesis worth testing. A jump is two actions — `SetAgentPose` at the goal's
location facing along the goal's direction, and an identity
`SetSensorRotation` so the sensors keep the orientation the jump was planned
in — and it always remembers the two actions that would put the agent back
where it started.

It is meant to be called twice: once to jump, and once to judge where the jump
landed. Landing on the object is the end of it, and the selector moves on to
the next policy; landing anywhere else — empty space, or inside something —
answers with the undo actions instead. The judgement reads the percept
(`on_object`), not the depth, which is where it differs from `InformedPolicy`'s
version of the same idea.

With no jump in flight and no goal it raises `NoGoalProvided`, because a
selector that routes a goal to this policy has already decided there is one;
a run configured to suppress runtime errors gets a warning and no action
instead.

`:sensor_id` is stored and never read, as in Monty, whose docstring says it is
for a depth-at-centre calculation this policy no longer does.

# `t`

```elixir
@type t() :: %Monty.Frameworks.Models.MotorPolicies.JumpToGoal{
  agent_id: atom() | String.t(),
  is_jumping: boolean(),
  is_undoing_jump: boolean(),
  pre_jump_state: Monty.Frameworks.Models.MotorSystemState.AgentState.t() | nil,
  sensor_id: atom() | String.t(),
  undo_action: Monty.Frameworks.Actions.Action.t() | nil,
  undo_jump_actions: [Monty.Frameworks.Actions.Action.t()]
}
```

# `call`

```elixir
@spec call(
  t(),
  Monty.Context.t(),
  map() | nil,
  Monty.Frameworks.Models.MotorSystemState.t(),
  Monty.Cmp.Message.t() | nil,
  Monty.Cmp.Goal.t() | nil
) :: {Monty.Frameworks.Models.MotorPolicies.MotorPolicyResult.t(), t()}
```

A jump, or a verdict on the last one.

A jump in flight is judged first: an undo answers with the actions that put the
agent back, and a landing on the object leaves the step free to start the next
jump — or, with no goal, to ask for nothing at all.

# `new`

```elixir
@spec new(keyword()) :: t()
```

A jump policy for `:agent_id`, judging with `:sensor_id`.

`:sensor_id` is kept for the sake of the constructor Monty has, and unused.

# `reset`

```elixir
@spec reset(t()) :: t()
```

Starts the next episode with no jump in flight.

# `state_dict`

```elixir
@spec state_dict(t()) :: map()
```

The jump in flight, as plain values.

Monty's memento, written with one name and read with another — see
`docs/monty-differences.md` §1.6. There is no load path here, so this is what a run
records and not something a policy is restored from.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
