Back to lab

What is Geography?

Geography is a two-player game played on a graph. A token starts on some vertex. On your turn, you move the token along an available edge. In Edge Geography, the traversed edge is deleted. If it is your turn and there is no legal edge to take, you lose.

A played game of Undirected Edge Geography

This playground focuses on Edge Geography, the version studied in my first research paper. Both Directed Edge Geography and Undirected Edge Geography are PSPACE-complete in general, so one should not expect an efficient solver for arbitrary large graphs.

A polynomial space algorithm for Edge Geography

The solver is deliberately naive. It recursively evaluates positions by minimax:

The state is essentially:

current vertex + set of remaining edges

So the brute-force search has exponential dependence on the number of edges. Up to polynomial factors, this is about O(2m)O(2^m), where m=E(G)m = |E(G)|. For a simple undirected graph, m(n2)m \leq \binom{n}{2}, so in terms of vertices this is bounded by roughly O(2n2)O(2^{n^2}). The recursion depth of this algorithm is O(E)O(|E|) which is polynomial in the input size so Undirected Edge Geography, Directed Edge GeographyPSPACE\text{Undirected Edge Geography}, \ \text{Directed Edge Geography} \in \text{PSPACE}.

sabcd

Vertex mode: left-click empty space to add a vertex, left-click a vertex to choose the start, drag vertices to move them, and right-click a vertex to remove it. Edge mode: left-click two vertices to add or toggle an edge; right-click an edge to remove it.

Directed Edge Geography is PSPACE-complete

Since we have membership in PSPACE for Directed Edge Geography we must show hardness for the class to get completeness. This is done by constructing a polynomial time reduction from a known PSPACE-complete problem. The canonical PSPACE-complete problem is Quantified Boolean Formula (QBF), which is defined as follows:

A quantified Boolean formula is a Boolean formula in which every variable is bound by a quantifier. Formally, an instance consists of a formula

Φ=Q1x1  Q2x2    Qnxn  φ(x1,,xn), \Phi = Q_1 x_1 \; Q_2 x_2 \; \cdots \; Q_n x_n \; \varphi(x_1,\ldots,x_n),

where each Qi{,}Q_i \in \{\exists,\forall\}, each xix_i is a Boolean variable, and φ\varphi is a propositional Boolean formula over the variables x1,,xnx_1,\ldots,x_n, for example a formula in conjunctive normal form, as is the usual convention.

The truth value of Φ\Phi is defined recursively as follows. If there are no quantifiers, then Φ\Phi is true exactly when the propositional formula φ\varphi evaluates to true under the current assignment. Otherwise,

xΨ(x) \exists x \, \Psi(x)

is true if and only if at least one of Ψ(true)\Psi(\text{true}) or Ψ(false)\Psi(\text{false}) is true, while

xΨ(x) \forall x \, \Psi(x)

is true if and only if both Ψ(true)\Psi(\text{true}) and Ψ(false)\Psi(\text{false}) are true.

The decision problem QBF is:

QBF={Φ:Φ is a true fully quantified Boolean formula}. \text{QBF} = \{\Phi : \Phi \text{ is a true fully quantified Boolean formula}\}.

The reduction works by turning choices of truth values into choices of graph moves. After the variables have been chosen, the graph enters a clause-checking phase. A satisfied literal gives an escape route; an unsatisfied clause traps the player.

Rigorously proving that this works and that the reduction can be constructed in polynomial time gives PSPACE-hardness of the problem.

Directed Edge Geography reduction

QBF → directed Edge Geography

The formula creates a directed graph. Variable choices consume edges, Player 2 challenges a clause, and Player 1 must point back to an already-consumed assignment branch.

Winning position
:
(x ∨ y ∨ ¬z)(¬x ∨ z)(¬y ∨ z)
TFTFTFxy¬z¬xz¬yzspad∃xx=Tx=Fjx∀yy=Ty=Fjy∃zz=Tz=FjzcheckC1xy¬zC2¬xzC3¬yz

Step 1 / 18 · P1 to move

Start

Player 1 starts at the beginning of the generated directed Edge Geography instance.

Undirected Edge Geography is PSPACE-complete

Now that we know that Directed Edge Geography is PSPACE-complete we can replace any directed instance with an undirected instance by using a small clever gadget which simulates a directed edge such that Player 1 wins the directed instance if and only if they win the undirected instance. For details on how this is done see Fraenkel, Scheinerman, and Ullman’s 1993 paper on Undirected Edge Geography [FSU93]. Since replacing each edge can be done in polynomial time we have that Undirected Edge Geography is PSPACE-hard and thus complete.

[FSU93] A. S. Fraenkel, E. R. Scheinerman, and D. Ullman, “Undirected edge geography,” Theoretical Computer Science 112(2):371–381, 1993. DOI: 10.1016/0304-3975(93)90026-P.