Recent

Author Topic: A Minesweeper program  (Read 5503 times)

jls890

  • New Member
  • *
  • Posts: 22
A Minesweeper program
« on: May 07, 2016, 03:02:51 am »
Hi there.

This is my minesweeper program written in Lazarus.
http://joselauro.bugs3.com/mines.html
I would like to thank you all for the Lazarus Ide and for the lots of information here, :)
Than you very much!
The best programming language is the one you know.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 570
    • My "almost daily" development blog
Re: A Minesweeper program
« Reply #1 on: May 07, 2016, 10:32:42 am »
Cool! :) I love minesweeper too :)
I've also been writing a minesweeper game in Lazarus a few years ago https://sourceforge.net/projects/metarsweeper/ (but ended up in need of rewriting it to Castle Game Engine and postponed the project finalization).
Lazarus 1.9 + FPC 3.1.1 Debian Jessie 64 bit.

My Free and Open Source games in Lazarus/FreePascal/CastleGameEngine:
https://decoherence.itch.io/
(and some ancient games in Turbo Pascal too)
Sources are here: https://github.com/eugeneloza?tab=repositories

jls890

  • New Member
  • *
  • Posts: 22
Re: A Minesweeper program
« Reply #2 on: May 07, 2016, 11:28:44 pm »
Hi Eugene.
Thank you for your feedback! :)
By the way, how do you generate the mines in the begining of the game?
In my case I calculate the chance of any position to be a mine, and then I fixed the problems caused by this aproach, such as not having the correct number of mines.
But I think this is not the best way.
Thank you again.
José Lauro.
The best programming language is the one you know.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 570
    • My "almost daily" development blog
Re: A Minesweeper program
« Reply #3 on: May 07, 2016, 11:35:14 pm »
By the way, how do you generate the mines in the begining of the game?
Yes, but not in a very optimal way, so it becomes slow.
Practically the algorithm is the following:

Put a mine on the field.
Check for the field solvability ("the best algorithm" is based on a few guesses, e.g. I demand that the field should be at least 50% solvable)
If field is solvable (and total amount of guesses does not exceed a predefined value) - place another mine if not - remove this mine and place it elsewhere
repeat until no mines left in the pool, or N mines failed to be placed.

I've already made up an algorithm how to make this process quicker (place mines only in adjacent areas and solve only changes from the previous time), but I'm still afraid it would reduce the generation difficulty.
« Last Edit: May 07, 2016, 11:36:57 pm by Eugene Loza »
Lazarus 1.9 + FPC 3.1.1 Debian Jessie 64 bit.

My Free and Open Source games in Lazarus/FreePascal/CastleGameEngine:
https://decoherence.itch.io/
(and some ancient games in Turbo Pascal too)
Sources are here: https://github.com/eugeneloza?tab=repositories

jls890

  • New Member
  • *
  • Posts: 22
Re: A Minesweeper program
« Reply #4 on: May 10, 2016, 04:30:57 am »
Hi Eugene.

Thank you for your feedback.
Well, I just did a new version, with '8 led like' numbers for the time, and a pause button.
Best whishes.
The best programming language is the one you know.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1106
    • Burdjia
Re: A Minesweeper program
« Reply #5 on: May 10, 2016, 12:27:10 pm »
Cool.  May be you can add graphics for the mines, and more LED labels to make it perfect.  :)
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

jls890

  • New Member
  • *
  • Posts: 22
Re: A Minesweeper program
« Reply #6 on: May 13, 2016, 03:52:10 am »
Dear Ñuño Martínez.
Thank you for your feedback.
I have created a new version with more 'LED likes'.
I did not understand about the mines. Mine ones are just red balls, but I don't have any idea.
Thank you again.


Update: Now it has naval mines figures.  :)
« Last Edit: May 14, 2016, 10:21:15 pm by jls890 »
The best programming language is the one you know.

 

TinyPortal © 2005-2018