Commit 78414eb4 authored by Adrien Simon's avatar Adrien Simon
Browse files

deleted testing files

parent ec135348
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% HELLTAKER IN ASP %%%
%%% version: 0.1 %%%
%%% authors : Adrien Simon %%%
%%% Julie Pichon %%%
%%% Léo Peron %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% clingo -c maxstep=10 -n0 helltaker.lp
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% INITIALISATION %%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
step(0..maxstep-1).
cell(0, 0..7).
cell(1, 0..6).
cell(2, 0..1).
cell(3, 1..4).
cell(4, 1..5).
cell(5, 4..5).
%%%%%% ACTIONS %%%%%%
action(
right;
left;
up;
down;
push_right;
push_left;
push_down;
push_up;
monster_right;
monster_left;
monster_down;
monster_up;
nop).
%%%%%% INIT %%%%%%
% player
init(at(5, 5)).
% boxes
init(box(1, 1)).
init(box(1, 4)).
init(box(0, 1)).
init(box(0, 3)).
% monsters
init(monster(3, 2)).
init(monster(4, 3)).
init(monster(3, 4)).
fluent(F, 0) :- init(F).
%%%%%%%%%%%%%%%%%%%%
%%%%%%% BUTS %%%%%%%
%%%%%%%%%%%%%%%%%%%%
goal(at(0, 5)).
achieved(T) :- fluent(F, T), goal(F).
:- not achieved(_).
:- achieved(T), T > maxstep.
:- achieved(T), do(Act, T), Act != nop.
:- do(nop, T), not achieved(T).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% ACTIONS DEPLACEMENT %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{ do(Act, T): action(Act) } = 1 :- step(T).
%%%%%% ACTION LEFT %%%%%%
% préconditions
:- do(left, T),
fluent(at(X, Y), T),
not cell(X, Y - 1).
:- do(left, T),
fluent(at(X, Y), T),
fluent(box(X, Y - 1), T).
:- do(left, T),
fluent(at(X, Y), T),
fluent(monster(X, Y - 1), T).
% effets
fluent(at(X, Y - 1), T + 1) :-
do(left, T),
fluent(at(X, Y), T),
cell(X, Y - 1),
not fluent(box(X, Y - 1), T),
not fluent(monster(X, Y - 1), T).
removed(at(X, Y), T) :-
do(left, T),
fluent(at(X, Y), T).
%%%%%% ACTION RIGHT %%%%%%
% préconditions
:- do(right, T),
fluent(at(X, Y), T),
not cell(X, Y + 1).
:- do(right, T),
fluent(at(X, Y), T),
fluent(box(X, Y + 1), T).
:- do(right, T),
fluent(at(X, Y), T),
fluent(monster(X, Y + 1), T).
% effets
fluent(at(X, Y + 1), T + 1) :-
do(right, T),
fluent(at(X, Y), T),
cell(X, Y + 1),
not fluent(box(X, Y + 1), T),
not fluent(monster(X, Y + 1), T).
removed(at(X, Y), T) :-
do(right, T),
fluent(at(X, Y), T).
%%%%%% ACTION UP %%%%%%
% préconditions
:- do(up, T),
fluent(at(X, Y), T),
not cell(X + 1, Y).
:- do(up, T),
fluent(at(X, Y), T),
fluent(box(X + 1, Y), T).
:- do(up, T),
fluent(at(X, Y), T),
fluent(monster(X + 1, Y), T).
% effets
fluent(at(X + 1, Y), T + 1) :-
do(up, T),
fluent(at(X, Y), T),
cell(X + 1, Y),
not fluent(box(X + 1, Y), T),
not fluent(monster(X + 1, Y), T).
removed(at(X, Y), T) :-
do(up, T),
fluent(at(X, Y), T).
%%%%%% ACTION DOWN %%%%%%
% préconditions
:- do(down, T),
fluent(at(X, Y), T),
not cell(X - 1, Y).
:- do(up, T),
fluent(at(X, Y), T),
fluent(box(X - 1, Y), T).
:- do(up, T),
fluent(at(X, Y), T),
fluent(monster(X - 1, Y), T).
% effets
fluent(at(X - 1, Y), T + 1) :-
do(down, T),
fluent(at(X, Y), T),
cell(X - 1, Y),
not fluent(box(X - 1, Y), T),
not fluent(monster(X - 1, Y), T).
removed(at(X, Y), T) :-
do(down, T),
fluent(at(X, Y), T).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% ACTIONS PUSH BOXES %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% ACTION PUSH LEFT %%%%%%
% préconditions
:- do(push_left, T),
fluent(at(X, Y), T),
not fluent(box(X, Y - 1), T).
:- do(push_left, T),
fluent(at(X, Y), T),
not cell(X, Y - 2).
:- do(push_left, T),
fluent(at(X, Y), T),
fluent(box(X, Y - 2), T).
% effets
fluent(box(X, Y - 2), T + 1) :-
do(push_left, T),
fluent(at(X, Y), T).
removed(box(X, Y - 1), T) :-
do(push_left, T),
fluent(at(X, Y), T).
%%%%%% ACTION PUSH RIGHT %%%%%%
% préconditions
:- do(push_right, T),
fluent(at(X, Y), T),
not fluent(box(X, Y + 1), T).
:- do(push_right, T),
fluent(at(X, Y), T),
not cell(X, Y + 2).
:- do(push_right, T),
fluent(at(X, Y), T),
fluent(box(X, Y + 2), T).
% effets
fluent(box(X, Y + 2), T + 1) :-
do(push_right, T),
fluent(at(X, Y), T).
removed(box(X, Y + 1), T) :-
do(push_right, T),
fluent(at(X, Y), T).
%%%%%% ACTION PUSH up %%%%%%
% préconditions
:- do(push_up, T),
fluent(at(X, Y), T),
not fluent(box(X + 1, Y), T).
:- do(push_up, T),
fluent(at(X, Y), T),
not cell(X + 2, Y).
:- do(push_up, T),
fluent(at(X, Y), T),
fluent(box(X + 2, Y), T).
% effets
fluent(box(X + 2, Y), T + 1) :-
do(push_up, T),
fluent(at(X, Y), T).
removed(box(X + 1, Y), T) :-
do(push_up, T),
fluent(at(X, Y), T).
%%%%%% ACTION PUSH DOWN %%%%%%
% préconditions
:- do(push_down, T),
fluent(at(X, Y), T),
not fluent(box(X - 1, Y), T).
:- do(push_down, T),
fluent(at(X, Y), T),
not cell(X - 2, Y).
:- do(push_down, T),
fluent(at(X, Y), T),
fluent(box(X - 2, Y), T).
% effets
fluent(box(X - 2, Y), T + 1) :-
do(push_down, T),
fluent(at(X, Y), T).
removed(box(X - 1, Y), T) :-
do(push_down, T),
fluent(at(X, Y), T).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% ACTIONS PUSH MONSTERS %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% ACTION MONSTER LEFT %%%%%%
% préconditions
:- do(monster_left, T),
fluent(at(X, Y), T),
not fluent(monster(X, Y - 1), T).
:- do(monster_left, T),
fluent(at(X, Y), T),
fluent(monster(X, Y - 2), T).
% effets
fluent(monster(X, Y - 2), T + 1) :-
do(monster_left, T),
cell(X, Y - 2),
fluent(at(X, Y), T).
removed(monster(X, Y - 1), T) :-
do(monster_left, T),
fluent(at(X, Y), T).
removed(monster(X, Y - 1), T) :-
fluent(box(X, Y - 2), T),
do(monster_left, T),
fluent(at(X, Y), T).
removed(monster(X, Y - 1), T) :-
not cell(X, Y - 2),
do(monster_left, T),
fluent(at(X, Y), T).
%%%%%% ACTION MONSTER RIGHT %%%%%%
% préconditions
:- do(monster_right, T),
fluent(at(X, Y), T),
not fluent(monster(X, Y + 1), T).
:- do(monster_right, T),
fluent(at(X, Y), T),
fluent(monster(X, Y + 2), T).
% effets
fluent(monster(X, Y + 2), T + 1) :-
do(monster_right, T),
cell(X, Y + 2),
fluent(at(X, Y), T).
removed(monster(X, Y + 1), T) :-
do(monster_right, T),
fluent(at(X, Y), T).
removed(monster(X, Y + 1), T) :-
fluent(box(X, Y + 2), T),
do(monster_right, T),
fluent(at(X, Y), T).
removed(monster(X, Y + 1), T) :-
not cell(X, Y + 2),
do(monster_right, T),
fluent(at(X, Y), T).
%%%%%% ACTION MONSTER up %%%%%%
% préconditions
:- do(monster_up, T),
fluent(at(X, Y), T),
not fluent(monster(X + 1, Y), T).
:- do(monster_up, T),
fluent(at(X, Y), T),
fluent(monster(X + 2, Y), T).
% effets
fluent(monster(X + 2, Y), T + 1) :-
do(monster_up, T),
cell(X + 2, Y),
fluent(at(X, Y), T).
removed(monster(X + 1, Y), T) :-
do(monster_up, T),
fluent(at(X, Y), T).
removed(monster(X + 1, Y), T) :-
fluent(box(X + 2, Y), T),
do(monster_up, T),
fluent(at(X, Y), T).
removed(monster(X + 1, Y), T) :-
not cell(X + 2, Y),
do(monster_up, T),
fluent(at(X, Y), T).
%%%%%% ACTION MONSTER DOWN %%%%%%
% préconditions
:- do(monster_down, T),
fluent(at(X, Y), T),
not fluent(monster(X - 1, Y), T).
:- do(monster_down, T),
fluent(at(X, Y), T),
fluent(monster(X - 2, Y), T).
% effets
fluent(monster(X - 2, Y), T + 1) :-
do(monster_down, T),
cell(X - 2, Y),
fluent(at(X, Y), T).
removed(monster(X - 1, Y), T) :-
do(monster_down, T),
fluent(at(X, Y), T).
removed(monster(X - 1, Y), T) :-
fluent(box(X - 2, Y), T),
do(monster_down, T),
fluent(at(X, Y), T).
removed(monster(X - 1, Y), T) :-
not cell(X - 2, Y),
do(monster_down, T),
fluent(at(X, Y), T).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% FRAME PROBLEM %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
fluent(F, T + 1) :-
fluent(F, T),
T + 1 < maxstep,
not removed(F, T).
fluent(F, T + 1) :-
fluent(F, T),
achieved(T),
T + 1 <= maxstep.
#show do/2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% HELLTAKER IN ASP %%%
%%% version: 0.1 %%%
%%% authors : Adrien Simon %%%
%%% Julie Pichon %%%
%%% Léo Peron %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% clingo -c maxstep=10 -n0 helltaker.lp
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% INITIALISATION %%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
step(0..maxstep-1).
cell(0, 4..6).
cell(1, 0..1). cell(1, 4..6).
cell(2, 0..1). cell(2, 4..6).
cell(3, 0..1). cell(3, 4..6).
cell(4, 1). cell(4, 3..6).
cell(5, 1..4).
%%%%%% ACTIONS %%%%%%
action(
right;
left;
up;
down;
push_right;
push_left;
push_down;
push_up;
monster_right;
monster_left;
monster_down;
monster_up;
on_spike;
nop).
%%%%%% INIT %%%%%%
% player
init(at(1, 0)).
% boxes
init(box(3, 4)).
init(box(3, 5)).
init(box(3, 6)).
% monsters
init(monster(4, 1)).
init(monster(1, 5)).
init(monster(0, 6)).
% spikes
spikes(3, 1).
spikes(4, 3).
spikes(4, 4).
spikes(3, 4).
spikes(3, 5).
spikes(2, 5).
% demoness
demoness(0, 4).
fluent(F, 0) :- init(F).
%%%%%%%%%%%%%%%%%%%%
%%%%%%% BUTS %%%%%%%
%%%%%%%%%%%%%%%%%%%%
goal(at(0, 5)).
goal(at(1, 4)).
achieved(T) :- fluent(F, T), goal(F).
:- not achieved(_).
:- achieved(T), T > maxstep.
:- achieved(T), do(Act, T), Act != nop.
:- do(nop, T), not achieved(T).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% ACTIONS DEPLACEMENT %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{ do(Act, T): action(Act) } = 1 :- step(T).
%%%%%% ACTION LEFT %%%%%%
% préconditions
:- do(left, T),
fluent(at(X, Y), T),
not cell(X, Y - 1).
:- do(left, T),
fluent(at(X, Y), T),
fluent(box(X, Y - 1), T).
:- do(left, T),
fluent(at(X, Y), T),
fluent(monster(X, Y - 1), T).
% effets
fluent(at(X, Y - 1), T + 1) :-
do(left, T),
fluent(at(X, Y), T),
cell(X, Y - 1),
not fluent(box(X, Y - 1), T),
not fluent(monster(X, Y - 1), T).
fluent(at(X, Y - 1), T + 1) :-
do(left, T),
fluent(at(X, Y), T),
cell(X, Y - 1),
spikes(X, Y - 1),
not fluent(box(X, Y - 1), T),
not fluent(monster(X, Y - 1), T).
removed(at(X, Y), T) :-
do(left, T),
fluent(at(X, Y), T).
%%%%%% ACTION RIGHT %%%%%%
% préconditions
:- do(right, T),
fluent(at(X, Y), T),
not cell(X, Y + 1).
:- do(right, T),
fluent(at(X, Y), T),
fluent(box(X, Y + 1), T).
:- do(right, T),
fluent(at(X, Y), T),
fluent(monster(X, Y + 1), T).
% effets
fluent(at(X, Y + 1), T + 1) :-
do(right, T),
fluent(at(X, Y), T),
cell(X, Y + 1),
not fluent(box(X, Y + 1), T),
not fluent(monster(X, Y + 1), T).
fluent(at(X, Y + 1), T + 1) :-
do(right, T),
fluent(at(X, Y), T),
cell(X, Y + 1),
spikes(X, Y + 1),
not fluent(box(X, Y + 1), T),
not fluent(monster(X, Y + 1), T).
removed(at(X, Y), T) :-
do(right, T),
fluent(at(X, Y), T).
%%%%%% ACTION UP %%%%%%
% préconditions
:- do(up, T),
fluent(at(X, Y), T),
not cell(X + 1, Y).
:- do(up, T),
fluent(at(X, Y), T),
fluent(box(X + 1, Y), T).
:- do(up, T),
fluent(at(X, Y), T),
fluent(monster(X + 1, Y), T).
% effets
fluent(at(X + 1, Y), T + 1) :-
do(up, T),
fluent(at(X, Y), T),
cell(X + 1, Y),
not fluent(box(X + 1, Y), T),
not fluent(monster(X + 1, Y), T).
fluent(at(X + 1, Y), T + 1) :-
do(up, T),
fluent(at(X, Y), T),
cell(X + 1, Y),
spikes(X + 1, Y),
not fluent(box(X + 1, Y), T),
not fluent(monster(X + 1, Y), T).
removed(at(X, Y), T) :-
do(up, T),
fluent(at(X, Y), T).
%%%%%% ACTION DOWN %%%%%%
% préconditions
:- do(down, T),
fluent(at(X, Y), T),
not cell(X - 1, Y).
:- do(up, T),
fluent(at(X, Y), T),
fluent(box(X - 1, Y), T).
:- do(up, T),
fluent(at(X, Y), T),
fluent(monster(X - 1, Y), T).
% effets
fluent(at(X - 1, Y), T + 1) :-
do(down, T),
fluent(at(X, Y), T),
cell(X - 1, Y),
not fluent(box(X - 1, Y), T),
not fluent(monster(X - 1, Y), T).
fluent(at(X - 1, Y), T + 1) :-
do(down, T),
fluent(at(X, Y), T),
cell(X - 1, Y),
spikes(X - 1, Y),
not fluent(box(X - 1, Y), T),
not fluent(monster(X - 1, Y), T).
removed(at(X, Y), T) :-
do(down, T),
fluent(at(X, Y), T).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% ACTIONS PUSH BOXES %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% ACTION PUSH LEFT %%%%%%
% préconditions
:- do(push_left, T),
fluent(at(X, Y), T),
not fluent(box(X, Y - 1), T).
:- do(push_left, T),
fluent(at(X, Y), T),
not cell(X, Y - 2).
:- do(push_left, T),
fluent(at(X, Y), T),