[m-users.] Mercury for Game AI

Tomas By tomas at basun.net
Thu Jan 20 02:24:49 AEDT 2022


On Wed, 19 Jan 2022 14:02:33 +0100, David Epstein wrote:
> I'd welcome suggestions on how to approach the subsystems described
> below in a manner that leverages Mercury's strengths.

> % Create characters
> % Define the world

These should be types:

| :- type person ---> adam ; bob ; carl ; dan.
| :- type room ---> salon ; bedroom ; hallway.

> % Place characters

Use e.g. a `multi_map(room,person)'

> % Define network for navigation
> connected(salon,hallway)
> connected(bedroom,hallway)
> connected(X,Y) :- connected(Y,X)

This looks fine, except for the rule. Just duplicate the links.

| connected(salon,hallway)
| connected(hallway,salon)
| connected(bedroom,hallway)
| connected(hallway,bedroom)
| ...

> % Assign character status
> dead(dan)

Depends... but probably not like that. You could have a set of dead
people, or a map from people to status, or something else.

> % Define some past events (things that actually occurred, regardless if anyone saw them)
> attack(bob,dan,bedroom)

No this needs to be some more complicated data structure. First of all
you probably need time points, and then a map from them to events, or
to sets of events.

The time points could be just numbers.

> Character Knowledge
> % bob knows what he did
> saw(bob,attack(bob,dan,bedroom)
> heard(bob,attack(bob,dan,bedroom)
> % adam heard what dan did
> heard(adam,attack(bob,dan,bedroom))

You can have terms like this, e.g. for passing to the planner, but it
should probably be stored as part of the event record.

> Action Planning
> I'm familiar with planners [...] Is there a more Mercury specific
> implementation, maybe something that involves constraint
> programming?

Nah. The main difference is that dynamic data is passed around in
variables, and has a type, it is not asserted/retracted.

> Parsing and Generating Dialogue
> The GUI will offer the user a set of words that can be translated
> into a Mercury query, for example "What did you hear" asked to bob,
> would become "heard(bob,X)."

Would become, eh. Nice bit of hand-waving?

You can do DCG, as was discussed recently on this list.

> Additional code would prevent bob from implicating himself in a
> crime. Perhaps DCG would be helpful in translating query results
> back into plain English?

Possibly, but probably easier to just write code, as in:

| write_sentence(Data) :-
|   write_subject(Data),
|   write_predicate(Data).

/Tomas


More information about the users mailing list