Simon McGregor on Thu, 5 Aug 2010 10:19:51 -0700 (MST)


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

Re: [game-lang] dice rolls


>> [Marc]
>> 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.

>> # 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)

Just to mention, we could sweeten this a whole lot with some syntactic
sugar, e.g.

// define an action's "Poss" and "Do" logic in one place with implicit
current state "_now_"
action <rolls(_nature_, X)> {
  changes       // facts discarded from state s with Do(rolls(_nature_, X), s)
    ( control(Player) + scores(Player, Score) )
  to                // facts acquired in next state
    ( control(nextplayer(Player)) + (scores(Player, Score + X) )
  when (         // conditions for Poss(rolls(_nature_, X), s)
    exists( Y, roll(3d6, Y) and is_sum(X, Y) )
    and not gameover )
}

> [Joel]
> It's kind of what I want, but only kind of. I'm still not finding
> the fluent calculus syntax very perpicuous, and it seems like there's
> not clear separation between the definition of initial state, general
> rules, and state change. I think it's important that we have this so
> as not to end up with a big ball of mud.

We can probably handle this problem with appropriate syntax design.

I'm more concerned about having to handle sequential flow by naming
individual flow states (see other thread). I really don't want to
specify a turn sequence of "player can pick a card, then player can
move a piece, then player can play a card" using anything like


action <pickcard(Player, Card)> {
   changes ( ... + phase(pick) )
   to ( ...  + phase(move) )
   when ( ... and phase(pick) )
}

action <movepiece(Player, Piece, Position)> {
   changes ( ... + phase(move) )
   to ( ... + phase(play) )
   when ( ... and phase(move) )
}

action <playcard(Player, Card)> {
   changes ( ... + phase(play) )
   to ( ... )
   when ( ... and phase(play) )
}


...which smells far too much like GOTO for my liking. Especially since
there's no requirement for the pickcard, movepiece and playcard
definitions to be in contiguous text.


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