How does mark_unsafe method work?


I am having trouble understanding how the mark_unsafe(self, ship) method works I usually have a difficult time understanding OOP related code. and since I don’t understand as it does not return anything I am unable to make my own mark_safe method.


It’s a method on MapCell, which sets an internal field (that stores ‘what ship is on this cell’). The navigation function checks the internal field to determine whether it can move to a cell.


doesn’t is_occupied method does the same thing then? since in Naive_navigate method we are checking if the position the ship is going to be moving at is empty or not.


is_occupied return cell status
mark_unsafe change cell status