python - "Unblock me" puzzle representation -


I'm trying to implement a program that fixes the "Unblock" puzzle. People who do not know this, "Unblock me" is a sliding block puzzle where you have a board with 1x1, 1x2, 2x1 and 2x2 boxes and take the goal out of the board through the opening of the red box is.

My question is how can I show a board state? I searched through the internet and found a suggestion to represent the state in this way.

For example this board:

Representation:

How I can understand this representation works. The problem comes when I want to move a box. How can I check if the box is 1x1, 1x2, 2x1 or 2x2, to check if the desired move is possible or not?

How can I do this, or any other "easy" representation?

I do:

  • Grid width
  • The height of the grid
  • The list of boxes, and for each box:
    • The dimensions of the box (no square or rectangle)
      • Box width < / Li>
      • The height of the box
      • Each cell
      • Position the top-left cell, so the coordinates (X, Y)
      • The name of the box ( If there is a need to slide a box out of this disturbance, then this is an unblocked puzzle

    • Exiting for that cell, for example, "A", "B", "C")
    • Status (for example, "answer", "east", etc.). This is necessary when the exit corner is located in the cell.

    It is necessary that you need to make any computation. Looking at the box at the top-left of the box, to know the dimensions of the box and to see which ones are captured in the box, you can assess whether a collision is occurring or not.

    The above representation also supports arbitrary shapes, not just rectangular and square.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -