This is a very simple application of the minimax algorithm to play an adversarial zero-sum game against the computer. It is based on concepts learned when I took the class CS221 (Artificial Intelligence) taught by Prof. Percy Liang at Stanford.
The last player to move the "rock" into the end position wins the game. This can be modelled as a subtraction game - assume we start with a number 25 and either player can subtract 1,2 or 3. Turn by turn, each player chooses how much to subtract. The person to subtract the last number and reach 0 wins.