Need help on Minesweeper with formatting issues.

조회 수: 1 (최근 30일)
Nathen Eberhardt
Nathen Eberhardt 2020년 2월 23일
댓글: Geoff Hayes 2020년 2월 26일
I am in need of help understanding this problem. Not sure where to go from my code i Have. so far i have created a 10x10 random array and labeled another array with every number in the rand(10) thats greater than .85 = 1. Also i have made the 2x2 corners top and bottom safe spots 'equaling 0'.
clc, clear, format compact
% Place mines
mine_probabilities = rand(10);
mine = mine_probabilities > 0.85;
% Make the beginning/end "safe"
mine(1:2,1:2) = 0;
mine(9:10,9:10) = 0;
disp(mine)
The next step is:
INITIALIZE GAME WINDOW: Create a new 10x10 array called game_window. This is the “field” that will be displayed while you are playing your game.
Every element in game_window should be -1, EXCEPT for where your “player” is located:
• Create a new variable my_position = [1, 1]; to describe your player’s current position (in terms of row, column).
• Set the corresponding element (element (1,1)) of game_window equal to 100. This is how you know where your player currently is.
  댓글 수: 1
Geoff Hayes
Geoff Hayes 2020년 2월 26일
Nathen - you have created the array of mines and so now you need to create the game field (where the player will navigate). The notes indicate that you need to create a 10x10 array (much like you have done for the mines) with all elements initialized to -1. You then need to create a variable that will keep track of where the user is. This variable will be the xy or row-column position of the player in the field. You set this position (in the field) to be 100 so that it is clear where the player is.

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

답변 (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