the game battle ship ship location

조회 수: 2 (최근 30일)
James Webber
James Webber 2021년 12월 30일
댓글: Geoff Hayes 2021년 12월 31일
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
James Webber
James Webber 2021년 12월 31일
@Geoff Hayes- by writing the number of the cube they wish the ship to start in and then either choising left right up or down for the computer to place the rest of the ship
should be asked for each ship
if the location of the ship goes out of bounds the it should ask them to re-enter the coordinates
Geoff Hayes
Geoff Hayes 2021년 12월 31일
@James Webber - what have you tried so far?

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2021년 12월 31일
There are lots of battleship games posted here in Answers as well as the File Exchange. Why don't you see how they did it?

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Number games에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by