calculating and storing the positions of ships on the grid