Thread: Jigsaw Puzzle

  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
    Ireland
    Posts
    8,446
    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.
    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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    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.

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    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.

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, 05:26 PM
  3. Crossword Puzzle Program
    By Loctan in forum C++ Programming
    Replies: 2
    Last Post: 07-31-2006, 11:08 PM
  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, 09:12 AM