# Encoding maze-generation_decision.gringo

Name maze-generation_decision.gringo [Root]    Puzzles (51)    Grid (17)    Maze Generation (2) Martin Gebser Martin Gebser and Roland Kaminski A Gringo encoding of Maze Generation. 2009-03-27 15:16 2009-05-07 16:15 Maze Generation col/1empty/2entrance/2exit/2row/1wall/2 col/1empty/2entrance/2exit/2row/1wall/2 No ASP Contest 09 (Martin Gebser) #hide adjacent/4. #hide grid/2. #hide maxcol/1. #hide maxrow/1. #hide border/2. #hide reach/2. :- exit(X,Y), wall(X,Y). grid(X,Y) :- col(X), row(Y). adjacent(X,Y,X,Y+1) :- grid(X,Y), row(Y+1). adjacent(X,Y,X,Y-1) :- grid(X,Y), row(Y-1). adjacent(X,Y,X+1,Y) :- grid(X,Y), col(X+1). adjacent(X,Y,X-1,Y) :- grid(X,Y), col(X-1). maxcol(X) :- col(X), not col(X+1). maxrow(Y) :- row(Y), not row(Y+1). border(1,Y) :- col(1), row(Y). border(X,1) :- col(X), row(1). border(X,Y) :- row(Y), maxcol(X). border(X,Y) :- col(X), maxrow(Y). reach(X,Y) :- entrance(X,Y), not wall(X,Y). reach(XX,YY) :- adjacent(X,Y,XX,YY), reach(X,Y), not wall(XX,YY). :- empty(X,Y), not reach(X,Y). :- wall(X,Y), wall(X+1,Y), wall(X,Y+1), wall(X+1,Y+1). :- empty(X,Y), empty(X+1,Y), empty(X,Y+1), empty(X+1,Y+1). :- wall(X,Y), empty(X+1;X-1,Y), empty(X,Y+1;Y-1), grid(X+1;X-1,Y+1;Y-1). :- wall(X,Y), wall(X+1,Y+1), not wall(X+1,Y), not wall(X,Y+1). :- wall(X+1,Y), wall(X,Y+1), not wall(X,Y), not wall(X+1,Y+1). wall(X,Y) :- border(X,Y), not entrance(X,Y), not exit(X,Y). { wall(X,Y) : grid(X,Y) : not entrance(X,Y) : not exit(X,Y) : not border(X,Y) }. empty(X,Y) :- grid(X,Y), not wall(X,Y). %* % The following is just a conjecture ... :- maxcol(M), maxrow(N), M mod 2 == 0, N mod 2 == 0, entrance(X,Y), exit(XX,YY), not adjacent(X,Y,XX,YY). :- maxcol(M), maxrow(N), M mod 2 == 0, N mod 2 == 0, entrance(X,Y), exit(XX,YY), X mod 2 == 0, X > XX. :- maxcol(M), maxrow(N), M mod 2 == 0, N mod 2 == 0, entrance(X,Y), exit(XX,YY), XX mod 2 == 0, XX > X. :- maxcol(M), maxrow(N), M mod 2 == 0, N mod 2 == 0, entrance(X,Y), exit(XX,YY), Y mod 2 == 0, Y > YY. :- maxcol(M), maxrow(N), M mod 2 == 0, N mod 2 == 0, entrance(X,Y), exit(XX,YY), YY mod 2 == 0, YY > Y. *%