How to make 4 ships in this game? Please reply!


#1

Please help!!! :grin:


#2

Look at how the position of the ship is determined:
ship_row = random_row(board)
ship_col = random_col(board)

And then how whether or not you've hit the ship is determined:
if guess_row == ship_row and guess_col == ship_col:
print "Congratulations! You sank my battleship!"

So if you add in more ships, say for instance a ship called Bill, you have to adjust the code that determines the position of the ship for multiple ships, as so:
ship_row = random_row(board)
ship_col = random_col(board)
bill_row = random_row(board)
bill_col = random_col(board)

And the code that determines whether or not you've hit something:
if guess_row == ship_row and guess_col == ship_col or guess_row == bill_row and guess_col == bill_col
print "Congratulations! You sank my battleship!"

And there you have it. The same format goes for each additional ship you want to add, so just add in another three ships with this format.