minesweeper
Re: minesweeper
Re: minesweeper
Re: minesweeper
Is this being done in BASIC ?
Re: minesweeper
I'm doing it in ZX Basic by [mention]boriel[/mention]
With a few simple ASM routines
I think it would be too slow in basic
I actually thought it would be quick and simple, but its more complicated that I first thought. The main thing missing at the moment is that is you hit a blank square then it opens up all blanks on the board, but it needs to only open the ones that are connected.
Apart from that and a few bugs the game works now
With a few simple ASM routines
I think it would be too slow in basic
I actually thought it would be quick and simple, but its more complicated that I first thought. The main thing missing at the moment is that is you hit a blank square then it opens up all blanks on the board, but it needs to only open the ones that are connected.
Apart from that and a few bugs the game works now
Re: minesweeper
Actually, that is not that hard, you just need to visit every single neighbor of that cell (up,down, left and right), maybe diagonals too (depending how you want it to open), using a depth first traversal (better used of memory), being the only concern to mark the cells where you have already been in previously (while traversing).Jbizzel wrote: ↑Mon Feb 14, 2022 12:24 am ...
I actually thought it would be quick and simple, but its more complicated that I first thought. The main thing missing at the moment is that is you hit a blank square then it opens up all blanks on the board, but it needs to only open the ones that are connected.
...
That is the typical implementation.
I explained it graphically (animation/video) in my Arcade game port to ZX Spectrum FOSDEM presentation.
Re: minesweeper
I made a BASIC - oneliner in the '80-ies
Game 11, BASIC-line 22
Only missing the automatic find all empty places.
https://spectrumcomputing.co.uk/entry/1 ... /ONELINERS
Re: minesweeper
In fact, you can do it without a depthsearch.RMartins wrote: ↑Tue Feb 15, 2022 7:24 pmActually, that is not that hard, you just need to visit every single neighbor of that cell (up,down, left and right), maybe diagonals too (depending how you want it to open), using a depth first traversal (better used of memory), being the only concern to mark the cells where you have already been in previously (while traversing).Jbizzel wrote: ↑Mon Feb 14, 2022 12:24 am ...
I actually thought it would be quick and simple, but its more complicated that I first thought. The main thing missing at the moment is that is you hit a blank square then it opens up all blanks on the board, but it needs to only open the ones that are connected.
...
That is the typical implementation.
I explained it graphically (animation/video) in my Arcade game port to ZX Spectrum FOSDEM presentation.
I coded the game in 1K on a ZX81 and I had no room to use a depthsearch.
Re: minesweeper
Thanks for the replies, I'll check those links out as I'm not familiar with the technique.
I've got the algorithm working and just need to debug everything.
I do this:
If you click a 0 (not a bomb, and not touching a bomb)
Add all 8 neighbors to a check list
Flag them so they can't be added twice
Then the print routine visits the check pile x and y of each item and prints it on screen. If the checked item is a 0 then it checks all 8 neighbors and adds them to the check pile.
It keeps going until the check pile is empty. No cell can be added to the pile twice.
I've got the algorithm working and just need to debug everything.
I do this:
If you click a 0 (not a bomb, and not touching a bomb)
Add all 8 neighbors to a check list
Flag them so they can't be added twice
Then the print routine visits the check pile x and y of each item and prints it on screen. If the checked item is a 0 then it checks all 8 neighbors and adds them to the check pile.
It keeps going until the check pile is empty. No cell can be added to the pile twice.
Re: minesweeper
The first version I made, when you found a blank it revealed every blank, and their neighbours. That's actually very playable.Dr beep wrote: ↑Wed Feb 16, 2022 4:36 pm
I made a BASIC - oneliner in the '80-ies
Game 11, BASIC-line 22
Only missing the automatic find all empty places.
https://spectrumcomputing.co.uk/entry/1 ... /ONELINERS
It also starts the player on a square that has no bombs.
I know it's possible to have a game board that is always solvable without guessing, but I have no idea how that would work.
Re: minesweeper
that is how my 1K version on the ZX81 works to prevent a large stack.Jbizzel wrote: ↑Sat Feb 19, 2022 12:52 am Thanks for the replies, I'll check those links out as I'm not familiar with the technique.
I've got the algorithm working and just need to debug everything.
I do this:
If you click a 0 (not a bomb, and not touching a bomb)
Add all 8 neighbors to a check list
Flag them so they can't be added twice
Then the print routine visits the check pile x and y of each item and prints it on screen. If the checked item is a 0 then it checks all 8 neighbors and adds them to the check pile.
It keeps going until the check pile is empty. No cell can be added to the pile twice.
it also reveals all fields adjecent to a bomb when you start on a space, like it should.
Except that the field is stored invisible on the screen all the time.
Re: minesweeper
It's good to know.
I've tried not to look at how this should be done. Part of the fun is trying to solve how to do it from scratch, only by playing the game.
Although I did start looking at alternative rules and versions of the game. So there is some scope for doing something that has never been done on the spectrum.
My code is so close now to a full working game. Just a few *bug* - or rather coding mistakes I have made that I can't see!
I don't think this game needs music, I'll probably just leave it with some minimal beeper fx
I've tried not to look at how this should be done. Part of the fun is trying to solve how to do it from scratch, only by playing the game.
Although I did start looking at alternative rules and versions of the game. So there is some scope for doing something that has never been done on the spectrum.
My code is so close now to a full working game. Just a few *bug* - or rather coding mistakes I have made that I can't see!
I don't think this game needs music, I'll probably just leave it with some minimal beeper fx
Re: minesweeper
https://youtube.com/shorts/nnxgMsPAbrE?feature=share
Here's the algorithm in action. With bugs. Fixed a few of them now, but there is still some strange stuff happening
Here's the algorithm in action. With bugs. Fixed a few of them now, but there is still some strange stuff happening
Re: minesweeper
Here is my 1K version. With hilaric gameplay by Rod BellJbizzel wrote: ↑Sat Feb 19, 2022 4:12 pm https://youtube.com/shorts/nnxgMsPAbrE?feature=share
Here's the algorithm in action. With bugs. Fixed a few of them now, but there is still some strange stuff happening
https://www.youtube.com/watch?v=ou4t4FLfnls
Re: minesweeper
1k thats amazing. Is it ASM? its super fast.
interesting to see your "clear 0s algorithm" looks very similar to mine - yours does a big diagonal trip across the field if it can. Mine does exactly the same thing! I've put a delay in so I can watch it go
My major milestone today is that I've removed every GO TO statement from the game.
It would be interesting to do a pure basic version.
Re: minesweeper
Very satisfying when you do that in ZX BASIC isn't it.
I love the loading screen!
Re: minesweeper
Yes it is ASM for multiple reasons
1) commands take less room, no length of line or length of data shorter ( 1 byte can hold a number from 0 to 255)
2) speed indeed
source can be obtained here
https://sinclairzxworld.com/viewtopic.p ... 077#p31077
Re: minesweeper
Here's my code for what its worth - still WIP but completely playable and no obvious show stopper bugs. Although, when I finish I we release it officially as a tap with a loading screen.
https://gitlab.com/JB1zzel1/mine-sweeper-zx-spectrum
A key feature on this version is that it will place the player on a square that is safe, and not touching a bomb. I think this gives it a modern aspect.
Once question [mention]Dr beep[/mention] and others, is how best to generate the field of bombs?
My game goes through the array, and in each location randomly determines if there is a bomb there. On hard mode - more change of bombs. Is there a better of different way to do it?
https://gitlab.com/JB1zzel1/mine-sweeper-zx-spectrum
A key feature on this version is that it will place the player on a square that is safe, and not touching a bomb. I think this gives it a modern aspect.
Once question [mention]Dr beep[/mention] and others, is how best to generate the field of bombs?
My game goes through the array, and in each location randomly determines if there is a bomb there. On hard mode - more change of bombs. Is there a better of different way to do it?
Re: minesweeper
I actually hadn't thought of doing it that way. Mine is more random so you get a varying amount of mines on each skill level.
I might have a go at your solution and see if it feels better. I suppose it would then be easy to ask the user how many bombs they want in the game and give them an exact amount.
I might have a go at your solution and see if it feels better. I suppose it would then be easy to ask the user how many bombs they want in the game and give them an exact amount.