Follow

I talk a lot about Prolog but really what I want is just a language I can write an Infocom / SHRDLU style adventure game / text-based AI simulation in.

My problem is I have high expectations for a language because I want to do what seems to me to be very simple things:

* have the world obey rules, so all actions cause consequences

* rules that can be changed at runtime

* game AIs can read these rules and make plans

* save/ load the game state to/from disk

Turns out getting these is HARD.

@jim All things are possible in Lisp, yes, given sufficient effort

Unfortunately the 'sufficient effort' part just to get to 'can literally type text into a box and save and load from a disk file' is 'quite a lot'

@natecull I wrote a infocom-ish thing in lisp for college many many years ago, and it wasn't too hard ... *but* I never attempted to serialise state to disk (i.e. saved gamed) and there wasn't any internal structure for an in-game agent/ai to get a handle on that wouldn't have required a lot of hard coding of knowledge about the actual game/world and therefore would not be an 'infocomish' game.

But text from a box -> in-game state wasn't as bad as you

@jim Yep, it's the serialization that's a big killer. It's so awful a problem that most IF engines skip it completely and just make it something the emulator does as a machine instruction, cos user code *can't* do it.

Which is great! Until you're running a generic VM and you don't have that facility.

Or you literally emulate an IF engine (Z-machine, Glulx, TADS) in Javascript.

This all just strikes me as... odd.

@jim Given a working Lisp system, getting text into a box isn't hard.

Getting people a working Lisp system and letting them get a game into that system without it also being a root exploit... that's a bit harder.

@natecull
I like how well prolog does here. It does reasonably at all of that minus the mutability of the world I suppose.

@violet Yep, Prolog was my first thought.

Literally more than ten years ago when I first saw Inform 7 I went 'omg I could whip this up in ten lines of Prolog'

and I still think that, I'm just waiting for Prolog to get.... better. Or Kanren to get understandable without me having to buy a book.

@natecull
I should reread that chapter of paradigms of artificial intelligence programming which deals with this

@violet There is some wonderful stiff in PoAIP but... it's very very Common Lisp-y.

@jankoekepan Theoretically any Turing-complete language can do anything, but, ...

@jankoekepan Lambdas will not save you, unfortunately.

Can you save your lambdas to disk?

The AI needs to be able to read the rules as *knowledge*, not run a function and have {unknown things happen} to the game state.

You need a format *for* the game state, because you're going to need a lot of it; the AIs may be imagining different game states as they plan.

All these things can be done, but they fall into designing a language, and possibly an emulator for that language, not just coding.

@jankoekepan I understand that most of these requirements are not present in most current games.

They're what I personally want, however.

@jankoekepan Yes! That's exactly what I need.

The need to represent a DSL succinctly in the core grammar/syntax of the language, unfortunately, rules out a LOT of languages because their core syntax tends to get in the way of building succint DSLs.

Lisp is about the only thing left standing.

@jankoekepan @natecull this conversation is fascinating.

I’m interested to see if you come up with something. I’ve dabbled here to and it’s the kind of thing where it’s fairly simple until it isn’t :)

@jbob @jankoekepan

A large motivation of this strange odyssey was my experience writing 'Planner' for Inform 7 ( inform7.com/extensions/Nate%20 ) which....

yeah, I just gave up on I7 after this because, the syntax of the language was just so absolutely hostile to what I was trying to do.

But the IF community got stuck on I7 and...

Well, maybe I'll just try again from scratch, this time in Node.js.

@jbob @jankoekepan

Inform 7 is like writing COBOL. Except a COBOL with half of Prolog attached, and the two halves glued together with FORTRAN.

It is a fascinating language but an infuriating one.

@jbob @jankoekepan

And *then*, the IF community wandered out into ChoiceScript and whatever Fallen London runs on and even less featureful web-based languages and platforms than I7 and I'm just over here a million miles away watching it all.

@natecull does inform7 not fit the bill? (i have no idea, i’ve never used it, but i understand that it is a prolog style language specifically designed for text adventures)

@natecull sorry I only just after that remark read the thread. hmmmkay. yes. shrdlu was interesting but ultimately only worked on the virtue of the extremely limited scope of its world to simple shapes and simplistic physics. I wonder if a contraints oriented language might fit the bill?

@zensaiyuki It doesn't for me, no. Here's the library I built in it, which convinced me that Inform 7 was never going to be my friend.

inform7.com/extensions/Nate%20

@zensaiyuki The thing about Inform 7 is that it HAS Prolog-looking-like 'rules', but:

* part of them is only implemented at compile time, involving hard-coded syntax. The source code of the compiler wasn't public back when I was looking at it, this may have changed.

* the rules themselves do pattern matching but then execute imperative code procedures. They''re not safe for an AI to run.

* Data storage is VERY restricted: objects and typed tables. Some names. Whole thing aimed at 64K ram.

@zensaiyuki A bigger problem is that the semantics of the whole thing are just super fuzzy and unclear. Natural language plus pattern-matching rules plus COBOL-like procedures plus Prolog-style 'facts' plus limited Prolog-style rules but that only go in one direction plus Literate Programming (your program has 'Chapters' that you name, etc)

Some of this stew meshes well together. Other parts, not so much.

@zensaiyuki It's insane just that it exists, though. In a good way. It's a mind-blowing little machine to observe, from a safe distance.

@natecull you have an interesting set of requirements, and I cannot say I’ve heard of anything that really fits all of them, but if i were to build something, I would probably start with sqlite, provided that your “rules” are logic rules and not fuzzier physics rules

@natecull it’s not commonly taught with this style of usage in mind, but the original point of “relational databases” was to have something like prolog with a runtime modifiable set of facts.

@natecull a properly designed schema would give you the ability to have an AI dynamically generate a query, whose result is the consequence of a possible action. or a query that gives you a list of possible actions. and so on.

@zensaiyuki I like how you said 'schema' and 'AI' together in the same sentence like they will play well together.

As long as your database basically just stores integers, it should be able to store any query an AI comes up with.

@natecull why not? keep in mind, I am mot talking about how an sql database is commonly used. AI agents would have the capability of creating new tables and reading schema definitions to make dynamic decisions about them

@zensaiyuki hmm, and how would sqlite relate to save-games? and multiple games?

I mean if your data model is gonna be restricted to what can fit in a SQL database, and only needs to be serialised at game start and end, you might as well just use.... text?

@natecull “just text” doesn’t give you the logical induction capabilities that sql gives you. a save game would be the list of actions that were taken, including modifications to the world. it’s kinda hard to explain what I mean without a whiteboard

@zensaiyuki just as a reminder:

The Infocom save-game format is literally a memory dump of a simulated Lisp machine.

And you'd put this into a SQL schema? Good luck.

@natecull no of course not. that would be silly. how do you expect to break beyond the likits of the infocom engine by copying what it does?

@zensaiyuki one doesn't normally break beyond limits by imposing smaller ones...

@natecull I am not, you’re just applying a stereotype of what an sql database is, beliving i am referring to that, when I am not.

@natecull i am referring to the version of sql where each “table” represents a logical predicate, and a query implementing a logical induction engine.

@natecull not a save game that is loaded, and then dumped at the beginning and ending of each session, but a session represented as a stream of events that can be mechanically projected via a fold function to produce the state of the world at any given point in time

@zensaiyuki That sounds very nice! And completely unlike SQL.

@natecull it does sound unlike sql! which is why it’s a bit hard to explain!

@natecull i might just have to do a proof of concept or something. I dunno. a hello shrdlu maybe.

@natecull precisely, and to be clear I am not talking about implementing the whole thing in sql- just the storage and querying of facts about the world.

@natecull the agents within the world would need to be implemented some other way, responsible for adding facts

@zensaiyuki I wonder what Bonner and Kifer's Transaction Logic was:

<< This is a new logic for defining complex database transactions, and like GOLOG provides a rich repertoire of of operators for defining new databases in terms of old. These include sequence, nondeterministic choice, conditionals and iteration. >>

informatik.uni-leipzig.de/~bre , p 19

citeseerx.ist.psu.edu/viewdoc/

@zensaiyuki It is very weird how hard just modelling 'add this to database, then remove that from database' seems to be.

Show more

@natecull

well prolog could handle the save/load part for its ruleset, IIRC? but you'd need the game itself to call prolog to get rule checks and I have no idea how much that'd impact things

(but apparently Prolog is platform-independent to some degree so it might be easier than it sounds?)

(also I just woke up so I'm probably talking out my ass)

@sydneyfalk I would write a whole game in Prolog, and I have, or started to, several times... at least just a basic skeleton. But a big problem with Prolog in the 2010s is that (SWI, the most standard one) has only just figured out how to Unicode and still doesn't really understand this 'text' thing. Ironic, since doing natural language recognition on text is what the language was invented for.

@natecull

the knife was just as likely first used as a tool of combat as a tool of food prep

things get repurposed all the time

@sydneyfalk that's the beauty of it! one tool for fighting the monster and carving it! once you've finished slashing, it's ready to serve!

hashtag dungeon-to-table-eating

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!