Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to write a function about battleship game. I already write down the first fucntion which is_win function, but i am stuck on the

image text in transcribed

I need to write a function about battleship game. I already write down the first fucntion which is_win function, but i am stuck on the rest of them.

* need to use python to write function

the first one i wrote is:

def is_win(lst): """(list of int) -> bool Return True if all elements of the list are 0, and False otherwise. >>> [0, 0, 0, 0] True >>> [0, 1, 0, 0] False """

The first parameter is the number of rows and the second is the number of columns in the board. Return a board with the specified number of rows and columns, where each cell of the board contains the NOT_KNoWN symbol. Each element in the outermost list should correspond to a row in the board The first two ints are a row and column, and the third and fourth ints are another row and column. The last parameter is a symbol board. Return True if the path from the first row and column cell to the second row and get viewboard: (int, int) -> list of list of str is_occupied: (int, int, int, int, 1ist of list of column cell, including those two cells, is not completely empty, and return alse otherwise. The rows and str) > bool columns given may form a horizontal or a vertical path. Do not make any assumptions about the order of rows or columns (e.q., smaller to larger row number, etc. The two int parameters represent the row and column of a cell, and the list of list of str parameters update_view_board: (int, nt, list of list of str, list of represent a player's view board and their opponent's symbol board, respectively. Set the element of that cell list of str) >NoneType in the view board to HIT or Miss using the corresponding cell from the symbol board The parameter is a view board. Return a 3-element list that contains: a. the number of moves made so far in the board, based on the number of its no longer NoT_KNows elements, b. the number of moves that were successful (i.e., resulted in a HIT), and c. the number of unsuccessful moves (i.e., moves that resulted in a MISS) get moves_info: (list of list of str > list of int The elements of the list have to be in the order specified here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions