How do I correlate two matrices together
1 回表示 (過去 30 日間)
古いコメントを表示
How do i correlate two matrices together for minesweeper.
I have one matrix
mine_probabilities = rand(10);
mine = mine_probabilities >= .85
mine(1:2,1:2) = 0;
mine(9:10,9:10) = 0;
This Matrix called "mine" is the field for the bombs in minesweeper with a 1 indicating a bomb is present, 0 is a safeground.
Now I need to create a Game Window matrix "Game_Window" which the user will see with the ones and zeros from matrix "mine" covered up and labeled all -1 but still going back and correlating to the "mine" matrix.
0 件のコメント
採用された回答
Geoff Hayes
2020 年 2 月 27 日
Nathen - if we assume that the matrices are of the same dimension (which they will be for this game) then you can use the position of the player in the game matrix (given by row and column indices) to determine if there is a mine in that same position. For example,
playerRowIndex = 4;
playerColIndex = 5;
isMine = mine(playerRowIndex, playerColIndex);
where isMine will tell you if there is a mine where the player is. I think from what you have posted elsewhere you will have this position and in the game matrix, you'll set this to 100 (indicating position of player).
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Conway's Game of Life についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!