What data structure should I use to represent this board?

enter image description here

 --- --- --- ---
| o | o | o | o |
 --- --- --- ---
| o | o | o | o |
 --- --- --- ---
| o | o | o | o |
 --- --- --- ---
| o | o | o | o |
 --- --- --- ---

Pieces go between circles. The goal is to fill the entire board. I need a way to present the contents of the board. Pieces can be rotated and flipped. I tried using a matrix, but it didn’t work out very well.

Edit: Example:

enter image description hereenter image description hereenter image description here

+4
source share
4 answers

Since the board is so tiny, one way to get closer to this problem is to present the board as a list of pairs of elements + layouts.

Think of each part as a sequence of drawing commands in a turtle:

  • D for "draw"
  • R to "turn right"
  • L to "turn left"
  • T for a "turn".

:

D-L-D-R-D-T-D-R-D
D-L-D-R-D-R-D
D-L-D-T-D-L-D-T-D-L-D

, , , , .

+ , , , "" . , + , "" .

+2

, , , . , 3 Γ— 3:

puzzle pieces represented as combinations of quadrant arcs

, , 6 Γ— 6. 8- , , , (, "" Y B / B Y B Y / Y B, ):

         Y Y B B Y Y
         Y Y B B Y Y    Diamond:  Moustache:   Snake:
         B B Y Y B B
         B B Y Y B B      Y B          Y         Y Y
         Y Y B B Y Y      B Y          B       B
         Y Y B B Y Y                 Y

, . , "" "" , -:

same pieces represented as blocks

, .

+4

.

, , : Dancing Links ( PostScript... ). , , .

Pentomino ( , ):

Scott's Pentomino Problem

, .

, 72 : 12 60 .

(1) , , a 1 , ; 1568 .

, , X ( ).

, .

, .

Welded Tetrasticks Problem by Donald Knuth

+1

Consider using graph ; although flight paths are used in this example, it is still useful that each position (node ​​on the graph) can have several nodes connected, which is what this question describes in this post. Checking whether the game panel will be full will be just a matter of ensuring that each position (node ​​on the graph) on the board is connected to all other positions (node ​​on the graph). Each part of the board can cover several positions on the board and, thus, connect to these nodes on the chart.

0
source

Source: https://habr.com/ru/post/1598115/


All Articles