def place_pawn(self, pawn: GridPawn, coord: Coord):
     '''Places a pawn on the grid at position coord if the coordinate is free'''
     coord = self._get_coord(coord)
     if not self.coord_occupied(coord):
         if pawn in self.grid_pawns:
             raise Exception(
                 'Pawn is already in the grid; move it with move_pawn')
         else:
             self.grid_pawns.append(pawn)
             self.occupied_coords.append(coord)
             coord.set_occupied(True)
             coord.occupied_val = pawn
             return coord
     else:
         raise CoordOutOfBoundsException(
             'Coordinate {} is already occupied.'.format(coord.__str__()))
 def move_pawn(self, pawn: GridPawn, coord: Coord):
     '''Moves a pawn that has already been placed on the grid to a new position'''
     if pawn in self.grid_pawns:
         coord = self._get_coord(coord)
         if not self.coord_occupied(coord):
             self.__log.info('moving pawn {} to coordinate {}'.format(
                 pawn.__str__(), coord.__str__()))
             pawn.current_coord.set_occupied(False)
             pawn.current_coord.occupied_val = None
             self.occupied_coords.remove(pawn.current_coord)
             self.occupied_coords.append(coord)
             coord.set_occupied(True)
             coord.occupied_val = pawn
             return coord
         else:
             raise CoordOccupiedException(
                 'Coord {} is already occupied, cannot move pawn'.format(
                     coord.__str__()))
     else:
         raise Exception(
             'Please place pawn on the grid first using place_pawn')