Vinatorul / minesweeper-rs

Simple minesweeper in Rust
MIT License
76 stars 9 forks source link

fix: true number of mines on board, not the case before #23

Closed waynenilsen closed 9 years ago

waynenilsen commented 9 years ago

If there was a high mine density before, there would not be that many mines on the board. This addresses this issue. I don't know how "fix" suits this commit but that is what I labeled it.

Vinatorul commented 9 years ago

Looks great! Thank you! I will merge a little later.

dylanhart commented 9 years ago

This could better be implemented by the following:

  1. make a list of numbers from 0 to (grid_w * grid_h)
  2. shuffle the list
  3. starting from the beginning of the list, put a mine on each index until the number of mines is reached

This would stop the program from checking if a cell is a mine on every mine creation.

waynenilsen commented 9 years ago

I think that is exactly what the improvement commit does. Funny how you described the exact algorithm that I ended up using.

dylanhart commented 9 years ago

Oops didn't see that second commit. On Sep 3, 2015 8:25 AM, "waynenilsen" notifications@github.com wrote:

I think that is exactly what the improvement https://github.com/waynenilsen/minesweeper-rs/commit/8c7ff7f38ad00763a4b0725d0ca0aa6225337f11 commit does. Funny how you described the exact algorithm that I ended up using.

— Reply to this email directly or view it on GitHub https://github.com/Vinatorul/minesweeper-rs/pull/23#issuecomment-137484966 .

Vinatorul commented 9 years ago

:+1: Merged!