dots and boxes - graz university of technology · dots and boxes dots and boxes is played by two...

28
Oswin Aichholzer Algorithms and Games 1 Dots and Boxes Algorithms & Games WS 2019/20

Upload: others

Post on 23-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games1

Dots and Boxes

Algorithms & Games WS 2019/20

Page 2: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 i

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

Page 3: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 ii

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

3× 4 grid

Page 4: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 iii

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

Page 5: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 iv

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

A

Page 6: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 v

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

Page 7: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 vi

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

A

Page 8: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 vii

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

Page 9: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 viii

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

A

Page 10: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 ix

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

Page 11: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 x

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

A

Page 12: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 xi

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

Page 13: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 xii

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

If a player completes a unit box, he/she owns that box andmust then draw another segment (except in the last move).

B

Page 14: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 xiii

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

If a player completes a unit box, he/she owns that box andmust then draw another segment (except in the last move).

B

Page 15: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 xiv

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

If a player completes a unit box, he/she owns that box andmust then draw another segment (except in the last move).

AA

Page 16: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 xv

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

If a player completes a unit box, he/she owns that box andmust then draw another segment (except in the last move).

A

AA

Page 17: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 xvi

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

If a player completes a unit box, he/she owns that box andmust then draw another segment (except in the last move).

A

AA

Page 18: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 xvii

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

If a player completes a unit box, he/she owns that box andmust then draw another segment (except in the last move).

A

AB

Page 19: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 xviii

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

If a player completes a unit box, he/she owns that box andmust then draw another segment (except in the last move).

A

AA

Page 20: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 xix

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

If a player completes a unit box, he/she owns that box andmust then draw another segment (except in the last move).

A

A

BB

Page 21: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 xx

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

If a player completes a unit box, he/she owns that box andmust then draw another segment (except in the last move).

A

A

B

BB

Page 22: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 xxi

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

If a player completes a unit box, he/she owns that box andmust then draw another segment (except in the last move).

A

A

B

BBB

Page 23: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games2 xxii

Dots and Boxes

Dots and Boxes is played by two players (Alice and Bob)on and n×m grid.

In each turn a player connects two adjacent dots with ahorizontal or vertical unit segment.

B

If a player completes a unit box, he/she owns that box andmust then draw another segment (except in the last move).

A

A

B

BB

At the end of the game the players count their boxes. Inthe example B wins 4 : 2.

Page 24: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games3 i

Move Generator: Pseudo Code

NEXT STATES(state, player)E = Set of unused segments in stateIF E = ∅ THEN

add state to list(state, NOT player)ELSE FOR all segments s ∈ E DO

IF s closes one or two boxes in state THENlabel new boxes with playernext states(state + s, player)

ELSEadd state to list(state + s, NOT player)

Main call:E = Set of unused segments in current stateIF E 6= ∅ THEN next states(current state, current player)

ELSE No moves possibleRemark: add state to list() removes duplicates

Page 25: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games3 ii

Move Generator: Pseudo Code

NEXT STATES(state, player)E = Set of unused segments in stateIF E = ∅ THEN

add state to list(state, NOT player)ELSE FOR all segments s ∈ E DO

IF s closes one or two boxes in state THENlabel new boxes with playernext states(state + s, player)

ELSEadd state to list(state + s, NOT player)

Main call:E = Set of unused segments in current stateIF E 6= ∅ THEN next states(current state, current player)

ELSE No moves possibleRemark: add state to list() removes duplicates

Final segment closeda box, no move left(rule exception).

Page 26: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games4

Small Boards

. . .

2× 2, 4, 6, 8, 10: B (4,8,12,16,20?) 2× 3, 5, 7, 9: draw

3× 3: A (9); 3× 4: B (12); 3× 5: A (15); 3× 6: B (18?)

4× 4: B (16)

Page 27: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games5

Schedule:• Testrun 1: Tuesday 21.01.2020 14:00-16:00• Testrun 2: Thursday 23.01.2020 14:00-16:00• Competition 1: Thursday 30.01.2020 10:00-18:00• Competition 2: Friday 31.01.2020 10:00-18:00

Interviews:• By appointment with TAs, and on request of a group• January, February, first week of March.• All members of a group have to be present• Approach has to be explained• Source code has to be provided for the interview and

can be inspected

Page 28: Dots and Boxes - Graz University of Technology · Dots and Boxes Dots and Boxes is played by two players ( A lice and B ob) on and n m grid. In each turn a player connects two adjacent

Oswin Aichholzer Algorithms and Games6

Evaluation: maximum of 34% for practical part• Minimum requirement: All valid moves (and only valid

moves) for all legal positions are provided; results in theminimum of 17%

• 17-34% depending on approach and level of play