def setup_ship(self, pos, direction, player, count, size):
    '\n        Create a ship.\n\n        Creates a ship dictionary based on positional, directional, player, and size data and tests if placement is legal.\n\n        Parameters\n        ----------\n        pos : tuple\n            (y,x) coordinate pair of top-left corner of the ship.\n        direction : int\n            Determines the direction of the ship:\n                0: Horizontal.\n                1: Vertical.\n        player : int\n            Determines which player to assign the ship to. Zero-indexed.\n        count : int\n            Current ship count for internal tracking use.\n        size : int\n            Length of the ship.\n\n        Returns\n        -------\n        str\n            Error string if an error occurred, None otherwise.\n        '
    try:
        if (player == 0):
            board = self.p1_grid
            if (direction == 0):
                for i in range(size):
                    if (board[pos[0]][(pos[1] + i)] != 0):
                        return 'ERROR: You cannot place a ship on top of another!'
            else:
                for j in range(size):
                    if (board[(pos[0] + j)][pos[1]] != 0):
                        return 'ERROR: You cannot place a ship on top of another!'
        else:
            board = self.p2_grid
            if (direction == 0):
                for i in range(size):
                    if (board[pos[0]][(pos[1] + i)] != 0):
                        return 'ERROR: You cannot place a ship on top of another!'
            else:
                for j in range(size):
                    if (board[(pos[0] + j)][pos[1]] != 0):
                        return 'ERROR: You cannot place a ship on top of another!'
    except IndexError:
        return 'ERROR: You must place a ship inside the grid boundaries!'
    if (player == 0):
        self.p1_ships.append({'num': count, 'size': size, 'x_pos': pos[1], 'y_pos': pos[0], 'direction': direction, 'setup': False, 'health': size, 'hits': []})
    else:
        self.p2_ships.append({'num': count, 'size': size, 'x_pos': pos[1], 'y_pos': pos[0], 'direction': direction, 'setup': False, 'health': size, 'hits': []})
    return None
Create a ship.

Creates a ship dictionary based on positional, directional, player, and size data and tests if placement is legal.

Parameters
----------
pos : tuple
    (y,x) coordinate pair of top-left corner of the ship.
direction : int
    Determines the direction of the ship:
        0: Horizontal.
        1: Vertical.
player : int
    Determines which player to assign the ship to. Zero-indexed.
count : int
    Current ship count for internal tracking use.
size : int
    Length of the ship.

Returns
-------
str
    Error string if an error occurred, None otherwise.
def setup_ship(self, pos, direction, player, count, size):
    '\n        Create a ship.\n\n        Creates a ship dictionary based on positional, directional, player, and size data and tests if placement is legal.\n\n        Parameters\n        ----------\n        pos : tuple\n            (y,x) coordinate pair of top-left corner of the ship.\n        direction : int\n            Determines the direction of the ship:\n                0: Horizontal.\n                1: Vertical.\n        player : int\n            Determines which player to assign the ship to. Zero-indexed.\n        count : int\n            Current ship count for internal tracking use.\n        size : int\n            Length of the ship.\n\n        Returns\n        -------\n        str\n            Error string if an error occurred, None otherwise.\n        '
    try:
        if (player == 0):
            board = self.p1_grid
            if (direction == 0):
                for i in range(size):
                    if (board[pos[0]][(pos[1] + i)] != 0):
                        return 'ERROR: You cannot place a ship on top of another!'
            else:
                for j in range(size):
                    if (board[(pos[0] + j)][pos[1]] != 0):
                        return 'ERROR: You cannot place a ship on top of another!'
        else:
            board = self.p2_grid
            if (direction == 0):
                for i in range(size):
                    if (board[pos[0]][(pos[1] + i)] != 0):
                        return 'ERROR: You cannot place a ship on top of another!'
            else:
                for j in range(size):
                    if (board[(pos[0] + j)][pos[1]] != 0):
                        return 'ERROR: You cannot place a ship on top of another!'
    except IndexError:
        return 'ERROR: You must place a ship inside the grid boundaries!'
    if (player == 0):
        self.p1_ships.append({'num': count, 'size': size, 'x_pos': pos[1], 'y_pos': pos[0], 'direction': direction, 'setup': False, 'health': size, 'hits': []})
    else:
        self.p2_ships.append({'num': count, 'size': size, 'x_pos': pos[1], 'y_pos': pos[0], 'direction': direction, 'setup': False, 'health': size, 'hits': []})
    return None