Puzzle Level Generation with Answer Set Programming

https://github.com/DanLindeman/swappy-gen

The Problem

  • Manual Generation is...
    • Cumbersome
    • Error prone

Prolog

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin urna odio, aliquam vulputate faucibus id, elementum lobortis felis. Mauris urna dolor, placerat ac sagittis quis.

ASP

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin urna odio, aliquam vulputate faucibus id, elementum lobortis felis. Mauris urna dolor, placerat ac sagittis quis.

"An elegant weapon, from a more civilized age..."

Solution

  • ASP Prolog: clingo
  •  
% Have correct player and goal count
:- { sprite(T, goal, C) } != number_of_players.
:- { sprite(T, player, C) } != number_of_players.

% You can walk on adjacent tiles
{ touch(T2, C) : adj(T1,T2) } :- touch(T1, C).

% You can never walk through a wall
:- sprite(T, wall, none), touch(T, C).

% You can't walk through a differently colored door
:- sprite(T, door, C1), touch(T, C2), C1 != C2.

% Collinear-X swapping rule
{ touch((X2, Y2), C1) } :-
    touch((X1, Y1), C1),
    touch((X2, Y2), C2),
    X1=X2,
    Y1!=Y2,
    C1!=C2.

"An elegant weapon, from a more civilized age..."

Results

  • "Starting Point" levels
  • New life to 5th Generation Programming languages
  • Rules laid bare
    • Elegant
    • Simple
    • Beautiful

deck

By dlindema

deck

Migrated to a different presentation: Deprecated

  • 326