Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Adrien Simon
ia02-helltaker
Commits
bcd31eda
Commit
bcd31eda
authored
Jun 15, 2022
by
Adrien Simon
Browse files
added asp README
parent
bde0d618
Changes
2
Hide whitespace changes
Inline
Side-by-side
asp/README.md
0 → 100644
View file @
bcd31eda
# ASP SOLVER FOR HELLTAKER
Ceci est un solveur codé en ASP, automatisé sous Python avec le module clingo pour résoudre des niveaux du jeu helltaker.
### How to use
-
en console, vous avez juste à taper 'python3 main.py path_to_txt_file' pour lancer le programme
-
le programme renverra sous la forme "hbgd" un modèle valide pour le niveau
\ No newline at end of file
asp/
helltaker_plan_asp
.py
→
asp/
main
.py
View file @
bcd31eda
...
...
@@ -837,19 +837,23 @@ fluent(F, T + 1) :-
asp
=
level_specificities
+
pb
ctl
=
clingo
.
Control
([
f
"-c maxstep=
{
infos
[
'max_steps'
]
}
"
],
logger
=
log
)
ctl
=
clingo
.
Control
([
f
"-c maxstep=
{
infos
[
'max_steps'
]
}
"
],
logger
=
log
)
# ajouter '-n0' pour afficher tt les modeles
ctl
.
add
(
"base"
,
[],
asp
)
ctl
.
ground
([(
"base"
,
[])])
plan
=
[
0
]
*
infos
[
"max_steps"
]
model_count
=
0
with
ctl
.
solve
(
yield_
=
True
)
as
handle
:
for
model
in
handle
:
model_count
+=
1
for
atom
in
model
.
symbols
(
atoms
=
True
):
if
atom
.
name
==
"do"
:
plan
[
atom
.
arguments
[
1
].
number
]
=
atom
.
arguments
[
0
].
name
#print(f"Model count: {model_count}")
plan_str
=
""
for
i
in
range
(
len
(
plan
)):
if
"up"
in
plan
[
i
]:
...
...
@@ -869,12 +873,6 @@ def log(code, message):
afficher des warnings inutiles dans la console lors du solving."""
pass
def
msg
():
"""Cette fonction récupère les messages des logs et n'en fait rien."""
return
def
main
():
# récupération du nom du fichier depuis la ligne de commande
filename
=
sys
.
argv
[
1
]
...
...
@@ -883,11 +881,15 @@ def main():
infos
=
grid_from_file
(
filename
)
# calcul du plan
start
=
time
.
time
()
plan
=
planify_asp
(
infos
)
end
=
time
.
time
()
# affichage du résultat
if
check_plan
(
plan
):
# print(f"Temps d'exécution : {(end - start):.2f} secondes.")
print
(
"[OK]"
,
plan
)
# print("")
else
:
print
(
"[Err]"
,
plan
,
file
=
sys
.
stderr
)
sys
.
exit
(
2
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment