dimanche 26 juillet 2020

I'm trying to create a battleship game but I'm using lists instead of a normal grid

row1 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row2 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row3 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row4 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row5 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row6 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row7 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row8 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row9 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row10 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]

This is the code that the A.I would use for it's own grid. It would work so that a string that would repesent a ship would be inserted into the lists e.g.

row1 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row2 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row3 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row4 = [['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]
row5 = [['-'], ['-'], ['-'], ['-'], ['A'], ['-'], ['-'], ['-'], ['-'], ['-']]
row6 = [['-'], ['-'], ['-'], ['-'], ['A'], ['-'], ['-'], ['-'], ['-'], ['-']]
row7 = [['-'], ['-'], ['-'], ['-'], ['A'], ['-'], ['-'], ['-'], ['-'], ['-']]
row8 = [['-'], ['-'], ['-'], ['-'], ['A'], ['-'], ['-'], ['-'], ['-'], ['-']]
row9 = [['-'], ['-'], ['-'], ['-'], ['A'], ['-'], ['-'], ['-'], ['-'], ['-']]
row10 = [['-'],['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-'], ['-']]

How do I make the inserting random and with multiple other ships.




Aucun commentaire:

Enregistrer un commentaire