Jigsaw Puzzle

This is a discussion on Jigsaw Puzzle within the Game Programming forums, part of the General Programming Boards category; Guys, Need help with designing an algorithm for solution to a jigsaw puzzle involving rectangular and right angled isoceles triangle ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    3

    Jigsaw Puzzle

    Guys,
    Need help with designing an algorithm for solution to a jigsaw puzzle involving rectangular and right angled isoceles triangle pieces only. Images are in .bmp format. The pieces are in a single bmp file separated by black borders...........thnx in advance

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,532
    Hmm... not sure what you mean.
    A standard jigsaw solution can be easily achieved by numbering the pieces. The player doesn't know about this numbering but the game engine just checks for all the pieces to be in order for it to name the player a winner.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    3
    Thanks Mario.F for replying. What I meant was an original bmp will be there as well as a bmp containing the fragments separated by black border. An algorithm to scan this second bmp and come up with a resulting bmp that will be the original picture, is what I need help with. The pieces may be rotated by multiples 0f 90 degrees...........

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,755
    So basically
    - open a BMP file and scan for shapes
    - open another BMP containing the puzzle - scan that for shapes as well
    - try and fit the first set to the second

    OK, how about we start with do you know how to read a BMP file?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    3

    Thank You

    Thank you Salem............yes I know how to read a bmp file in c. But the problem that I'm facing here is that the pieces of the puzzle are given in one bmp and they are straight edged(rectangular or right angled isoceles). So I did not understand what you meant by scanning for shapes..............some more help will be appreciated.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,755
    Well for example, if most of the BMP is white, and the shapes are marked by black lines, it's simply(*) a matter of finding a black pixel, then working your way round the image until you get back to your starting point. Along the way, you figure out from the turns in direction which shape you've got.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The puzzle again...Swapping elements of 2D array
    By crazygopedder in forum C Programming
    Replies: 44
    Last Post: 11-05-2008, 01:53 PM
  2. Replies: 12
    Last Post: 06-06-2008, 06:26 PM
  3. Crossword Puzzle Program
    By Loctan in forum C++ Programming
    Replies: 2
    Last Post: 08-01-2006, 12:08 AM
  4. Solution to Google Puzzle 3,3,8,8=24
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 06-01-2006, 10:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21