"""SynForge Planner v1 template.

Input: PlanContext with current position, target, speed, time, and obstacles.
Output: Action(vx, vy), a finite velocity vector in metres per second.
Required entry class: SubmittedPlanner.
"""

import math

from synforge_core import Action, PlanContext, Planner


class SubmittedPlanner(Planner):
    def plan(self, ctx: PlanContext) -> Action:
        # Available input:
        # ctx.x, ctx.y                 current position
        # ctx.target_x, ctx.target_y   target position
        # ctx.speed                    maximum speed
        # ctx.dt, ctx.sim_time         fixed step and simulation time
        # ctx.obstacles                tuple of CircleObstacle(x, y, radius)
        dx = ctx.target_x - ctx.x
        dy = ctx.target_y - ctx.y
        distance = math.hypot(dx, dy)
        if distance == 0:
            return Action(vx=0.0, vy=0.0)

        # TODO: replace this direct-to-target baseline with your algorithm.
        return Action(
            vx=ctx.speed * dx / distance,
            vy=ctx.speed * dy / distance,
        )