TITLE: An ant on an infinite chessboard
QUESTION [14 upvotes]: There is an infinite chessboard, and an ant $A$ is in the middle of one of the squares.
The ant can move in any of the eight directions, from the center of one square to another.
If it moves 1 square north, south, east or west; it requires $1$ unit energy.
If it moves to one of its diagonal neighbor (NE, NW, SE, SW); it requires $\sqrt 2$ units of energy.
It is equally likely to move in any of the eight directions.
If it initially has $20$ units of energy, find the probability that, after using the maximum possible energy, the ant will be $2$ units away from its initial position.
Assumption
If in case it doesn't have enough energy to move in a particular set of directions, it will move in any of the other directions with equal probability.

I approached this problem, considering that the case that it finally ends up $2$ units to the east (we can multiply by four to get all the cases).
If it ends up $2$ units to the east, then $\text{Total steps to right}=2+\text{Total steps to left}$.
We will somehow balance these steps, considering that the ant has a total of $20$ units of energy at the start.
I don't know how to effectively calculate the sample space either.
If the ant takes a total of $n$ steps, such that while taking all $n$ steps it is equally likely to move in any of the eight directions, then the sample space would be $8^n$.
But here we do not know $n$. Further, if the energy left after the second-last step is less than $\sqrt 2$ and more than $1$, then the ant will not be able to move diagonally.
I wasn't able to think of much after this. Help is appreciated.

REPLY [6 votes]: Here is a solution in terms of formulas. My ant starts at $(0,0)$ and visits lattice points.
Energywise the history of the ant can be encoded as a word $AADADAAAD\ldots$ where the letter $A$ denotes a move parallel to one of the axes and $D$ a diagonal move. The individual letters are obtained by a coin toss, and the word ends when the ant's energy is used up. Denote by $a$ and $d$ the number of $A$- resp. $D$-steps. Then $$d\leq d_a:=\left\lfloor{20-a\over\sqrt{2}}\right\rfloor\ .$$
Each word corresponds to a staircase path in the first quadrant of the $(a,d)$-plane, as shown in the following figure:

The path ends at a red point, where there is no more energy for an additional step. At a blue point the following  rule takes place: If a $D$ is thrown (with probability ${1\over2}$) at that point the ant makes an $A$-move nevertheless. It follows that all paths end at a red point $(a,d_a)$. The probability $p(a)$ that the number of $A$-moves is  exactly $a$ is then given by the following formulas:
$$p(a)=0\qquad{\rm if}\qquad d_a=d_{a+1}\ ;$$
$$p(a)={a+d_a\choose d_a}2^{-(a+d_a)} \qquad{\rm if}\qquad d_{a-1}>d_a>d_{a+1}\ ;$$
$$p(a)=
{a+d_a\choose d_a}2^{-(a+d_a)}+{1\over2}{a-1+d_a\choose d_a}2^{-(a-1+d_a)}\qquad{\rm if}\qquad d_{a-1}=d_a>d_{a+1}\ .$$
We now compute the probability $p_{20}(a)$ that the actual grid path of the ant ends at $(2,0)$, given that it makes $a$ type $A$ moves. It is easy to see that $a$ has to be even in such a case. Given $a$, there are $h$ horizontal moves and $v=a-h$ vertical moves of the ant, where $0\leq h\leq a$. In reality we have $h+d_a$ independent horizontal $\pm1$-steps, which should add up to $2$, and $a-h+d_a$ vertical $\pm1$-steps, which should add up to $0$. Therefore $h+d_a$ has to be even as well. On account of the Bernoulli distribution of the $\pm1$ signs we  obtain in this way
$$p_{20}(a)=\sum_{0\leq h\leq a, \ h+d_a\ {\rm even}}{a\choose h} 2^{-a}{h+d_a\choose (h+d_a)/2-1}\cdot{a-h+d_a\choose(a-h+d_a)/2} 2^{-(a+2d_a)}\ .$$
The requested probability $p$ therefore comes to
$$p=4\sum_{0\leq a\leq 20, \ a\ {\rm even}} p(a)\>p_{20}(a)\ .$$
The computation gave
$$p={26872167014433\over562949953421312}\doteq0.0477346\ .$$