Extra Credit:
In this homework, we’re going back to the beginning! Primarily, you will be converting the Action Castle game from HW1 into Sabre’s syntax by hand.
In this first part, you will be creating a planning problem following the syntax of Sabre and then running your problem through the Sabre planner.
Sabre tries to find a story based on a set of limits. It has three different types of limits:
-atl
flag)-ctl
flag)-el
flag)Whether a limit is reached is calculated by looking at the utility of the overall problem (utility()
) or the utility of a particular character’s perspective (e.g., utility(Princess)
).
The above definitions and more information can be found in the report A Collection of Benchmark Problems for the Sabre Narrative Planner. You can also find a partial example of a problem that I made in the Extra Credit.
The skeleton of a problem has been provided to you in this notebook. Again, you can open this notebook in Colab, Deepnote, or VSCode. You might notice that there are some variations from Action Castle. I’ve simplified a few things: the rose is just in the garden (no rosebush) and there is no “Death” room or path from the tree.
To write a problem for Sabre, do the following:
location(Player) == GardenPath
if you’re trying to make sure your walk action works.
Also, the deeper the goal is, the longer the planner is going to take to run.null
in Sabre is ?
utility()
as the following block:
utility():
if(royal(Player)) 1 else 0;
run it and collect the plan you get (for context this utility takes my solution about 3 minutes to plan through), and then replace it with
utility():
if(inv(Crown) == Player) 1 else 0;
and run that and collect that plan.
walk()
action to allow all characters to walk around, not just the Player.
You can find the instructions here: https://code.visualstudio.com/docs/copilot/setup
But it essentially is:
And you should be ready to go!
We’ll now use GitHub Copilot to write a Sabre problem for a wikiHow article. The goal for this is to start from something that describes proceedures and actions and is written in natural language, and then have Copilot translate it into the description language used for automated planning.
Here are a few wikiHow articles that I thought might be interesting since they had some elements that could make for interesting interactive fiction. It’s fine to pick your own article. You shouldn’t translate the whole article, just a few steps, so you can pick out the parts that you think are most relevant/easiest to create a schema from.
Survival Stories
Detectives
Dystopian Futures
As an example, I’ll pick the How to Survive in the Woods article, and show you how part of the schema might look. Here is step 1 from that article:
Finding Drinking Water
Search for a source of fresh water.[1] The first thing that you’ll need in order to survive in the woods is water that you can drink. Look for signs of fresh water nearby like areas of green foliage that indicate water is nearby, low-lying areas where water could be collected, and signs of wildlife like animal tracks. It could mean that a creek, stream, or pond is nearby. While finding water is important for survival, be aware some water sources will not be safe - if possible treat all drinking water before using it. [2] If there are mountains nearby, look for water collected at the foot of the cliffs.
- The presence of insects like mosquitoes and flies means that water is nearby.
- Water from heavily oxygenated water (such as from a big waterfall or rapids) typically is safer than that from a slow or still water source.
- Freshwater springs are typically safer water sources, although these can be contaminated by mineral or bacteria as well.
- Remember that all untreated water must be considered risky unless treated. Even crystal clear water can harbor diseases and be dangerous if consumed.
My Sabre problem for this might look like this:
I would declare some types that would be relevant. These are like listing variable.
type location;
type type : attribute;
type player : location;
type attribute : entity;
type water: entity;
type status;
And some entities – specific instances of the types above. These are like the characters and things in your story.
entity Bugs : player;
entity Treated : attribute;
entity Fresh : type;
entity Moving : type;
entity Salt : type;
entity Chesapeake : location;
entity Lake : location;
entity Water : water;
entity Player : player;
And properties – what types of what attributes entities might have and the relations they have with each other.
property is(location : location, attribute : attribute) : boolean;
property has_water(location : location) : boolean;
property is(location : location) : type;
property at(player : player) : location;
property from(water : water) : location;
property safe(water : water) : boolean;
property has(player : player, water : water) : boolean;
...
Then we need some starting facts – what state things are in at the beginning of the story.
at(Foot) = Lake;
at(Bugs)= Lake;
!has(Player, Water);
at(Player) = Chesapeake;
has_water(Chesapeake);
...
And actions – things that move the story along.
action get_water(player : player, water : water, location : location) {
precondition:
has_water(location) &
at(player) == location;
effect:
!safe(water) &
has(player, water);
};
...
Any potential triggers – things that should occur but don’t neccessarily have an event that starts it.
trigger know_water_source(player : player, other : player, water : water, location : location) {
precondition:
at(player) != location &
from(water) == location &
has(other, water);
effect:
believes(player, safe(water));
};
...
Finally, some utility. This is how you want the planner to weight effects.
utility(Water):
if(safe(Water))
2
elseif(is(Water,Fresh) & is(Water,Moving))
1
else
0;
...
In order to get the full 5 points, you need:
You should submit the following:
Submissions should be done on Blackboard.
Stephen G. Ware and Cory Siler, Sabre: A Narrative Planner Supporting Intention and Deep Theory of Mind.
Stephen G. Ware, Lasantha Senanayake, and Rachelyn Farrell, Causal Necessity as a Narrative Planning Step Cost Function.
Stephen G. Ware and Rachelyn Farrell, A Collection of Benchmark Problems for the Sabre Narrative Planner.