Dynamic programming and python for a game of battleships