Unformatted text preview: ignment will be written in a file named battleship.py
Implement n w b a d a function with 2 arguments: The w d h of the board and the h i h
of the board. In case of no height argument, the default board is a square. The default value for width is
10 (new_board() is 10x10, new_board(8) is 8x8, new_board(8,12) is rectangular). Each row of the
board is represented by a list, (left to right,) and the board is a list of lists of rows, (top to bottom). The
top left cell is indexed as , and the bottom right cell is indexed as [height1][width1]. As the
board starts empty, each of the inner arrays is a list of 'None's.
Return an empty grid of the right size. Assignment 4b:
Implement l c _ h p a function with 4 arguments: The b a d in which to place the ships, the
or length of the ship, s i _ e g h a tuple (x,y) representing the b w of the ship, and a tuple
o (dx,dy) representing the direction the ship is facing s i _ i e t o .
Remember that the cell (x,y) can be accessed as b a dy][x]. Re...
View Full Document
This document was uploaded on 03/20/2014 for the course CMSC 67101 at Hebrew University of Jerusalem.
- Spring '14