Tuesday, March 25, 2025

Acuitas Diary #82 (March 2025)

This month I've made a long-awaited return to the Game Engine (see the demo from June 2023) with ambitious plans to improve Acuitas' reasoning and agency. Specifically, I want to introduce some experimental learning abilities. And I'm hoping to do that by getting him to play Allergic Cliffs.

What is that? There's a reason I wrote a game showcase on Logical Journey of the Zoombinis earlier this month. "Allergic Cliffs" is the first puzzle in every journey. It's a hidden information game, with some underlying ties to Set Theory.

A screenshot of the Logical Journey of the Zoombinis puzzle "Allergic Cliffs," showing a whimsical painting of a chasm with two plank bridges across it. There are a pair of stone faces in the cliffs on the right side of the chasm. A number of zoombinis - little round blue creatures with various types of hair, eyes, and locomotion devices - are clustered on the grassy lawns on both sides of the chasm.
An example of the original Allergic Cliffs. It appears the righthand/foreground cliff is allergic to "two wide eyes" in this scenario. Screenshot by jdl on the Wonderland Forum.

In brief, there's a chasm with two bridges spanning it, and you want to get all your zoombinis across. The complicating factor is the presence of two stone faces in the cliffs on the chasm's far side. These beings are quite literally allergic to zoombinis with (or without) certain attributes. Putting a zoombini on the bridge that passes over the wrong cliff will cause the face to sneeze violently, shaking the bridge and tossing the hapless zoombini back to the near side. After enough mistakes, both bridges fall, and you have to leave behind any zoombinis who didn't make it over. Here's a video of someone playing Allergic Cliffs.

Since you're only allowed a limited number of failures, you can't brute-force the puzzle by setting every zoombini on both bridges. You need to be trying to learn which zoombini features make the cliffs sneeze. And to be sure of learning this before the bridges fall, you have to perform targeted experiments. Why did this zoombini get across? Why did that one get sneezed at?

Acuitas can't play the original Zoombinis game, obviously; it's far too visuo-spatial. He needs a text version. The author of the Storeroom Blog has kindly written up a full breakdown of the Allergic Cliffs game mechanics. I will only be expecting Acuitas to play on the easiest difficulty level, for the time being. So every round will require choosing a zoombini feature that one cliff will be allergic to and the other cliff will be immune to (i.e. allergic to all zoombinis who don't have the feature). This rule is kept secret, but must be used to inform descriptions of what the cliffs do when zoombinis are placed on the bridges. Each scenario also includes the group of sixteen zoombinis, with known characteristics, whom the player is trying to get across the chasm.

In my first demo of the Game Engine, I behaved as a "game master"; I initiated the game during a conversation with Acuitas, then kept interacting with him to describe the setting and the results of his in-character actions. But I don't want to do that in this case. Do you know how much effort it takes to fully describe a group of sixteen zoombinis? Lots, actually. I am not going to type that up and paste one line at a time into Acuitas' text box every time we play! This game needs to be automated.

So I wrote an independent, interactive Python program that implements a "text adventure" version of Allergic Cliffs. When launched, the game program generates sixteen zoombinis with randomized names and attributes, and a set of rules for the cliffs. Then it outputs a text description of the scene, the player character and their goal, and all the zoombinis. Acuitas, using the "Play" action, can run this script and connect the IO to his Game Engine. The script includes a very dumb parser that scans Acuitas' speech outputs for signs that he's moving a zoombini, and replies "you can't do that" to anything else. If Acuitas puts a zoombini on a bridge, the Allergic Cliffs script tells him the results. It also keeps track of the game's state; if it reaches either the win condition (all zoombinis on the far side) or the loss condition (fallen bridges), it will tell Acuitas "Game Over" and terminate.

This is something of a milestone, since it's the first time Acuitas has been able to launch and use a subordinate software tool. It was also more difficult than I expected. It's easy to launch another executable from a Python program using subprocess, but getting them to interact is another matter; by default, the main program expects the subprocess to run to its end, produce one burst of output, and be done. I ended up using the temporary file trick (described in the second answer). Both the Acuitas side and the independent program side send outputs, then wait for a response to appear in either the PIPE or the file, then formulate and send new outputs ...

Recreating Allergic Cliffs without all the graphics ended up being fairly simple, though. The game script is under 250 lines of code. Here's the boilerplate it uses to set the scene at the beginning of any game run:

"You are a guide."

The player character in LJotZ is referred to as the "guide" of the zoombinis; that's it. We don't even know what species this person is.

"You are at the Allergic Cliffs."
"There is a chasm."
"The chasm has a near side."
"The chasm has a far side."
"The far side has a lefthand cliff."
"The far side has a righthand cliff."
"There is a lefthand bridge over the chasm."
"There is another righthand bridge over the chasm."

Thanks to my January work on adjectives and distinct instances, the lefthand bridge and the righthand bridge can be distinguished. I'm using these words instead of "left" and "right" to avoid tricky sense disambiguation issues for now.

"You can put a zoombini on the lefthand bridge."
"You can put a zoombini on the righthand bridge."

Here the game gives the player affordances - that's a fancy name for obvious possible actions. In the original, these are communicated visually. Clicking on a zoombini "picks them up" (they start following the cursor and their locomotion devices dangle). Two patches of ground next to the bridges flash if the zoombini is moved over them, as a sign that the zoombini can be set down there.

"If a zoombini crosses a bridge, the zoombini will be on the far side."
"If you put a zoombini on a bridge, the zoombini will try to cross the bridge."

A couple of inference rules specific to this setting, to aid in problem-solving. I'm not sure whether I'll keep them in the final version, or have Acuitas learn this mechanic for himself too.

"You want all zoombinis to be on the far side."

This sentence establishes a goal for the player character. In the original, this would have been implicit in the narration and premise.

"Six pegs hold the bridges up.",
"If all pegs pop loose, the lefthand bridge will fall.",
"If all pegs pop loose, the righthand bridge will fall.",
"If a bridge falls, a zoombini cannot cross the bridge."

A warning about the loss condition, which thwarts the goal.

And that's it. Even a lot of the descriptions of the scene are just pretty nothings; the important part is the existence of the two bridges and the fact that the player can put zoombinis on them.

Here's an example description of a zoombini:

Oosebeek is a zoombini.
Oosebeek is on the near side.
Oosebeek has scruffy hair.
Oosebeek has eyelids.
Oosebeek has an orange nose.
Oosebeek has wheels.
Oosebeek does not have a ponytail ...

That's right, I also have the game script tell Acuitas every possible zoombini feature that this zoombini does not have. If not told that something is true, Acuitas doesn't assume it's false. Maybe this zoombini has wheels and a propeller, and nobody mentioned the propeller! Another way I could handle this would be to establish mutual exclusivity rules, like "if a zoombini has wheels, the zoombini does not have a propeller," and let him infer all the negatives. But this is an easier way to start.

I had to tweak some of the code behind the Narrative scratchboard for this as well. I introduced "temporary concepts" so Acuitas won't memorize the names of all sixteen zoombinis every time he plays a round. That would junk up the semantic database quickly. Playing this game much can easily lead to interactions with hundreds of zoombinis, and their names are procedurally generated strings. They're made to be loved, but not remembered.

If Acuitas puts a zoombini on the safe bridge, the game will tell him what happens afterward:

Oosebeek crosses the righthand bridge. (Acuitas has to infer that Oosebeek is now on the far side.)

If Acuitas puts a zoombini on the bridge over the cliff that's allergic to them, he gets this kind of response instead:

Oosebeek tries to cross the lefthand bridge.
The lefthand cliff sneezes.
Oosebeek is thrown to the near side.
Oosebeek cannot cross the lefthand bridge.
The first peg pops loose.

My goal for this month was to get Allergic Cliffs set up and make it possible for Acuitas to play. He's not any good at the game yet. His Game Engine is aware of the goal but has no idea how to reach it - so it falls back on trying the actions offered by the affordances. He'll keep putting a randomly chosen zoombini on a random bridge until he either loses or wins by dumb luck. After he's finished, the game-playing action generates a flow diagram from the game's narrative scratchboard for me; between that and the game outputs written to the temp file, I can see what happened.

Later this year I'll work on trial-and-error learning so he can actually win. This is a brand new area for me, and I'm excited.

Until the next cycle,
Jenny

Monday, March 10, 2025

Foundations Part II: They're Bluuuuue

Yeah, this series has a Part I - bet you thought I'd never finish it! It's time for me to showcase my other favorite edugame from childhood, Logical Journey of the Zoombinis. Like the Doctor Brain games, this one was so good for me that I wanted to keep playing it as an adult. I still have the original CD and can run the game if I set up one of my older Windows computers. (If you'd like to play it on a modern PC, there is a remake, though they redid all the art for some silly reason). Unlike the Doctor Brain series, Logical Journey does not teach any encyclopedic knowledge or technical skills. It is 100% about how to think - reasoning, experimenting, and planning. All the puzzles sorta have a basis in mathematics or programming, but you wouldn't realize that unless you were told (or knew what to look for).

Four zoombinis, which look like little blue orbs with hair, eyes, nose, and locomotion devices attached, are gathered around a hole dug in the ground, looking conspiratorially at each other.
Get in the hole, we're escaping!

Let's start with the obvious: this game is CUTE. What little kid doesn't love small round innocent creatures with big eyes? The ridiculous supporting characters range from an anthropomorphic ringtail cat to sapient rocks and trees. There's a thin but motivating plot: the Zoombinis were a happy nation of craft workers [1] until the Bloats tricked them into a bad trade agreement and basically enslaved them. The player character is a "guide" who helps bands of Zoombini refugees travel to a distant land where they can be free. That means getting them through bizarre obstacles, which I guess they're not smart enough to manage on their own.

To get a group of Zoombinis through the entire trek, you have to solve nine puzzles out of the twelve available. A common theme across seven of the puzzles is a hidden rule you must deduce. Sometimes the rule is about categories, sometimes it's about mapping (functions), sometimes it's about spatial relationships ... regardless, it can only be found through trial and error, and you get a limited number of tries. So this game excels at teaching the player not only how to generalize from limited experience, but also how to choose experiments that judge between competing possibilities and maximize information gained. Other puzzle elements I can think of include resource allocation under constraints, prediction, and sequencing.

An ethereal light grid is projected above a deep chasm in an underground cavern. Several zoombinis are floating above the grid inside bubbles. The bubble-making machines are visible on the ledges that border the chasm. Various symbols that resemble arrows, buttons, etc. are suspended within the grid.
Bubblewonder Abyss, the last obstacle, became my favorite puzzle once I figured out how it worked. It's all about sequencing (you solve it by sending Zoombinis across in the correct order) and imitates computer program elements like toggles and if/else statements. Screenshot obtained from zoombinis.fandom.com. 

This is also the only edugame I can think of that had a serious difficulty curve - it enabled me to watch myself get smarter. When I played for the first time, the easiest level was manageable (mostly - I had no clue what was going on in the Fleens puzzle), but the upper levels were too hard. When I got older and came back to it, I found myself mysteriously able to figure out parts that once seemed impenetrable.

I can remember having big feelings about this game - mostly frustration. Failing a puzzle means you "lose" some Zoombinis. They never die (the designers weren't brutes), but they do go back to the closest available campsite. And then, unless you lose more Zoombinis, you can never get back to moving perfect groups of sixteen around. You'll always have a "remainder" stuck at one of the camps. I adore round numbers enough that this ticked me off. It's tough to choose the puzzle I had the fiercest love-hate relationship with. "Mirror Machine" probably drove me crazy the longest, but I have to give the award to "Titanic Tattooed Toads," because failing at this one really made me feel dumb. It's quite easy if you meticulously pay attention: just make sure your lily pad feature of choice forms an unbroken trail across the marsh. If you aren't meticulous and miss one incorrect lily pad, boom, the scenario becomes unwinnable. Being impatient and launching more than one toad at once can also wreck you. Thanks loads, toads!

An overhead view of a river with an orderly grid of lily pads spanning it. Each lily pad is decorated with a colorful flower. Giant toads and crabs are sitting on some of the lily pads; the toads have zoombinis riding on their heads.
The same-color paths were always easier for me to find than same-shape, so I wonder if this puzzle is extra torture for colorblind kids. Screenshot obtained from zoombinis.fandom.com.

My late-blooming achievement was not intelligence, but discipline. In early playthroughs, I lost interest after a few journeys at the highest difficulty level. It wasn't until I was older ... I forget when, probably my late teens ... that I "beat the game" by transferring a full complement of 625 Zoombinis from Zoombini Isle to Zoombiniville. That involves playing the nine puzzles at least forty times, even if you do it perfectly. Was it worth it? I don't know, but I feel strangely satisfied. I guess it means I cared. (If you leave the game running in Zoombiniville for very long, the narrator starts harassing you about all the Zoombinis still living under tyranny. Tell him I finally committed and went back for every last one.)

There might be a particular reason why I decided to talk about this game this month, but you'll just have to wait and see. :)

Happy cogitations,
Jenny

[1] How they managed this without hands or other manipulators, I don't know. Don't overthink it.