4 # Programme de Bataille Navale
6 # Codé par Lucie Mazet
18 ships
= [1, 1, 1, 1, 2, 2, 3]
30 def display(main_tab
, second_tab
=[]):
32 # display all symbols in main tab
36 if len(second_tab
) != 0:
37 # only display 'O' and 'X'
43 def read_coordonate(size
, tab
):
47 def generate_coordonate(size
, tab
):
50 # put element into table
51 def put_in_table(element
, pos
, tab
):
55 def check_status(tab
):
61 # init table for human
65 print("Where do you want to place a ship of", ship
, "?")
66 pos
= read_coordonate(ship
, tab_human
)
67 put_in_table('S', pos
, tab_human
)
69 # init table for machine
70 init_table(tab_machine
)
73 pos
= generate_coordonate(ship
, tab_machine
)
74 put_in_table('S', pos
, tab_machine
)
80 display(tab_human
, tab_machine
)
81 print("Where do you want to bomb?")
82 pos
= read_coordonate(1, tab_machine
)
83 put_in_table('B', pos
, tab_machine
)
84 if check_status(tab_machine
):
90 pos
= generate_coordonate(1, tab_human
)
91 put_in_table('B', pos
, tab_human
)
92 if check_status(tab_human
):
100 if __name__
== "__main__":
103 # vim: set ts=4 sw=4 et: