11/7/2022 0 Comments Global minesweeper game![]() ![]() The Cell::show() routine doesn't alter the underlying Cell object, and so it should be declared const. then where you currently have system(CLEAR) use this instead: Since you're already using and relying on ANSI escape sequences, do this instead: auto constexpr CLEAR = "\x1b[2J" Specifically, if some program is defined and named clear, your program may execute that program instead of what you intend, and that other program could be anything. The second is that it's a potential security hole, depending on which shell the user has, which you absolutely must care about. #GLOBAL MINESWEEPER GAME PORTABLE#The first is that it is not portable to other operating systems which you may or may not care about now. There are two reasons not to use system("clear"). ![]() In particular, instead of rand, you might want to look at std::uniform_real_distribution and friends in the header. That's not bad, and it avoids most of the usual problems, but since C 11, we have had better random number generators available. You are currently using row = rand() / (RAND_MAX / board.size() 1) Here are some observations that may help you improve your code. Note: This implementation does not include the option of adding flags. If (val >= GRIDSIZE || val = 0
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |