Need help on Minesweeper with formatting issues.
1 回表示 (過去 30 日間)
古いコメントを表示
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
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!