Playsession highlight: still haven’t cracked the operators or there is no way to combine the lunch with the nasty knife.
>open sack
Opening the brown sack reveals:
A clove of garlic.
A lunch.
>hide knife in lunch
I don't understand that.
>look at lunch
I see nothing special about the lunch.
>put knife in bottle
I can't reach inside.
>use knife on lunch
I don't understand that.
>use knife with lunch
I don't understand that.
>combine knife and lunch
I don't understand that.
Have repeated enough to want some helper functions now. Will draft them in this post, but I suppose next play session I suppose I’ll need to be packaging it.
# print() doesn't respect newline even with escape, but message handles newline# Also learnt, use message() for the text, but use print() for structured data zork_nodes_and_edges <-get_nodes_and_edges_raw()
*** zork nodes ***
✔ Reading from "zork-graph-data".
✔ Range ''nodes''.
# A tibble: 3 × 4
perspective_location region interactivity loot
<chr> <chr> <chr> <chr>
1 west of house forest solved: mailbox leaflet
2 north of house forest none none
3 forest forest song bird? none
*** zork edges ***
✔ Reading from "zork-graph-data".
✔ Range ''edges''.
# A tibble: 3 × 4
perspective_location perspective_to_target target_location discovered
<chr> <chr> <chr> <dttm>
1 west of house north north of house 2024-10-30 00:00:00
2 north of house east behind house 2024-10-30 00:00:00
3 behind house west kitchen 2024-10-30 00:00:00
zork graph function
Code
create_zork_graph <-function(zork_nodes_and_edges, selected_region ='all') { zork_nodes <- zork_nodes_and_edges$zork_nodes zork_edges <- zork_nodes_and_edges$zork_edgesif (selected_region !='all') { zork_nodes <- zork_nodes |> dplyr::filter(region %in%c(selected_region, 'unexplored')) } zork_base_graph <- zork_edges |> dplyr::mutate(from = perspective_location,to = target_location ) |># does order matter? dplyr::select(from, to, everything()) |> tidygraph::as_tbl_graph()# Join the nodes data frame to the nodes of the graph zork_graph <- zork_base_graph |> tidygraph::activate(nodes) |># add attributes to nodes dplyr::inner_join(zork_nodes, by =c("name"="perspective_location"))print(zork_graph)# report regions discoveredmessage('\n*** zork regions discovered (zork_ggraph selected_region) ***\n')print( zork_nodes |> dplyr::filter(!(region %in%c('unexplored', 'inaccessible'))) |> dplyr::pull(region) |>unique() )message('\n***\n')return(zork_graph)}
# A tbl_graph: 18 nodes and 51 edges
#
# A directed multigraph with 1 component
#
# Node Data: 18 × 4 (active)
name region interactivity loot
<chr> <chr> <chr> <chr>
1 west of house forest solved: mailbox leaflet
2 north of house forest none none
3 behind house forest window to house none
4 kitchen house sack water, lunch, garl…
5 living room house rug, locked door to west sword, lantern
6 cellar cellar none none
7 west of chasm cellar unknown unknown
8 gallery cellar painting none
9 studio cellar note, 69 colours none
10 north south crawlway cellar hole above, no climbing unknown
11 the troll room cellar troll none
12 maze cellar unknown unknown
13 east west passageway cellar unknown unknown
14 ravine crossing cellar none none
15 circular 8 directions cellar compass needle spins none
16 attic house none rope, knife, clay
17 inaccessible unexplored none none
18 unexplored unexplored unknown unknown
#
# Edge Data: 51 × 6
from to perspective_location perspective_to_target target_location
<int> <int> <chr> <chr> <chr>
1 1 2 west of house north north of house
2 2 3 north of house east behind house
3 3 4 behind house west kitchen
# ℹ 48 more rows
# ℹ 1 more variable: discovered <dttm>
*** zork regions discovered (zork_ggraph selected_region) ***
Today I’m impatient to get to the cellar and try out putting the nasty knife in the food I find in the sack and I should try talking to the troll.
get to the cellar
I’ll note what I haven’t explored and get to the cellar.
Code
zork_ggraph(zork_nodes_and_edges, 'forest')
# A tbl_graph: 5 nodes and 11 edges
#
# A directed acyclic multigraph with 2 components
#
# Node Data: 5 × 4 (active)
name region interactivity loot
<chr> <chr> <chr> <chr>
1 west of house forest solved: mailbox leaflet
2 north of house forest none none
3 behind house forest window to house none
4 inaccessible unexplored none none
5 unexplored unexplored unknown unknown
#
# Edge Data: 11 × 6
from to perspective_location perspective_to_target target_location
<int> <int> <chr> <chr> <chr>
1 1 2 west of house north north of house
2 2 3 north of house east behind house
3 1 5 west of house south unexplored
# ℹ 8 more rows
# ℹ 1 more variable: discovered <dttm>
*** zork regions discovered (zork_ggraph selected_region) ***
[1] "forest"
***
Using "sugiyama" as default layout
get to the troll
Make a beeline for the troll.
Code
zork_ggraph(zork_nodes_and_edges, 'cellar')
# A tbl_graph: 12 nodes and 36 edges
#
# A directed multigraph with 1 component
#
# Node Data: 12 × 4 (active)
name region interactivity loot
<chr> <chr> <chr> <chr>
1 cellar cellar none none
2 west of chasm cellar unknown unknown
3 gallery cellar painting none
4 studio cellar note, 69 colours none
5 north south crawlway cellar hole above, no climbing unknown
6 the troll room cellar troll none
7 maze cellar unknown unknown
8 east west passageway cellar unknown unknown
9 ravine crossing cellar none none
10 circular 8 directions cellar compass needle spins none
11 inaccessible unexplored none none
12 unexplored unexplored unknown unknown
#
# Edge Data: 36 × 6
from to perspective_location perspective_to_target target_location
<int> <int> <chr> <chr> <chr>
1 1 6 cellar east the troll room
2 1 2 cellar south west of chasm
3 1 11 cellar west inaccessible
# ℹ 33 more rows
# ℹ 1 more variable: discovered <dttm>
*** zork regions discovered (zork_ggraph selected_region) ***
[1] "cellar"
***
Using "stress" as default layout
overview
Code
zork_ggraph(zork_nodes_and_edges)
# A tbl_graph: 18 nodes and 51 edges
#
# A directed multigraph with 1 component
#
# Node Data: 18 × 4 (active)
name region interactivity loot
<chr> <chr> <chr> <chr>
1 west of house forest solved: mailbox leaflet
2 north of house forest none none
3 behind house forest window to house none
4 kitchen house sack water, lunch, garl…
5 living room house rug, locked door to west sword, lantern
6 cellar cellar none none
7 west of chasm cellar unknown unknown
8 gallery cellar painting none
9 studio cellar note, 69 colours none
10 north south crawlway cellar hole above, no climbing unknown
11 the troll room cellar troll none
12 maze cellar unknown unknown
13 east west passageway cellar unknown unknown
14 ravine crossing cellar none none
15 circular 8 directions cellar compass needle spins none
16 attic house none rope, knife, clay
17 inaccessible unexplored none none
18 unexplored unexplored unknown unknown
#
# Edge Data: 51 × 6
from to perspective_location perspective_to_target target_location
<int> <int> <chr> <chr> <chr>
1 1 2 west of house north north of house
2 2 3 north of house east behind house
3 3 4 behind house west kitchen
# ℹ 48 more rows
# ℹ 1 more variable: discovered <dttm>
*** zork regions discovered (zork_ggraph selected_region) ***
[1] "forest" "house" "cellar"
***
Using "stress" as default layout
lost in the maze
In this playsession, I ended up in a maze twice, so I think I’ve found a new region.
>go south
You are in a narrow east-west passageway. There is a narrow staircase
leading down at the north end of the room.
>go down
You are in a deep ravine at a crossing with an east-west crawlway.
Some stone steps are at the south of the ravine and a steep staircase
descends.
>look
You are in a deep ravine at a crossing with an east-west crawlway.
Some stone steps are at the south of the ravine and a steep staircase
descends.
>go south
You are in a narrow east-west passageway. There is a narrow staircase
leading down at the north end of the room.
>go east
You are in a circular room with passages off in eight directions.
Your compass needle spins wildly, and you cannot get your bearings.
>look
You are in a circular room with passages off in eight directions.
Your compass needle spins wildly, and you cannot get your bearings.
>go west
Unfortunately, it is impossible to tell directions in here.
You are in a maze of twisty little passages, all alike.
>go east
You are in a maze of twisty little passages, all alike.
>go north
You are in a maze of twisty little passages, all alike.
>go north
You are in a maze of twisty little passages, all alike.
>go south
You are in a maze of twisty little passages, all alike.
>go south
You are in a maze of twisty little passages, all alike.
>go south
You are in a maze of twisty little passages, all alike.
>go south
You are in a maze of twisty little passages, all alike.
>go south
You are in a maze of twisty little passages, all alike.
>go south
You are in a maze of twisty little passages, all alike.
>go south
You are in a maze of twisty little passages, all alike.
>go south
You are in a maze of twisty little passages, all alike.
>go south
You are in a maze of twisty little passages, all alike.
>go south
You are in a maze of twisty little passages, all alike.
>go east
You are in a maze of twisty little passages, all alike.
>go east
Dead end.
>go north
There is a wall there.
>go south
You are in a maze of twisty little passages, all alike.
>go east
Dead end.
>go west
There is a wall there.
>go south
You are in a maze of twisty little passages, all alike.
>go east
Dead end.
>go west
There is a wall there.
>go south
You are in a maze of twisty little passages, all alike.
>go east
Dead end.
>go west
There is a wall there.