-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbattleship.py
40 lines (30 loc) · 834 Bytes
/
battleship.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import board
import ship
BOARDSIZE = 10
PLAYERBOARD = board.Board(BOARDSIZE)
COMPUTERBOARD = board.Board(BOARDSIZE)
HITX = 1
HITY = 1
SHIP1 = ship.Ship("Motorlaunch", 2, 3, 3, 'V')
SHIP2 = ship.Ship("Carrier", 5, 5, 5, 'H')
def start_game():
"""Start the game"""
print("Let's play Battleship!")
def print_game():
"""Print the game"""
print('-------------------')
# board.Board.print(COMPUTERBOARD)
print('===================')
board.Board.print(PLAYERBOARD)
print('-------------------')
# ------------------- MAIN -------------------
if __name__ == '__main__':
start_game()
# print_game()
SHIP1.place(PLAYERBOARD)
SHIP2.place(PLAYERBOARD)
print(SHIP1.attack(PLAYERBOARD, 3, 4))
print(SHIP2.attack(PLAYERBOARD, 5, 6))
print_game()
# SHIP1.show()
# SHIP2.show()