Marc Lanctot on Tue, 3 Aug 2010 17:33:56 -0700 (MST)


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

Re: [game-lang] dice rolls


On 08/03/2010 07:09 PM, Simon McGregor wrote:
If we are going with a GDL-style syntax, I for one am going to have to
learn more about logic programming. Please forgive my ignorance!

We're treading way out of my expertise here. I'm not sure how much I'll be able to contribute to this. Anyway, please forgive me for asking:

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


This reads "l is a roll of NdS if l is a list of N numbers between 1
and S", right?

How would we use this?

For example, consider the following game. I roll a 3d6, and add the numbers to get my score. Then you roll a 3d6 and add the numbers to get your score. The winner is player with the highest score, or a draw if it is a tie.

How would we go about describing this game?

I'm having trouble with the logic lingo, so please bear with me.

# initial state S_0
# collection of .. atoms? .. facts? ..?
players(player1, player2)      # players is a list
score(player1, 0)
score(player2, 0)
turnplayer(player1)

# collection of predicates.. rules?

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

nextplayer(player1, player2)
nextplayer(player2, player1)

# using syntax from http://en.wikipedia.org/wiki/Fluent_calculus

State(Do(myroll), s)) o score(x, sc) o turnplayer(x) =

  State(s) o roll(3d6, l) o sum(l) == n o score(x, sc + n)
           o nextPlayer(x,y) o turnplayer(y)

# end of the game predicate

end(s) :-
   forall(p, in(p, players) -> score(p, x) & (x > 0))

# winner

draw(s) :-
  sc1 == sc2 & score(player1, sc1) & score(player2, sc2)

winner(p,s) :-
  end(s) & forall(p', in(p', players) & p' != p
         & x > y & score(p,x) & score(p,y)

(Am I missing existential quantifiers everywhere?)

Is this the kind of this we want?

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