Sei sulla pagina 1di 14

A GAME OF COPS AND ROBBERS

Adam Scarchilli
Outline
Questions ask anytime!
Rules of the game
Challenge
Approach
Why Big Data?
Algorithm
Pseudo-Code
Bonus: Strategies
Live Demonstration!
Rules of the Game
Pursuit game cop wants to catch the robber and
robber wants to avoid the cop
To play, make a graph with vertices and edges
Cop chooses a vertex
Robber chooses a vertex
Cop starts
Alternate turns moving along connected vertices
Continue until:
They are on the same vertex (cop catches robber)
The cop gives up and the robber wins
Challenge
Solve the game:
Suppose the cop and robber plays perfectly
On a given graph, two outcomes:
Cop win cop will win with perfect play
Robber win robber will win with perfect play

You give me a graph, I can tell you who will win

But how to do in general?
Approach
Professor Arend Hintzes idea: metagraph!

metagraph every vertex is a game state

game state answers 3 questions
Whos turn to move (cop or robber)
Where is the cop (what vertex)
Where is the robber (what vertex)

If a move goes from one game state to another, they
are connected by a directional edge in a digraph
For this simple graph
Heres the metagraph!!!
Why Big Data?
Suppose a graph has n vertices
The metagraph will have 2*n^2 vertices
Possible metagraph edges: (2n^2 choose 2)
# of possible graphs: 2^(# of edges) = 2^(2n^2
choose 2)

Example! n = 10 vertices.
Metagraph has 200 vertices
Possible metagraph edges: 19900
# of possible graphs: 2^19900 -> about a 5000 digit
number
Algorithm
The secret work backwards!
Start from positions where the robber is caught
Get rid of those positions until you have a new graph
where the robber no longer has the option to make
those mistakes
If the robber lands on the cop, get rid of the end node
If the cop lands on the robber, also get rid of the second
to last node (robber cannot make a bad move / lose the
next turn)
Repeat on the new graph. Maybe stripping end
vertices creates new end vertices. And so on.

Algorithm
After iteratively removing end states, two cases:
Final Graph is empty cop win
Final Graph is non-empty robber win

Why? Graph is empty all bad robber moves are
eliminated, he has no safe moves left

Graph is non-empty robber simply stays on this
final graph
cop can never escape these cycles to find a winning path
(otherwise removing end points would cut into the cycles
via the escape path)
Pseudo-Code
While End nodes exist:
For all end nodes:
If the robber moved last:
Delete the end node and all connections to it
If the cop moved last:
Delete the end node and all connections to it
For all cop moves that goes to the end node:
Delete the cop moves and all connections
If final graph is empty:
cop win
Else:
robber win
Bonus: Strategies
Can you show the best strategy?
Cop quickest ways to win
Robber list of moves to always evade capture

Cop win graphs:
Track how you removed vertices in the metagraph
Following this sequence is the fastest way to win

Robber win graphs:
Final metagraph is not empty
Just stay on that metagraph!

Live Demonstration!

Potrebbero piacerti anche