Assignment5a implementg t v l e k

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: hip, part is a number from 0 at the bow towards length­1 aft (backwards towards the stern) and [size] is a length 1 list, containing the number of the remaining parts of the ship. When successfully placing a ship, do the following: 1. Find the maximum ship index in the grid 'm'. The new ship's index will be 'm+1'. (The first ship placed will have index of 1.) 2. The part number is 0 for the bow (front of the ship), length­1 for the stern (back). 3. The starting size of the ship is its length. 4. In each cell occupied by the ship, place a tuple containing the above information. Remember that size is stored in a list. Why is that necessary? When successfully hitting a ship, do the following: 1. Decrease the size of the ship. If the size becomes 0, the ship is destroyed, and its index will have to be returned. You may not search the grid in order to update the ship size. 2. Remove the ship from the relevant cell, i.e., set the cell to None. Note that this means that shooting a cell a second time, after it is hit, will be considere...
View Full Document

This document was uploaded on 03/20/2014 for the course CMSC 67101 at Hebrew University of Jerusalem.

Ask a homework question - tutors are online