I'm not sure why you'd specifically want to use dynamic programming and/or Manhattan distance for this puzzle. This is a game for which you can find a fixed solution.
If you go first and there are 3 bananas, no matter what you play, I win. You pick one, I pick two, and vice versa. If there are six bananas, the same logic allows me to reduce the game to the 3 banana case. In fact, for any 3n bananas, I can reduce the game to 3(n-1) bananas. If the number of bananas isn't a multiple of three, then you can make it a multiple of three (By removing either one or two bananas), and ensure victory.
For k bananas, you always remove k % 3
. If k % 3 == 0
, you've lost unless your opponent makes a mistake, so play whatever you like. That's it.