Duck Chase
Imagine our yellow dot is a duck swimming in a pond, and the red dot is a hungry fox. The fox circles around the pond to search for an opportunity to catch the duck. Duck is safe in the pond, but it needs to reach the shore to escape.
Game Rules
- Click anywhere on the canvas to move the duck to pointed location.
- The fox (red) will chase the duck, such that it minimizes its distance to the duck.
- If the duck reaches the shore without being caught, then you win!
Turn around and run?
Intuitively, we may be tempted to run in the opposite direction of the fox and take the shortest path ashore. But the speed of the fox is setup to be at least $\pi$ times duck's speed. Therefore, as duck moves towards the shore, fox will surely catch up.
Solution
Hint
Try move along the grey circle within pond.
Step One
As you probably noticed, if duck moves along or outside the grey circle, it will maintain the same angle with the fox. This is because beyond the grey circle, angular velocity of the duck is the same as the fox $\omega_{duck} = \omega_{fox}$.
On the flip side, if duck moves within the grey circle, it can potentially increase its angle difference with the fox. This gives us an idea for a strategy: move spirally towards the grey circle from center of pond.
This way, duck can gradually increase its angle difference with the fox. In an ideal scenario, duck can reach a point on the grey circle that is at most $\pi$ or $180^\circ$ degrees away from the fox, marking the maximum angle and distance away from the fox.
Step Two
Maybe take the shortest path now?
Intuitively, we may think from this optimal point, duck should take the shortest path to shore. But is this really the best strategy?
Well, if you give it a try, you may find as we increase the speed of the fox, this strategy may not work as well.
Optimize it!
Assuming we followed step one, and we are at the optimal point (maximum angle/distance away from the fox), as shown in graph below. We can then formulate this problem of finding the optimal path from this point onwards into an optimization.
As shown in plot, we will first define a few variables:
- $v_d$ to be duck's velocity, $v_f$ to be fox's and $\omega_f$ to be its angular velocity.
- $r$ to be grey circle's radius, $R$ to be pond radius.
- $\theta$ to be the potential angle duck takes to reach shore, while $\gamma$ being the angle fox will travel during the time duck takes to reach the shore.
- $d$ being the distance duck travelled.
From here, we can immediately derive a few relations:
- $\frac{r}{R} = \frac{v_d}{v_f}$
- $d = \sqrt{(R \cos{\theta} - r)^2 + (R\sin{\theta})^2} = \sqrt{R^2 + r^2 - 2Rr\cos{\theta}}$
- $\gamma = \frac{d}{v_d}\omega_f = \frac{d}{v_d}\frac{v_f}{R} = \frac{d}{r}$
We will define the objective as the final angle between duck and fox and aim to maximize it: $$f(\theta) = \theta + \pi - \gamma = \theta + \pi - \frac{\sqrt{R^2 + r^2 - 2Rr\cos\theta}}{r}, \text{where } 0\leq\theta\leq \arccos{\frac{r}{R}}.$$
Side note on the limits, if $\theta\lt 0$, then it will certainly be worse for duck as it travels in direction of fox. If $\theta\gt \arccos{\frac{r}{R}}$, which means duck travels beyond the tangent line, this will cause fox to chase in the opposite direction and resulting in a speedier catch/failure as well.
We can take derivative and attempt to solve for optimal solution (assume there is one). $$f'(\theta) = 1 - \frac{R\sin\theta}{\sqrt{R^2 + r^2 - 2Rr\cos\theta}} = 0$$ With basic calculus, we get the following, $$R^2\cos^2\theta - 2Rr\cos\theta + r^2 = 0$$ $$\theta = \arccos{\frac{r}{R}}$$ Meaning our upper limit for $\theta$ (intersection of tangent line to grey circle and the pond) happens to be a critical point.
To further confirm, we can also plot out the solution for case when $v_f = \pi v_d$.
The optimal path onwards is indeed to aim for an angle of $\theta = \arccos{\frac{r}{R}}$.
Conclusion
The optimal strategy is as follows:
- Move spirally towards the grey circle from center of pond, until duck reaches maximum angle/distance away from the fox.
- From that point, move along tangent line of grey circle to shore.
Give it a try!