Battleship game design: implement only the guessing step.
Given ship coordinates, previously guessed coordinates, and one new guess, classify the guess and return the updated guess history.
Implement guess_battleship(ships, guessed, row, col).
ships is a list of ships. Each ship is a list of [row, col] cells.guessed is the list of [row, col] cells guessed before this turn.{"status": ..., "guessed": ...}.Check these rules in order and return the first one that applies:
already_guessed: [row, col] is already in guessed. Return guessed unchanged.miss: the cell is not part of any ship.win: the cell hits a ship, and after this guess every cell of every ship has been guessed.sunk: the cell hits a ship, and after this guess every cell of that ship has been guessed, but other ships still have unguessed cells.hit: the cell hits a ship that still has unguessed cells.For every status except already_guessed, the returned guessed is the input list with [row, col] appended at the end.
def guess_battleship(ships, guessed, row, col):