[m-users.] Mercury for Game AI

M McDonough foolkingcrown at gmail.com
Fri Jan 21 19:21:29 AEDT 2022


On Thu, 20 Jan 2022, David Epstein <davideps at umich.edu> wrote:
> Thank you Zoltan and Fabrice.  I just need to maintain (add and remove)
> facts before a query. This seems possible in Mercury through various data
> structures in the standard library. I need to review Julien's fruitbowl
> example again. He used lists to permit compiled Mercury to behave in a way
> similar to redefining a predicate. However, I'm not sure how this is
> different than just using those same data structures directly in C#.

I have written a number of games in Mercury, and I think the big
benefits it has over C# for games are:

1. Being functionally pure, it is relatively easy to write unit tests
for the game without structuring your game specifically to allow it,
which is usually very difficult for games. There is even a unit
testing framework, "Transunit", built specifically for this use-case.
2. Writing AI/behavior for systems that like pathfinding or constraint
solving is made very easy using multi/nondet facilities. This
essentially automates the need to save previous states or handle
"open"/"closed" solutions.
3. The expressive (and non-nullable) type system makes moving a system
from prototyping/tech demo stages to its final stage much easier, as
it turns run-time errors for missing data/logic into type or mode
errors.
4. The mode system provides the most ideal way to perform guaranteed
correct round-trip data translations, such as from on-disk to
in-memory representations of data. This is extremely useful for
writing reliable game data saving and game level/data loading systems.


More information about the users mailing list