# Reward function for parking vehicle

I am having problems with parking a vehicle using DQN and could use some help.

Agent Description

The agent exists in a square grid with boundaries (X x Y), and is only able to move forward, turn left or turn right by setting target positions to reach. Decisions and rewards are done whenever the agent reaches its target position pt = [x y]. When the agent moves outside the boundaries or reaches the target the episode is terminated.

Agent State Space

The state of the agent is modelled by its position (x, y) along with its angle psi.

Agent Action Space

The agent can choose to set a target straight, a target turning left or a target turning right. As shown by green lines and crosses in the included image.

Objective

The goal of the agent is simple enough: to reach the target position holding a specific angle psi_d.

Attempted Rewards

Until now i have only focused on getting the agent to reach the desired area r = prev_target_distance - target_distance, and ignored heading but cant even get this to work. Additionally a big reward is given if the agent reaches the target state.

I am using a DQN with replay memory, and two hidden layers with 40 and 50 neurons. Any assistance would be greatly appreciated!