correction in minesweeper.c - #9
Open
mikhatech wants to merge 1 commit into
Open
Conversation
As I understand:
while(mines_left > 0) {
int rand_x = rand() % PLAYFIELD_WIDTH;
int rand_y = rand() % PLAYFIELD_HEIGHT;
// make sure first guess isn't a mine
if (minesweeper_state->minefield[rand_x][rand_y] == FieldEmpty &&
(minesweeper_state->cursor_x != rand_x || minesweeper_state->cursor_y != rand_y )) {
minesweeper_state->minefield[rand_x][rand_y] = FieldMine;
mines_left--;
}
}
cursor_x and cursor_y are the current position of the "cursor" and the position where the first click was made. Now there is made a check, if the mine, that wants to be created, is not in the same column and not in the same row as the mine that wants to be placed. But for us it is totally fine, if the mine is either not in the same row !or! not in the same column. That is why "$$" must be changed to "||".
I tried to find in the internet a way to compile the code and test it. I did not find a good instruction for that. Is there any possibility to check the code on the computer or I always have to do it on the flipper? What program do you use for compiling the code?
Best regards,
Mikhail
|
you compile it on the firmware; put it in the plugins folder, then do ./fbt updater_package and it will create all the faps... there are simpler ways to only compile the fap, but this will work... fap ends up in assets/resources/apps |
mac-edmondson
added a commit
to mac-edmondson/minesweeper
that referenced
this pull request
Jan 7, 2024
…clude panki27#9 functionality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As I understand:
while(mines_left > 0) {
int rand_x = rand() % PLAYFIELD_WIDTH;
int rand_y = rand() % PLAYFIELD_HEIGHT;
// make sure first guess isn't a mine
if (minesweeper_state->minefield[rand_x][rand_y] == FieldEmpty &&
(minesweeper_state->cursor_x != rand_x || minesweeper_state->cursor_y != rand_y )) {
minesweeper_state->minefield[rand_x][rand_y] = FieldMine;
mines_left--;
}
}
cursor_x and cursor_y are the current position of the "cursor" and the position where the first click was made. Now there is made a check, if the mine, that wants to be created, is not in the same column and not in the same row as the mine that wants to be placed. But for us it is totally fine, if the mine is either not in the same row !or! not in the same column. That is why "$$" must be changed to "||".
I tried to find in the internet a way to compile the code and test it. I did not find a good instruction for that. Is there any possibility to check the code on the computer or I always have to do it on the flipper? What program do you use for compiling the code? Best regards,
Mikhail