Labs 4 – ASP
Procedural Content Generation for Computer Games
Vojtěch Černý
cerny@gamedev.cuni.cz
Prerequisites
Installing clingo
How does clingo work?
ASP program
(AnsProlog)
Ground program
(propositional
logic rules)
Answer set(s)
Grounding
gringo
Solving
clasp
clingo = gringo + clasp
Grounding
edge(0,1). edge(1,2). edge(2,0).
color(r; g; b).
:- edge(X, Y), colored(X, C), colored(Y, C).
:- colored(1, r), colored(0, r).
:- colored(1, g), colored(0, g).
:- colored(1, b), colored(0, b).
:- colored(2, r), colored(1, r).
:- colored(2, g), colored(1, g).
:- colored(2, b), colored(1, b).
:- colored(0, r), colored(2, r).
:- colored(0, g), colored(2, g).
:- colored(0, b), colored(2, b).
Solving
First clingo run
Start with the answer-set-programming repo
clingo 0_sprinklers.lp
clingo 0_sprinklers.lp 0
gets you all solutions possible (0 = all)
Python runner
Preparation tasks
Start with the answer-set-programming repo
Read through the numbered examples (best in order) and make sure you understand them.
Try doing these „simple“ tasks:
The Task
Make a murder mystery text-based game!
Start with the ASP + Python example
This version is playable, but quite bland (try playing it yourself).
Extensions (mainly for inspiration)
Task details
Criteria
Points
Submission details
Questions / Problems
Q & A
Vojtěch Černý
cerny@gamedev.cuni.cz
Meta-programming in ASP (optional topic)
How to guarantee unique solution
If a counter-example exists, generating it will be a smaller (in inclusion) than if bot is derived and the whole counter-example space is filled.
And in that case, solutions with bot won’t be answer sets.
How to guarantee minimal assignment
Contains solution (X, Y, N) for each ClueX, ClueY, where the clue at ClueX, ClueY is changed. Has to be derived for each ClueX, ClueY.