the game battle ship ship location
Ältere Kommentare anzeigen
hi
i am trying to code the game battleships,
how do i write the code for 2 players to chose the location of their ships?
the ship grid is a 6x6 grid (top left 1 bottom right 36)
each player has to place 5 ships
1- 1x2 (in size)
2- 1x3
1- 1x4
1- 1x5
the ships can only be placed left to right or up and down
the ships cannot over lamp
and each player should be able to choice there own placement with the program rembering where they placed their ships
3 Kommentare
Geoff Hayes
am 31 Dez. 2021
@James Webber - how is the user choosing the location of each ship? Do you iterate over each of the five ships and ask the user to enter the coordinates (or start position and direction)? Do you then validate the inputs and action them or, if invalid, ask the user to re-enter the coordinates?
James Webber
am 31 Dez. 2021
Geoff Hayes
am 31 Dez. 2021
@James Webber - what have you tried so far?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Strategy & Logic finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!