Hpdrcin rememberthatthecellxycanbeaccessedasb a

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: ignment will be written in a file named battleship.py Assignment 4a Implement n w b a d a function with 2 arguments: The w d h of the board and the h i h e_or, it egt 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 [0][0], and the bottom right cell is indexed as [height­1][width­1]. 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 paesi, or length of the ship, s i _ e g h a tuple (x,y) representing the b w of the ship, and a tuple hplnt, o (dx,dy) representing the direction the ship is facing ­ s i _ i e t o . hpdrcin 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.

Ask a homework question - tutors are online