Results 1 to 10 of 15

Thread: 8 Puzzle for Linux

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Quote Originally Posted by SilverWarior View Post
    Perhaps I might go and check how computers are trying to solve such puzzles and learn just as how I learned how to solve Sudoku puzzles
    Inded it would be interesting to see how computers tackle problems like this. I guess for small puzzles like 3x3 brute force could do it, or some clever algorithm. Wouldn't be surprised if those already exist somewhere. I also assume this could be a good start for the upcoming AIs. New AI:s or students of AI probably get these puzzles as one of their first assignments. But I'm on thin ice here and I also have no intention to try to make a program for solving the puzzle.


    What I do know for certain is that a friend's class at a local university once got the assignmet to program a 15-puzzle in pascal. That was a long time ago so he had to do the programming on paper at home and then try it out on the univerity computer when access was available. I never saw his result but I recall he was pretty proud about it.


    Meanwhile replying to your other post will have to wait. Right now I'm struggling with the randomizing thingie. Hopefully something can be presented any week now.

  2. #2
    Quote Originally Posted by Jonax View Post
    I guess for small puzzles like 3x3 brute force could do it, or some clever algorithm.
    I doubt brute force approach would be very effective here. Why? To many chances to end up repeating same sets of moves within a loop which could then end up in endless cycle.

    Quote Originally Posted by Jonax View Post
    Wouldn't be surprised if those already exist somewhere.
    Of course they do exist. One of the most common mentioned algorithm for solving Sliding puzzles is Iterative deepening A* algorithm: https://en.wikipedia.org/wiki/Iterative_deepening_A*

  3. #3
    Update:


    Progress quicker than anticipated.
    Random but solvable start mode now added (version 0413). Foreign numbers still available.
    It seems to work as intended, but one never knows what bugs dwell in the dark corners of the code.



    Thanks for valuable feedback @silverwarior


    No plans to use iterative deepening algorithms for this project.
    Got to start tackling the graphics /ascii art situation first.
    That will be a task for next mini-game project . Which hasn't started yet.

    Now time to enjoy some well deserved beer and cheese

  4. #4
    Update: it turned out the lightweight desktop environment LXQT doesn't come with Thai or Ethiopian fonts installed. I assume it's the same for the Xfce. I'm sure there are ways to install desired fonts there but I have no such experience. I'm afraid I have to say the 8Puzzle works best on KDE or Gnome.


    Haven't yet started with the ascii art project and haven't digested all the suggestions from SilverWarior, but I totally agree about the monospaced fonts. Very useful.

  5. #5
    Update:

    New mini-game project is started with dual approach.
    Background decoration as (huge) bitmap file. Currently linux allows 300 % scaling for the happy owners of huge monitors. So the image better be big enough to handle that.

    In the new project the executable increases from previously ~3 MB to ~11 MB. Still reasonable but there may also be a gziped version for download.
    What do you guys say? downloading 11 MB is no big deal nowadays? Compressing the file may be overkill?

    Then for this project there is also the scalable vector graphics approach.
    I try a home-made version using a series of

    image.canvas.line(x1,y1,x2,y2);

    commands.

    The current result is shown below




    (image may be removed from the server at some later time)

    Quite blocky but it scales decently and I start to like it.
    Might even keep it. We will see. The ascii-art will have to wait.

    The actual game?

    Can you guess the theme from the presented "art"?

    As often it's a variation of an old and well known concept, with some Jonax touch added.

    Hopefully it can be presented any week now. At least if I make do with the above "art" and solve a few remaining bullet points.

  6. #6
    Quote Originally Posted by Jonax View Post
    What do you guys say? downloading 11 MB is no big deal nowadays? Compressing the file may be overkill?
    11 MB is no big deal today. Especially if you take into account that may web-pages can exceed 5 MB od downloadable data per page.
    As for tying to reduce size of your executable that has increased due to including a large image in it. You can do a lot by using appropriate image format. For instance:
    If your image has low number of colors then using PNG image format would reduce the data size the most due the way PNG image compression works.
    If your image has lots of colors like in a photo then using JPEG might be better idea since JPEG compression is developed to better handle this kind of images.
    You should avoid storing images in plain BMP format since BMP offers no compression.

    Quote Originally Posted by Jonax View Post
    I try a home-made version using a series of

    image.canvas.line(x1,y1,x2,y2);
    You should check TCanvas.Polyline (https://lazarus-ccr.sourceforge.io/d....polyline.html) which allows you to draw a line across a an array of points. It will probably make your life a bit easier
    And of you want less "linear" results you may also want to check TCanvas.PolyBezier (https://lazarus-ccr.sourceforge.io/d...olybezier.html) which allows drawing of nice curved lines.

  7. #7
    Thanks for input and suggestions . I'll probably skip the zipping. Indeed the PNG and JPG formats are great. I think in this case I had some problem making it work with PNG, while a BMP-file behaved well albeit being huge. Anyway. First priority is to create something executable and playable at all.

    I'll have a look at the polyline and bezier suggestions.
    Indeed my approach while getting the job done started to get cumbersome, as more points were added . In fact I spent 100 lines of code just to make that image. A polyline with array could no doubt simplify things. And more curvy lines can add some allure.

    There's still some polishing and adding of functionality to do so nothing can be presented yet. Hopefully a new thread can be started for the new project in the coming week(s).

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •