slithering the link - carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...slithering the...

150
Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth Carleton College Department of Computer Science March 12, 2016

Upload: others

Post on 30-Sep-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Slithering the Link

David Anderson, Dan Hamalainen, Edward Kwiatkowski,Valerie Lambert, Sam Spaeth

Carleton College Department of Computer Science

March 12, 2016

Page 2: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Roadmap

What is a Slitherlink Puzzle?

How to Define a Slitherlink Puzzle

How to Solve a Slitherlink Puzzle

How to Make a Slitherlink Puzzle

Page 3: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

What is Slitherlink?

Logic puzzle developed by NikoliPlayed on:

I a rectangular lattice of dots, creating ”cells”

I with some cells containing numbers

Page 4: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

What is Slitherlink?

Objective of the game is to create a single loop throughout thepuzzle where:

I the final solution is acontinuous line thatdoes not cross itself

I each numbered cellcorresponds to thenumber of solutionlines around it

I the puzzle should haveONLY ONE uniquesolution

Page 5: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 6: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Conceptis Puzzles Slitherlink Techniques

Page 7: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Conceptis Puzzles Slitherlink Techniques

Page 8: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Conceptis Puzzles Slitherlink Techniques

Page 9: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Conceptis Puzzles Slitherlink Techniques

Page 10: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Conceptis Puzzles Slitherlink Techniques

Page 11: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 12: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Solving a Slitherlink puzzle is an NP-complete problem, as well asdetermining if there are multiple solutions.

On the NP-completeness of the Slither Link Puzzle Takayuki YATO

Page 13: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Puzzle Representation

Components of a puzzle:I the grid

I linesI numbers

I rules and contradictions

I contours

I what it means to be solved

Page 14: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

The Grid

M by N grid has 3 2D arrays:

I M by N 2D array for numbers; values 0 to 3 or empty

I M + 1 by N 2D array for horizontal lines; values line, x, orempty

I M by N + 1 2D array for vertical lines; values line, x, or empty

A rule-based approach to the puzzle of Slither Link. StefanHerting.

Page 15: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth
Page 16: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Rules and Contradictions

Each rule has:

I dimensions

I prerequisites

I consequences

Each contradiction has:

I dimensions

I prerequisities

Page 17: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Examples of Rules

Page 18: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Static Rules

Static rules are rules that do not contain lines or x’s in theirprerequisites. We identified 3 static rules.

Page 19: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Rule and Contradiction in action

We chose to cover rules that are at most 3 by 3 in dimension, andcontradictions that are at most 2 by 2 in dimension.

Page 20: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Contours

I Use 2D array to keep track of contour endpoints.

I Update endpoints as we add lines.

I Keep track of the number of open and closed contours as weadd lines.

Table 1: Contour Endpoint Array

3,1 0,1

1,2 0,2 1,3

2,2

numClosed = 0numOpen = 3

Page 21: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

How Can We Tell Our Grid is Solved?

I Every number in thegrid is satisfied

I There is exactly oneclosed loop, and noopen loops.

Page 22: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

How Can We Tell Our Grid is Solved?

I Every number in thegrid is satisfied

I There is exactly oneclosed loop, and noopen loops.

Page 23: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Applying Rules

I for every position in the grid...

I for every defined rule...I for every orientation...

Do the prerequisites in the rule match where we’re looking at onthe grid?

I If so, add consequences to the grid.

Page 24: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth
Page 25: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth
Page 26: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth
Page 27: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth
Page 28: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth
Page 29: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth
Page 30: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Guessing

Method:

1. Find a particular open position

2. Guess that position is a Line

2.1 Run deterministic rules2.2 If there’s a contradiction, we know the position is an X

3. Guess that position is an X

3.1 Run deterministic rules3.2 If there’s a contradiction, we know the position is a Line

4. If neither results in a contradiction, take the intersection ofthe two resulting grids

Page 31: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Guessing

Method:

1. Find a particular open position

2. Guess that position is a Line

2.1 Run deterministic rules2.2 If there’s a contradiction, we know the position is an X

3. Guess that position is an X

3.1 Run deterministic rules3.2 If there’s a contradiction, we know the position is a Line

4. If neither results in a contradiction, take the intersection ofthe two resulting grids

Page 32: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Guessing

Method:

1. Find a particular open position

2. Guess that position is a Line

2.1 Run deterministic rules2.2 If there’s a contradiction, we know the position is an X

3. Guess that position is an X

3.1 Run deterministic rules3.2 If there’s a contradiction, we know the position is a Line

4. If neither results in a contradiction, take the intersection ofthe two resulting grids

Page 33: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Guessing

Method:

1. Find a particular open position

2. Guess that position is a Line

2.1 Run deterministic rules

2.2 If there’s a contradiction, we know the position is an X

3. Guess that position is an X

3.1 Run deterministic rules3.2 If there’s a contradiction, we know the position is a Line

4. If neither results in a contradiction, take the intersection ofthe two resulting grids

Page 34: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Guessing

Method:

1. Find a particular open position

2. Guess that position is a Line

2.1 Run deterministic rules2.2 If there’s a contradiction, we know the position is an X

3. Guess that position is an X

3.1 Run deterministic rules3.2 If there’s a contradiction, we know the position is a Line

4. If neither results in a contradiction, take the intersection ofthe two resulting grids

Page 35: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Guessing

Method:

1. Find a particular open position

2. Guess that position is a Line

2.1 Run deterministic rules2.2 If there’s a contradiction, we know the position is an X

3. Guess that position is an X

3.1 Run deterministic rules3.2 If there’s a contradiction, we know the position is a Line

4. If neither results in a contradiction, take the intersection ofthe two resulting grids

Page 36: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Guessing

Method:

1. Find a particular open position

2. Guess that position is a Line

2.1 Run deterministic rules2.2 If there’s a contradiction, we know the position is an X

3. Guess that position is an X

3.1 Run deterministic rules

3.2 If there’s a contradiction, we know the position is a Line

4. If neither results in a contradiction, take the intersection ofthe two resulting grids

Page 37: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Guessing

Method:

1. Find a particular open position

2. Guess that position is a Line

2.1 Run deterministic rules2.2 If there’s a contradiction, we know the position is an X

3. Guess that position is an X

3.1 Run deterministic rules3.2 If there’s a contradiction, we know the position is a Line

4. If neither results in a contradiction, take the intersection ofthe two resulting grids

Page 38: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Guessing

Method:

1. Find a particular open position

2. Guess that position is a Line

2.1 Run deterministic rules2.2 If there’s a contradiction, we know the position is an X

3. Guess that position is an X

3.1 Run deterministic rules3.2 If there’s a contradiction, we know the position is a Line

4. If neither results in a contradiction, take the intersection ofthe two resulting grids

Page 39: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth
Page 40: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth
Page 41: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth
Page 42: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth
Page 43: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Recursive Guessing

If single guesses don’t result in anything, we can nest our guesses.New information from nested guesses propagates out to thecanonical grid.

We call n nested guesses a ”depth n guess”.

Page 44: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Recursive Guessing

If single guesses don’t result in anything, we can nest our guesses.New information from nested guesses propagates out to thecanonical grid.

We call n nested guesses a ”depth n guess”.

Page 45: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Example of a depth 2 guess

Grid

Page 46: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Example of a depth 2 guess

Grid

A

Page 47: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Example of a depth 2 guess

Grid

A

Line X

Page 48: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Example of a depth 2 guess

Grid

A

Line

B

Line X

X

Page 49: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Example of a depth 2 guess

Grid

A

Line

B

Line X

X

C

Line X

Page 50: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Example of a depth 2 guess

Grid

A

Line

B

Line

contradiction

X

X

C

Line X

Page 51: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Example of a depth 2 guess

Grid

A

Line

B

Line

contradiction

X

valid

X

C

Line X

Page 52: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Example of a depth 2 guess

Grid

A

Line

B

X

valid

X

C

Line X

Page 53: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Example of a depth 2 guess

Grid

A

Line

B

X

valid

X

C

Line

contradiction

X

Page 54: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Example of a depth 2 guess

Grid

A

Line

B

X

valid

X

C

Line

contradiction

X

contradiction

Page 55: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Example of a depth 2 guess

Grid

A

Line

B

X

valid

X

contradiction

Page 56: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Example of a depth 2 guess

Grid

A

Line

B

X

Page 57: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Repeated guessing algorithm

I If at any point new information is found, restart algorithm

I Run deterministic rules

I Run every possible guess (depth 1 guessing)

I Run every possible guess, and within each guess, make allpossible guesses (depth 2 guessing)

I · · ·

Page 58: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Repeated guessing algorithm

I If at any point new information is found, restart algorithm

I Run deterministic rules

I Run every possible guess (depth 1 guessing)

I Run every possible guess, and within each guess, make allpossible guesses (depth 2 guessing)

I · · ·

Page 59: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Repeated guessing algorithm

I If at any point new information is found, restart algorithm

I Run deterministic rules

I Run every possible guess (depth 1 guessing)

I Run every possible guess, and within each guess, make allpossible guesses (depth 2 guessing)

I · · ·

Page 60: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Repeated guessing algorithm

I If at any point new information is found, restart algorithm

I Run deterministic rules

I Run every possible guess (depth 1 guessing)

I Run every possible guess, and within each guess, make allpossible guesses (depth 2 guessing)

I · · ·

Page 61: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Repeated guessing algorithm

I If at any point new information is found, restart algorithm

I Run deterministic rules

I Run every possible guess (depth 1 guessing)

I Run every possible guess, and within each guess, make allpossible guesses (depth 2 guessing)

I · · ·

Page 62: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 63: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 64: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 65: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 66: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 67: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 68: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 69: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 70: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 71: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 72: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 73: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 74: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 75: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 76: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 77: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 78: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 79: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 80: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 81: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 82: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 83: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 84: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Solving a Slitherlink Puzzle

Page 85: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Checking for Multiple Solutions

For every guess we made to get to the solution:

I Go back to the state of the grid before the guess was made,and solve the corresponding grid with the opposite guess atthat same spot:

I If the opposite guess eventually leads to a contradiction, weknow that the original guess has to be true (given all previousguesses). Continue to check other guesses.

I If the opposite guess eventually leads to one or more solutions,then we know that this grid has more than one solution.

If the opposite of every guess we had to make leads to acontradiction, then we know that the original solution we found isthe only one.

Page 86: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Checking for Multiple Solutions

For every guess we made to get to the solution:I Go back to the state of the grid before the guess was made,

and solve the corresponding grid with the opposite guess atthat same spot:

I If the opposite guess eventually leads to a contradiction, weknow that the original guess has to be true (given all previousguesses). Continue to check other guesses.

I If the opposite guess eventually leads to one or more solutions,then we know that this grid has more than one solution.

If the opposite of every guess we had to make leads to acontradiction, then we know that the original solution we found isthe only one.

Page 87: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Checking for Multiple Solutions

For every guess we made to get to the solution:I Go back to the state of the grid before the guess was made,

and solve the corresponding grid with the opposite guess atthat same spot:

I If the opposite guess eventually leads to a contradiction, weknow that the original guess has to be true (given all previousguesses). Continue to check other guesses.

I If the opposite guess eventually leads to one or more solutions,then we know that this grid has more than one solution.

If the opposite of every guess we had to make leads to acontradiction, then we know that the original solution we found isthe only one.

Page 88: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Checking for Multiple Solutions

For every guess we made to get to the solution:I Go back to the state of the grid before the guess was made,

and solve the corresponding grid with the opposite guess atthat same spot:

I If the opposite guess eventually leads to a contradiction, weknow that the original guess has to be true (given all previousguesses). Continue to check other guesses.

I If the opposite guess eventually leads to one or more solutions,then we know that this grid has more than one solution.

If the opposite of every guess we had to make leads to acontradiction, then we know that the original solution we found isthe only one.

Page 89: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Checking for Multiple Solutions

For every guess we made to get to the solution:I Go back to the state of the grid before the guess was made,

and solve the corresponding grid with the opposite guess atthat same spot:

I If the opposite guess eventually leads to a contradiction, weknow that the original guess has to be true (given all previousguesses). Continue to check other guesses.

I If the opposite guess eventually leads to one or more solutions,then we know that this grid has more than one solution.

If the opposite of every guess we had to make leads to acontradiction, then we know that the original solution we found isthe only one.

Page 90: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Checking for Multiple Solutions

For every guess we made to get to the solution:I Go back to the state of the grid before the guess was made,

and solve the corresponding grid with the opposite guess atthat same spot:

I If the opposite guess eventually leads to a contradiction, weknow that the original guess has to be true (given all previousguesses). Continue to check other guesses.

I If the opposite guess eventually leads to one or more solutions,then we know that this grid has more than one solution.

If the opposite of every guess we had to make leads to acontradiction, then we know that the original solution we found isthe only one.

Page 91: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Checking for Multiple Solutions

Page 92: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Checking for Multiple Solutions

Page 93: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Checking for Multiple Solutions

Page 94: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Checking for Multiple Solutions

Page 95: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Time Complexity

Important details:

I For each depth, O(mn) new guesses, each taking O(mn) timeto instantiate

I Guessing at the max depth is by far the most important factorin runtime

I We can maximize this by never filling anything in at lowerdepths

Page 96: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Time Complexity

Important details:

I For each depth, O(mn) new guesses, each taking O(mn) timeto instantiate

I Guessing at the max depth is by far the most important factorin runtime

I We can maximize this by never filling anything in at lowerdepths

Page 97: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Time Complexity

Important details:

I For each depth, O(mn) new guesses, each taking O(mn) timeto instantiate

I Guessing at the max depth is by far the most important factorin runtime

I We can maximize this by never filling anything in at lowerdepths

Page 98: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Time Complexity

Important details:

I For each depth, O(mn) new guesses, each taking O(mn) timeto instantiate

I Guessing at the max depth is by far the most important factorin runtime

I We can maximize this by never filling anything in at lowerdepths

Page 99: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Time Complexity

Overall runtime O((mn)d) with d bounded above by O(mn)

Table 2: Empty grid completion time

Size Max Depth Time (sec)3x3 0 0.0011113x3 1 0.0337433x3 2 1.199983x3 3 57.20043x3 4 2587.52

Page 100: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Empirical Results: Typical Puzzles

Table 3: Solve Times

Size Max Depth Solve Time10x10 1 0.048542 seconds10x10 1 0.385348 seconds10x10 2 1.77571 seconds10x10 2 3.23716 seconds10x10 3 150.824 seconds*30x25 1 1.95466 seconds30x25 1 2.38471 seconds30x25 1 4.4892 seconds40x30 1 1.97524 seconds40x30 3 66.268 seconds*

*These puzzles were determined to have multiple solutionsPuzzles taken from nikoli .com, kakuro − online.com, andpuzzle − loop.com.

Page 101: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Make a Slitherlink Puzzle

Overview

1. Make a loop

2. Fill grid with numbers

3. Remove some numbers

Page 102: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop

Start with an empty m × n grid, a simple rule, and three lists:

1. available

2. expandable

3. unexpandable

Start with every location in the grid in available but none inunexpandable and expandable. Then, add one random location toexpandable and remove it from available.

Page 103: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop

Start with an empty m × n grid, a simple rule, and three lists:

1. available

2. expandable

3. unexpandable

Start with every location in the grid in available but none inunexpandable and expandable. Then, add one random location toexpandable and remove it from available.

Page 104: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Bad Stuff

Rule: When expanding from a location, cur , in expandable to anadjacent location in available , make sure that adding pos toexpandable doesn’t cause any bad stuff

Opposite: Opposite kitty-corners:

If opposite or either of the opposite kitty -corners are inexpandable, then do not add pos to the loop.

Page 105: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop cont.

1. Choose a location, cur in expandable at random

2. Look at neighbors to see if and where the loop can expandfrom cur .

2.1 If a neighbor is in available and it wasn’t a valid neighbor,remove it from available

2.2 If there are no valid neighbors, add cur to unexpandable andremove it from expandable

2.3 Otherwise, randomly choose an valid neighbor to add to addto expandable and take out of available

3. repeat until there are no locations in expandable

Page 106: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop cont.

1. Choose a location, cur in expandable at random

2. Look at neighbors to see if and where the loop can expandfrom cur .

2.1 If a neighbor is in available and it wasn’t a valid neighbor,remove it from available

2.2 If there are no valid neighbors, add cur to unexpandable andremove it from expandable

2.3 Otherwise, randomly choose an valid neighbor to add to addto expandable and take out of available

3. repeat until there are no locations in expandable

Page 107: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop cont.

1. Choose a location, cur in expandable at random

2. Look at neighbors to see if and where the loop can expandfrom cur .

2.1 If a neighbor is in available and it wasn’t a valid neighbor,remove it from available

2.2 If there are no valid neighbors, add cur to unexpandable andremove it from expandable

2.3 Otherwise, randomly choose an valid neighbor to add to addto expandable and take out of available

3. repeat until there are no locations in expandable

Page 108: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop cont.

1. Choose a location, cur in expandable at random

2. Look at neighbors to see if and where the loop can expandfrom cur .

2.1 If a neighbor is in available and it wasn’t a valid neighbor,remove it from available

2.2 If there are no valid neighbors, add cur to unexpandable andremove it from expandable

2.3 Otherwise, randomly choose an valid neighbor to add to addto expandable and take out of available

3. repeat until there are no locations in expandable

Page 109: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop cont.

1. Choose a location, cur in expandable at random

2. Look at neighbors to see if and where the loop can expandfrom cur .

2.1 If a neighbor is in available and it wasn’t a valid neighbor,remove it from available

2.2 If there are no valid neighbors, add cur to unexpandable andremove it from expandable

2.3 Otherwise, randomly choose an valid neighbor to add to addto expandable and take out of available

3. repeat until there are no locations in expandable

Page 110: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop cont.

1. Choose a location, cur in expandable at random

2. Look at neighbors to see if and where the loop can expandfrom cur .

2.1 If a neighbor is in available and it wasn’t a valid neighbor,remove it from available

2.2 If there are no valid neighbors, add cur to unexpandable andremove it from expandable

2.3 Otherwise, randomly choose an valid neighbor to add to addto expandable and take out of available

3. repeat until there are no locations in expandable

Page 111: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 112: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 113: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 114: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 115: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 116: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 117: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 118: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 119: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 120: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 121: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 122: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 123: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Making a Loop Example

Page 124: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Filling with Numbers

Surprise surprise, this is actually really easy

(sum the differences in the neighboring locations)

Page 125: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers

To make puzzles interesting, we want to remove numbersWe want to do so until we have reached a certain countMust retain one unique solution

Page 126: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers

The Process:

1. Pick a number from a set of eligible numbers

2. Add this number to a stack of ineligible numbers

3. Check if eliminating would make the puzzle unsolvable

3.1 If solvable, remove the number from both the grid and set ofeligible numbers

3.2 If unsolvable, only remove the number from the set of eligiblenumbers

4. Repeat until set of eligible numbers is empty

Page 127: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers

The Process:

1. Pick a number from a set of eligible numbers

2. Add this number to a stack of ineligible numbers

3. Check if eliminating would make the puzzle unsolvable

3.1 If solvable, remove the number from both the grid and set ofeligible numbers

3.2 If unsolvable, only remove the number from the set of eligiblenumbers

4. Repeat until set of eligible numbers is empty

Page 128: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers

The Process:

1. Pick a number from a set of eligible numbers

2. Add this number to a stack of ineligible numbers

3. Check if eliminating would make the puzzle unsolvable

3.1 If solvable, remove the number from both the grid and set ofeligible numbers

3.2 If unsolvable, only remove the number from the set of eligiblenumbers

4. Repeat until set of eligible numbers is empty

Page 129: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers

The Process:

1. Pick a number from a set of eligible numbers

2. Add this number to a stack of ineligible numbers

3. Check if eliminating would make the puzzle unsolvable

3.1 If solvable, remove the number from both the grid and set ofeligible numbers

3.2 If unsolvable, only remove the number from the set of eligiblenumbers

4. Repeat until set of eligible numbers is empty

Page 130: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers

The Process:

1. Pick a number from a set of eligible numbers

2. Add this number to a stack of ineligible numbers

3. Check if eliminating would make the puzzle unsolvable

3.1 If solvable, remove the number from both the grid and set ofeligible numbers

3.2 If unsolvable, only remove the number from the set of eligiblenumbers

4. Repeat until set of eligible numbers is empty

Page 131: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers

The Process:

1. Pick a number from a set of eligible numbers

2. Add this number to a stack of ineligible numbers

3. Check if eliminating would make the puzzle unsolvable

3.1 If solvable, remove the number from both the grid and set ofeligible numbers

3.2 If unsolvable, only remove the number from the set of eligiblenumbers

4. Repeat until set of eligible numbers is empty

Page 132: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers

The Process:

1. Pick a number from a set of eligible numbers

2. Add this number to a stack of ineligible numbers

3. Check if eliminating would make the puzzle unsolvable

3.1 If solvable, remove the number from both the grid and set ofeligible numbers

3.2 If unsolvable, only remove the number from the set of eligiblenumbers

4. Repeat until set of eligible numbers is empty

Page 133: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers cont.

Once set of eligible numbers is empty:

1. Pop numbers off ineligible stack

2. Place each back into the set of eligible numbers

3. Do so until most recently eliminated number is found

4. Keep eliminated in the ineligible stack, but place back intogrid

Repeat removing numbers until desired count is reached

Page 134: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers cont.

Once set of eligible numbers is empty:

1. Pop numbers off ineligible stack

2. Place each back into the set of eligible numbers

3. Do so until most recently eliminated number is found

4. Keep eliminated in the ineligible stack, but place back intogrid

Repeat removing numbers until desired count is reached

Page 135: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers cont.

Once set of eligible numbers is empty:

1. Pop numbers off ineligible stack

2. Place each back into the set of eligible numbers

3. Do so until most recently eliminated number is found

4. Keep eliminated in the ineligible stack, but place back intogrid

Repeat removing numbers until desired count is reached

Page 136: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers cont.

Once set of eligible numbers is empty:

1. Pop numbers off ineligible stack

2. Place each back into the set of eligible numbers

3. Do so until most recently eliminated number is found

4. Keep eliminated in the ineligible stack, but place back intogrid

Repeat removing numbers until desired count is reached

Page 137: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers cont.

Once set of eligible numbers is empty:

1. Pop numbers off ineligible stack

2. Place each back into the set of eligible numbers

3. Do so until most recently eliminated number is found

4. Keep eliminated in the ineligible stack, but place back intogrid

Repeat removing numbers until desired count is reached

Page 138: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers cont.

Once set of eligible numbers is empty:

1. Pop numbers off ineligible stack

2. Place each back into the set of eligible numbers

3. Do so until most recently eliminated number is found

4. Keep eliminated in the ineligible stack, but place back intogrid

Repeat removing numbers until desired count is reached

Page 139: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Removing Numbers cont.

It’s too hard!

Improvements

1. Data

2. Rule set

3. Balancing

Page 140: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth
Page 141: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Ruleset Limitation

As a result, we created two subsets of rules:

I easy: the rules with a greater than 5% occurrence rate

I hard: the rules with a greater than 1% occurrence rate

Page 142: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

An ‘Easy’ Puzzle

Page 143: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

A Quick Attempt at the ‘Easy’ Puzzle

Page 144: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Balancing the Numbers

Page 145: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

A Balanced Easy Puzzle

Page 146: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

A Quick Attempt at the ‘Easy’ Puzzle

Page 147: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Time Complexity

Important details

I The Solver is run on the order of mn times.

I Each time the solver is run, it happends with a maximumdepth of one guess which has on the order of O((mn)2) time.

I Therefore, the generator run in the order of O((mn)3) time.

Page 148: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

References

Conceptis Puzzles Slitherlink TechniquesOn the NP-completeness of the Slither Link Puzzle Takayuki YATOFinding All Solutions and Instances of Numberlink and Slitherlinkby ZDDs. Ryo Yoshinaka, Toshiki Saitoh, Jun Kawahara, KojiTsuruma, Hiroaki Iwashita and Shin-ichi Minato.

A rule-based approach to the puzzle of Slither Link. StefanHerting.

Puzzles and Games: A Mathematical Modeling Approach. TonyHurlimann, 2015

Solving logical puzzles using mathematical models. KVIS Susanti,S Lukas.

Page 149: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Thank you

Page 150: Slithering the Link - Carletoncs.carleton.edu/cs_comps/1516/slither/final-results/...Slithering the Link David Anderson, Dan Hamalainen, Edward Kwiatkowski, Valerie Lambert, Sam Spaeth

Questions?