Poor Tetris players and polyomino generation - Laboratoire I3S

1 downloads 0 Views 624KB Size Report
Jun 3, 2016 - Bad Tetris and bad players. Pieces: any bar of length ≤ k. (bad Tetris). Area: fix s ∈ N. (bad player). -Rules: No cancelling. (bad Tetris). 5 ...
From Tetris to polyominoes generation

June 3rd, 2016



GASCOM 2016



La Marana, Bastia, France.

Authors

Enrico Formenti

Paolo Massazza

Laboratoire I3S Université Nice Sophia Antipolis

Università dell’Insubria Varese, Italy.

2

Tetris All variants of tetrominos fall one-by-one from top to bottom.

3

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

4

Classic Tetris

Cancelling rule

4

Classic Tetris

Gravity rule

4

Classic Tetris

4

Bad Tetris and bad players Pieces:

any bar of length ≤ k

5

(bad Tetris)

Bad Tetris and bad players Pieces:

any bar of length ≤ k

(bad Tetris)

Area:

fix s ∈ N

(bad player)

5

Bad Tetris and bad players Pieces:

any bar of length ≤ k

(bad Tetris)

Area:

fix s ∈ N

(bad player)

-Rules:

No cancelling

(bad Tetris)

5

Bad Tetris and bad players Pieces:

any bar of length ≤ k

(bad Tetris)

Area:

fix s ∈ N

(bad player)

-Rules:

No cancelling

(bad Tetris)

+Rules:

New pieces and old ones have to be 4-connected

(bad player)

5

Bad Tetris and bad players Pieces:

any bar of length ≤ k

(bad Tetris)

Area:

fix s ∈ N

(bad player)

-Rules:

No cancelling

(bad Tetris)

+Rules:

New pieces and old ones have to be 4-connected

(bad player)

-Rules:

No more left and right walls

(bad Tetris)

5

Bad Tetris (and bad player)

6

Bad Tetris (and bad player)

6

Bad Tetris (and bad player)

6

Bad Tetris (and bad player)

6

Bad Tetris (and bad player)

6

Bad Tetris (and bad player)

6

Bad Tetris (and bad player)

6

Bad Tetris (and bad player)

6

Bad Tetris (and bad player)

6

Bad Tetris (and bad player)

6

Polyominoes Polyomino Any finite 4-connected subset of Z2

7

Polyominoes Polyomino Any finite 4-connected subset of Z2

Polyominoes Polyomino Any finite 4-connected subset of Z2

8

Polyominoes: history and motivations Introduction: Golomb (1954)

Polyominoes are widely studied in many fields: ▶

Enumerative combinatorics



Bijective combinatorics



Two dimensional language theory



Tilings



Discrete tomography

9

Polyominoes: the open questions Exhaustive generation Can polyominoes of a given area n be efficiently generated?

Enumeration How many polyominoes of a given area n are there?

Closed formula Is there a closed formula for the number of polyominoes of a given area n?

10

Exhaustive generation: known results & CATs

2011 Parallel polyominoes [Mantaci, Massazza] 2012 L-convex polyominoes [Massazza] 2014 Z-convex polyominoes [Castiglione, Massazza] 2015 Convex-polyominoes [Massazza] 2015 k-convex polyominoes [Brocchi, Castiglione, Massazza] 2016 Prefix-closed polyominoes [this talk]

11

Polyomino representation Polyomino Ordered sequence of columns.

Column Sequence of integers {α1 , x1 , α2 , x2 , ... , αk , xk } st. α1 xi αi

= = =

vertical displacement wrt previous column segment length hole length (i > 1)

12

Some notation

Given P = {C1 , C2 , ... , Ci , ... Ck } with { } C1 = {α1 , x1 , α2 , x2 , ... , αk , xk }, C2 = α1′ , x′1 , α2′ , x′2 , ... , αl′ , x′l , ... Pi = Ci (i-th column of P) P≤i = {C1 , ... , Ci } Ci □Ci−1 iff any segment of Ci is edge adjacent to some segment of Ci−1

13

Comparing columns C = {α1 , x1 , α2 , x2 , ... , αk , xk } C′ = {α1′ , x′1 , α2′ , x′2 , ... , αl′ , x′l } C ≤ C′ if one of the following holds 1.

∑k


α1′ and α1 = α1′ but ∃e s.t.

3.1 xi = x′i and αi = αi′ for 1 < i < e 3.2 xe > x′e if e is even 3.3 αe < αe′ if e is odd

14

Comparing polyominoes

P = {c1 , c2 , ... , ci , ... ck } { } P′ = c′1 , c′2 , ... , c′i , ... c′l

P ≤ P′ iff ∃i s.t. ci < c′i and ch = c′h for h < i.

15

Prefix-closed polyominoes Prefix-closed polyomino P = {c1 , c2 , ... , ci , ... ck } is prefix-closed iff for all i ∈ {1, ... , k} , P≤i is a polyomino.

Prefix-closed polyominoes Prefix-closed polyomino P = {c1 , c2 , ... , ci , ... ck } is prefix-closed iff for all i ∈ {1, ... , k} , P≤i is a polyomino.

Prefix-closed

Non Prefix-closed

16

Bad Tetris + bad player = Prefix-closed polyominoes

17

Bad Tetris + bad player = Prefix-closed polyominoes

17

Bad Tetris + bad player = Prefix-closed polyominoes

17

The result

Theorem There exists a CAT algorithm for the exhaustive generation of PCPol(n) which uses O(n) space.

18

Generating columns: split move

Split(a, b, j) j

a

a b′

b

19

Generating columns: shift move

j Shift(a, b, j)

a

a b′

b

20

Generating columns: the grand ancestor Grand ancestor C = {α1 , x1 , α2 , x2 , ... , αk , xk } C′ = {α1′ , x′1 , α2′ , x′2 , ... , αl′ , x′l } G(C′ , C) = column which is 1. the smallest □-compat. with C 2. identical to C′ up to j = max {M(C′ )} 3. admits a move at j 4. has same area as C′

21

Generating columns: the grand ancestor 1 Shift

2 3 4 5

Shift

6 7 8

Split

9

Split

10 11 12 13 a

a G

b

M(b) = {2, 6, 8, 9} 22

Generating columns: the dynamical system C(a, r) = set of all columns of area r and □-compatible with a j

b′ → b if b′ = Split(a, b, j) or b′ = Shift(a, b, j)

{ fa,r (b) =

j

b′ ∃b′ , GA(b, a) → b′ , j = max M(b) (α1 − h(a) + 1, r) otherwise

23

Generating columns: the dynamical system (cont.) Lemma Fix an integer r and a column a = (α1 , x1 , α2 , x2 , ... , αk , xk ) then for all b, d ∈ C(a, r) it holds: 1. fa,r (b) □ a 2. b < d implies fa,r (b) < fa,r (d); 3. fna,r (b) < fn+1 a,r (b) for b ̸= (α1 − h(a) + 1, r); 4.



n n∈N fa,r ((r

− 1, r)) = C(a, r). 24

Generating PCPol(n): the algorithm

Procedure PCPolGen(n) for r := 1 to n − 1 do 3: P1 := (0, r); ColGen(2, n − r); 4: end for 5: P := (0, n); Output(P); 1:

2:

25

Generating PCPol(n): the algorithm (columns) 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:

Procedure ColGen(i, r) for d := 1 to r do InitColumn(i); {i.e. Pi := ((d), d − 1)} Init(S, i); {init stack} if d < r then ColGen(i + 1, r − d); else Output(P); endif while not IsEmpty(S) do j:=GrAn(i, S); {restore the grand ancestor} Move(j, S); {execute a move at j and update S} if d < r then ColGen(i + 1, r − d); else Output(P); endif end while end for

26

Generating PCPol(n): the algorithm (columns)

27

Generating PCPol(n): the algorithm (columns)

w

x, y, z

27

Generating PCPol(n): the algorithm (columns)

x, y, z

w

length

27

Generating PCPol(n): the algorithm (columns)

x, y, z

w

length

position of lowest cell # of cells below length of segment

27

Generating PCPol(n): the algorithm (columns)

w

ptr to smallest compat. segment of prev. column

x, y, z

ptr to largest compat. segment of prev. column

27

Generating PCPol(n): the algorithm (columns)

w

ptr to smallest compat. segment of prev. column

x, y, z

ptr to largest compat. segment of prev. column

27

Generating PCPol(n): an example b a

1

1, 5, 2

3

3, 2, 8

3

2, 0, 13

0

3, 6, 3

1

2, 4, 6

1

1, 3, 8

28

1

3, 0, 12

Conclusions and perspectives



CAT algorithm for PCPol(n)

29

Conclusions and perspectives



CAT algorithm for PCPol(n)

29

⇐ Done

Conclusions and perspectives



CAT algorithm for PCPol(n)



Closed formula for |PCPol(n)|

29

⇐ Done

Conclusions and perspectives



CAT algorithm for PCPol(n)



Closed formula for |PCPol(n)|

29

⇐ Done To do!

Conclusions and perspectives

⇐ Done



CAT algorithm for PCPol(n)



Closed formula for |PCPol(n)|



Extension to k-PCPol(n) (k ∈ N fixed)

29

To do!

Conclusions and perspectives

⇐ Done



CAT algorithm for PCPol(n)



Closed formula for |PCPol(n)|



Extension to k-PCPol(n) (k ∈ N fixed)

29

To do! ⇐ Done (?)

Conclusions and perspectives

⇐ Done



CAT algorithm for PCPol(n)



Closed formula for |PCPol(n)|



Extension to k-PCPol(n) (k ∈ N fixed)



Closed formula for |k-PCPol(n)|

29

To do! ⇐ Done (?)

Conclusions and perspectives

⇐ Done



CAT algorithm for PCPol(n)



Closed formula for |PCPol(n)|



Extension to k-PCPol(n) (k ∈ N fixed)



Closed formula for |k-PCPol(n)|

29

To do! ⇐ Done (?) To do!!

Conclusions and perspectives

⇐ Done



CAT algorithm for PCPol(n)



Closed formula for |PCPol(n)|



Extension to k-PCPol(n) (k ∈ N fixed)



Closed formula for |k-PCPol(n)|



Extension to Pol(n)

29

To do! ⇐ Done (?) To do!!

Conclusions and perspectives

⇐ Done



CAT algorithm for PCPol(n)



Closed formula for |PCPol(n)|



Extension to k-PCPol(n) (k ∈ N fixed)



Closed formula for |k-PCPol(n)|



Extension to Pol(n)

To do!!!

29

To do! ⇐ Done (?) To do!!

Thank you.