diff options
author | Arda Cinar <kuzux92@gmail.com> | 2022-12-08 17:44:19 +0300 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2022-12-12 16:23:03 +0000 |
commit | 5562ef6cc5ac331b5a50ed5e8b11ec62816bfc9d (patch) | |
tree | 9e2680d717a43bc1cf582ca5b9bcdf558832eeef /Userland/Libraries/LibSyntax | |
parent | 1cdd3bb74ff0106d0738f97301f02cb67660b3f6 (diff) | |
download | serenity-5562ef6cc5ac331b5a50ed5e8b11ec62816bfc9d.zip |
Minesweeper: Use a faster method to generate game field
The existing method was simply using a "randomly generate until it fits
our criteria" method to generate a game field. While this worked OK in
most cases, the run time was increasing seriously in boards whose
mine count / board size ratio was too big.
The new approach simply generates every possible mine location, shuffles
the array and picks its head. This uses more memory (shouldn't be a big
deal since minesweeper boards are generally miniscule) but runs much
quicker. The generation could still use some improvement (regarding
error handling), though :^)
Diffstat (limited to 'Userland/Libraries/LibSyntax')
0 files changed, 0 insertions, 0 deletions