Commit 881462e5 authored by Adrien Simon's avatar Adrien Simon
Browse files

fixed things

parent 8899511a
state_trap(on; off).
cell(6,3).
demoness(6,3).
goal(at(5,3)).
goal(at(6,2)).
goal(at(7,3)).
goal(at(6,4)).
cell(6,4).
cell(5,3).
cell(5,4).
init(chest(5,4)).
cell(5,5).
cell(4,0).
cell(4,1).
init(key(4,1)).
cell(4,3).
init(box(4,3)).
cell(4,4).
init(box(4,4)).
cell(4,5).
init(box(4,5)).
cell(3,0).
init(monster(3,0)).
cell(3,1).
init(box(3,1)).
cell(3,2).
cell(3,3).
init(monster(3,3)).
cell(3,4).
init(box(3,4)).
cell(3,5).
cell(2,0).
cell(2,2).
init(monster(2,2)).
cell(2,3).
cell(2,4).
cell(2,5).
init(at(2,5)).
cell(1,0).
{trap(1, 0, S, T) : state_trap(S)} = 1 :- step(T). :- trap(1, 0, S, 0), S != off.
cell(1,3).
{trap(1, 3, S, T) : state_trap(S)} = 1 :- step(T). :- trap(1, 3, S, 0), S != on.
cell(0,0).
{trap(0, 0, S, T) : state_trap(S)} = 1 :- step(T). :- trap(0, 0, S, 0), S != on.
cell(0,1).
{trap(0, 1, S, T) : state_trap(S)} = 1 :- step(T). :- trap(0, 1, S, 0), S != off.
cell(0,2).
{trap(0, 2, S, T) : state_trap(S)} = 1 :- step(T). :- trap(0, 2, S, 0), S != on.
cell(0,3).
{trap(0, 3, S, T) : state_trap(S)} = 1 :- step(T). :- trap(0, 3, S, 0), S != off.
step(0..maxstep-1).
init(has_key(0)).
state_trap(on; off).
fluent(F, 0) :- init(F).
%%%%%% ACTIONS %%%%%%
......@@ -787,4 +839,4 @@ fluent(F, T + 1) :-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#show do/2.
#show do/2.
\ No newline at end of file
......@@ -60,6 +60,9 @@ init(has_key(0)).
fluent(F, 0) :- init(F).
goal(at(6, 3)).
goal(at(5, 4)).
%%%%%% ACTIONS %%%%%%
action(
right;
......@@ -81,9 +84,6 @@ action(
%%%%%%% BUTS %%%%%%%
%%%%%%%%%%%%%%%%%%%%
goal(at(6, 3)).
goal(at(5, 4)).
achieved(T) :- fluent(F, T), goal(F).
:- not achieved(_).
......@@ -118,9 +118,9 @@ achieved(T) :- fluent(F, T), goal(F).
spikes(X, Y - 1),
not do(on_spike, T + 1).
:- do(left, T),
:- do(_, T),
fluent(at(X, Y), T),
trap(X, Y - 1, on, T),
trap(X, Y, on, T + 1),
not do(on_spike, T + 1).
% effets
......@@ -183,11 +183,6 @@ removed(at(X, Y), T) :-
spikes(X, Y + 1),
not do(on_spike, T + 1).
:- do(right, T),
fluent(at(X, Y), T),
trap(X, Y + 1, on, T),
not do(on_spike, T + 1).
% effets
fluent(at(X, Y + 1), T + 1) :-
do(right, T),
......@@ -248,10 +243,6 @@ removed(at(X, Y), T) :-
spikes(X + 1, Y),
not do(on_spike, T + 1).
:- do(up, T),
fluent(at(X, Y), T),
trap(X + 1, Y, on, T),
not do(on_spike, T + 1).
% effets
fluent(at(X + 1, Y), T + 1) :-
......@@ -314,11 +305,6 @@ removed(at(X, Y), T) :-
spikes(X - 1, Y),
not do(on_spike, T + 1).
:- do(down, T),
fluent(at(X, Y), T),
trap(X - 1, Y, on, T),
not do(on_spike, T + 1).
% effets
fluent(at(X - 1, Y), T + 1) :-
do(down, T),
......@@ -379,11 +365,6 @@ removed(at(X, Y), T) :-
spikes(X, Y),
not do(on_spike, T + 1).
:- do(push_left, T),
fluent(at(X, Y), T),
trap(X, Y, on, T),
not do(on_spike, T + 1).
% effets
fluent(box(X, Y - 2), T + 1) :-
do(push_left, T),
......@@ -432,11 +413,6 @@ removed(box(X, Y - 1), T) :-
spikes(X, Y),
not do(on_spike, T + 1).
:- do(push_right, T),
fluent(at(X, Y), T),
trap(X, Y, on, T),
not do(on_spike, T + 1).
% effets
fluent(box(X, Y + 2), T + 1) :-
do(push_right, T),
......@@ -485,11 +461,6 @@ removed(box(X, Y + 1), T) :-
spikes(X, Y),
not do(on_spike, T + 1).
:- do(push_up, T),
fluent(at(X, Y), T),
trap(X, Y, on, T),
not do(on_spike, T + 1).
% effets
fluent(box(X + 2, Y), T + 1) :-
do(push_up, T),
......@@ -538,11 +509,6 @@ removed(box(X + 1, Y), T) :-
spikes(X, Y),
not do(on_spike, T + 1).
:- do(push_down, T),
fluent(at(X, Y), T),
trap(X, Y, on, T),
not do(on_spike, T + 1).
% effets
fluent(box(X - 2, Y), T + 1) :-
do(push_down, T),
......@@ -595,16 +561,13 @@ removed(box(X - 1, Y), T) :-
spikes(X, Y),
not do(on_spike, T + 1).
:- do(monster_left, T),
fluent(at(X, Y), T),
trap(X, Y, off, T),
not do(on_spike, T + 1).
% effets
fluent(monster(X, Y - 2), T + 1) :-
do(monster_left, T),
cell(X, Y - 2),
fluent(at(X, Y), T).
fluent(at(X, Y), T),
not fluent(box(X, Y - 2), T),
not fluent(chest(X, Y - 2), T).
removed(monster(X, Y - 1), T) :-
do(monster_left, T),
......@@ -640,16 +603,13 @@ removed(monster(X, Y - 1), T) :-
spikes(X, Y),
not do(on_spike, T + 1).
:- do(monster_right, T),
fluent(at(X, Y), T),
trap(X, Y, off, T),
not do(on_spike, T + 1).
% effets
fluent(monster(X, Y + 2), T + 1) :-
do(monster_right, T),
cell(X, Y + 2),
fluent(at(X, Y), T).
fluent(at(X, Y), T),
not fluent(box(X, Y + 2), T),
not fluent(chest(X, Y + 2), T).
removed(monster(X, Y + 1), T) :-
do(monster_right, T),
......@@ -685,16 +645,13 @@ removed(monster(X, Y + 1), T) :-
spikes(X, Y),
not do(on_spike, T + 1).
:- do(monster_up, T),
fluent(at(X, Y), T),
trap(X, Y, off, T),
not do(on_spike, T + 1).
% effets
fluent(monster(X + 2, Y), T + 1) :-
do(monster_up, T),
cell(X + 2, Y),
fluent(at(X, Y), T).
fluent(at(X, Y), T),
not fluent(box(X + 2, Y), T),
not fluent(chest(X + 2, Y), T).
removed(monster(X + 1, Y), T) :-
do(monster_up, T),
......@@ -730,16 +687,13 @@ removed(monster(X + 1, Y), T) :-
spikes(X, Y),
not do(on_spike, T + 1).
:- do(monster_down, T),
fluent(at(X, Y), T),
trap(X, Y, off, T),
not do(on_spike, T + 1).
% effets
fluent(monster(X - 2, Y), T + 1) :-
do(monster_down, T),
cell(X - 2, Y),
fluent(at(X, Y), T).
fluent(at(X, Y), T),
not fluent(box(X - 2, Y), T),
not fluent(chest(X - 2, Y), T).
removed(monster(X - 1, Y), T) :-
do(monster_down, T),
......@@ -771,6 +725,11 @@ removed(monster(X - 1, Y), T) :-
not spikes(X, Y),
not trap(X, Y, off, T).
:- do(_, T),
fluent(at(X, Y), T),
trap(X, Y, on, T + 1),
not do(on_spike, T + 1).
% effets
fluent(at(X, Y), T) :-
do(on_spike, T + 1),
......@@ -787,7 +746,8 @@ fluent(at(X, Y), T) :-
:- trap(X, Y, S1, T), trap(X, Y, S2, T + 1), S1 = S2.
removed(monster(X, Y), T) :-
trap(X, Y, on, T).
trap(X, Y, on, T),
fluent(monster(X, Y), T).
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% KEY AND CHEST %%%%%%
......@@ -813,8 +773,13 @@ fluent(has_key(1), T) :-
fluent(at(X, Y), T),
fluent(key(X + 1, Y), T).
removed(key(X, Y), T) :-
fluent(at(X, Y), T).
removed(has_key(0), T) :-
fluent(has_key(1), T).
fluent(has_key(1), T),
fluent(at(X, Y), T),
fluent(key(X, Y), T).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% HELLTAKER IN ASP %%%
%%% version: 0.1 %%%
%%% authors : Adrien Simon %%%
%%% Julie Pichon %%%
%%% Léo Peron %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% clingo -c maxstep=n -n0 helltaker.lp
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% INITIALISATION %%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
step(0..maxstep-1).
cell(0, 4..5).
cell(1, 4..6).
cell(2, 1..5).
cell(3, 1). cell(3, 3..6).
cell(4, 1..4).
cell(5, 0..3).
cell(6, 1..3).
cell(7, 1..3).
%%%%%% INIT %%%%%%
% player
init(at(7, 2)).
% boxes
init(box(6, 1)).
init(box(6, 2)).
init(box(6, 3)).
init(box(4, 2)).
init(box(3, 3)).
init(box(3, 4)).
init(box(2, 3)).
init(box(1, 5)).
% monsters
init(monster(3, 1)).
init(monster(2, 5)).
% spikes
% trap
state_trap(on; off).
cell(7,1).
cell(7,2).
init(at(7,2)).
cell(7,3).
cell(6,1).
init(box(6,1)).
cell(6,2).
init(box(6,2)).
cell(6,3).
init(box(6,3)).
cell(5,0).
cell(5,1).
cell(5,2).
cell(5,3).
init(key(5,3)).
cell(4,1).
{trap(4, 1, S, T) : state_trap(S)} = 1 :- step(T). :- trap(4, 1, S, 0), S != on.
cell(4,2).
init(box(4,2)).
{trap(4, 2, S, T) : state_trap(S)} = 1 :- step(T). :- trap(4, 2, S, 0), S != on.
cell(4,3).
cell(4,4).
cell(3,1).
init(monster(3,1)).
cell(3,3).
init(box(3,3)).
cell(3,4).
init(box(3,4)).
cell(3,5).
cell(3,6).
cell(2,1).
cell(2,2).
cell(2,3).
init(box(2,3)).
cell(2,4).
cell(2,5).
init(monster(2,5)).
cell(1,4).
init(chest(1,4)).
cell(1,5).
init(box(1,5)).
cell(1,6).
cell(0,4).
cell(0,5).
demoness(0,5).
goal(at(-1,5)).
goal(at(0,4)).
goal(at(1,5)).
goal(at(0,6)).
% demoness
demoness(0, 5).
% chest & key
init(chest(1, 4)).
init(key(5, 3)).
step(0..maxstep-1).
init(has_key(0)).
state_trap(on; off).
fluent(F, 0) :- init(F).
%%%%%% ACTIONS %%%%%%
......@@ -813,8 +807,13 @@ fluent(has_key(1), T) :-
fluent(at(X, Y), T),
fluent(key(X + 1, Y), T).
removed(key(X, Y), T) :-
fluent(at(X, Y), T).
removed(has_key(0), T) :-
fluent(has_key(1), T).
fluent(has_key(1), T),
fluent(at(X, Y), T),
fluent(key(X, Y), T).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......
......@@ -12,7 +12,7 @@
%%%%%%% INITIALISATION %%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
step(0..maxstep-1).
cell(0, 0..3).
cell(1, 0). cell(1, 3).
......@@ -41,7 +41,6 @@ init(monster(2, 2)).
% spikes
% trap
state_trap(on; off).
{trap(1, 0, S, T) : state_trap(S)} = 1 :- step(T). :- trap(1, 0, S, 0), S != off.
{trap(0, 0, S, T) : state_trap(S)} = 1 :- step(T). :- trap(0, 0, S, 0), S != on.
......@@ -57,8 +56,10 @@ demoness(6, 3).
init(chest(5, 4)).
init(key(4, 1)).
init(has_key(0)).
step(0..maxstep-1).
init(has_key(0)).
state_trap(on; off).
fluent(F, 0) :- init(F).
%%%%%% ACTIONS %%%%%%
......
......@@ -12,7 +12,7 @@
%%%%%%% INITIALISATION %%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
step(0..maxstep-1).
cell(0, 1..7).
cell(1, 0..8).
......@@ -37,7 +37,6 @@ init(box(4, 3)). init(box(4, 5)).
% spikes
% trap
state_trap(on; off).
% demoness
demoness(6, 3).
......@@ -45,9 +44,12 @@ demoness(6, 3).
% chest & key
init(chest(4, 4)).
init(key(2, 8)).
goal(at(5, 4)).
init(has_key(0)).
step(0..maxstep-1).
state_trap(on; off).
init(has_key(0)).
fluent(F, 0) :- init(F).
%%%%%% ACTIONS %%%%%%
......@@ -71,8 +73,6 @@ action(
%%%%%%% BUTS %%%%%%%
%%%%%%%%%%%%%%%%%%%%
goal(at(5, 4)).
achieved(T) :- fluent(F, T), goal(F).
:- not achieved(_).
......
Level 2 (merci à E. Porte)
24
####
# ##
#M#SS #
S##OOB#
## S #
H ## M #
####D M#
########
\ No newline at end of file
#########
## ###
##M#SS #
# S##OOB#
# ## S #
#H ## M #
#####D M#
#########
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment