Joel Uckelman on Tue, 3 Aug 2010 08:13:54 -0700 (MST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[game-lang] dice rolls


The GDL II paper got me thinking about how one could write a predicate
for rolling dice where the number of dice and number of faces are
parameters. What I came up with as a first attempt is this:

  roll(nds,l) :- 
    list(l) & size(l) == n & forall(x,(in(x,l) -> (1 <= x & x <= s)))

(I'm trying to write something GDL-looking, but not necessarily something
which is well-formed GDL. Basically, I'm writing something I would like
to be well-formed in the language we develop.)

In roll(nds,l), I'm treating 'd' as a comma, in order that dice rolls
can be written using the standard notation. This is just syntactic sugar,
you could just as well write roll(n,s,l).

There are comparison operators here, and numeric literals, and l is a list
variable (but maybe we don't need actual list variables---perhaps we can
already axiomatize all of the features of of lists...). We also need the
universal quantifier in the antecedent because we don't know how many
elements there will be in the list of rolls beforehand.

This bit with lists is interesting: Datalog, of which GDL is a sublanguage,
doesn't have compound terms. (Prolog does.) Lists are compound terms. I
wonder whether you could add lists to Datalog without destroying all of
its nice properties...

I'm at a loss for how to define size(l), in(l), and forall(l,X) if there's
no language-level support for lists.

-- 
J.
_______________________________________________
game-lang mailing list
game-lang@xxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/game-lang