summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibTextCodec
diff options
context:
space:
mode:
authorArda Cinar <kuzux92@gmail.com>2022-12-08 17:44:19 +0300
committerSam Atkins <atkinssj@gmail.com>2022-12-12 16:23:03 +0000
commit5562ef6cc5ac331b5a50ed5e8b11ec62816bfc9d (patch)
tree9e2680d717a43bc1cf582ca5b9bcdf558832eeef /Userland/Libraries/LibTextCodec
parent1cdd3bb74ff0106d0738f97301f02cb67660b3f6 (diff)
downloadserenity-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/LibTextCodec')
0 files changed, 0 insertions, 0 deletions