-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New #12
base: master
Are you sure you want to change the base?
New #12
Conversation
Use tk.destroy() function to close down the window at end of a game when you say you don't want to continue. The quit() function was leaving window open and causing error next time program called.
Add flag to choose to set specific number of mines. If set, will generate correct size list of mines as part of setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution - I thought I had left a review a while back but I never submitted it and just had the comments sitting there 😅
There's a few small tweaks/improvements to be made, but overall I like the approach and looks like indeed there is a bug with closing the window on python3 - I initially wrote this for python 2 so it's most likely popped up since then 😊
@@ -14,6 +14,6 @@ Contents: | |||
|
|||
To Do: | |||
---------- | |||
- Have specific number of mines, rather than random | |||
- ~~Have specific number of mines, rather than random~~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just remove this line entirely
#if fixed number, generate random list of mines | ||
#for simplicity generate set of random numbers going up to x*y size | ||
#will then compare with mine number, counting across row then row by row | ||
mine_list = random.sample(range(SIZE_X*SIZE_Y-1),MINES_TO_SET) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a space after the comma for consistent formatting, please
@@ -130,7 +147,9 @@ def gameOver(self, won): | |||
if res: | |||
self.restart() | |||
else: | |||
self.tk.quit() | |||
self.tk.destroy() #shut down the window |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will throw errors on quit due to updateTimer running in after
, I think wrapping this in an after
also should resolve it, i.e. self.tk.after(100, self.tk.destroy)
although I haven't had the chance to test it yet.
@@ -130,7 +147,9 @@ def gameOver(self, won): | |||
if res: | |||
self.restart() | |||
else: | |||
self.tk.quit() | |||
self.tk.destroy() #shut down the window | |||
#self.tk.quit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to keep commented-out lines, please remove
#count which square number we're on and see if in mine list | ||
isMine = True | ||
self.mines += 1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this blank line just so the if-else block is grouped visually
@@ -12,6 +12,9 @@ | |||
SIZE_X = 10 | |||
SIZE_Y = 10 | |||
|
|||
FIXED_MINE_NUMBER = True #if True set a fixed number of mines, rather than a random outcome |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be nice to add argument parser and set this to False
if run with --random
🤔
Hello. I don't know if you're still working on / maintaining your minesweeper program?
I found it yesterday and was having a play - thanks for sharing/making public.
I saw you had a ToDo to set a fixed number of mines - so I've added functionality to do just that.
I also fixed a bug - on my system at least - where the window didn't close when the game ends and you say no you don't want to continue -- which then causes and error next time you run.
I'm quite new to Git (and Python) and have never done a pull request before, so hope I'm doing this right....
Ashley