|
From: <mik...@ya...> - 2003-01-21 22:23:35
|
Hi,
We are currently trying to schematize card games using
a "formal" syntax (XML). In this way we can develop a
rulebook in a standardized format for each separate
game.
Mike
--- Patrick Carl <pat...@we...> wrote: > Hi
Magnus, hi gameframe ;)
>
> I like your ideas. Currently there exists a GameRule
> interface which
> represents the rule of a game. The processing of
> moves is done by
> GameState/GameTable, not to an interface Game. As
> you will notice, there
> is no interface Game yet in gameframe. The reason,
> as I remember, was
> the danger of mixing up what is meant with Game and
> prefering to split a
> Game in smaller pieces.
>
> But your idea of an RuleBook sounds good to me. A
> GameState could use a
> RuleBook instead of a GameRule. One question to the
> people knowing about
> game creation: Can the rules of every game (or every
> game we want to
> offer a framework for) be presented as a RuleBook
> and therefore be an
> ordered collection of Rules which are processed
> sequentially? I think it
> should be possible as long as every rule is atomic,
> meaning that it
> doesn't have influence on a former processed rule or
> it isn't influenced
> by a latter one.
>
> Patrick
>
> >
> > Hi!
> >
> > Some thoughts on architechture around rules:
> > I have intentionally shorted the code so there
> > are few modifiers and no throws clauses here.
> >
> > The Basic idea is: When a Move is to be made we
> find
> > the Rules that applies to that move. Checks if the
> move
> > is legal, then the Move is executed. After that
> the Rules
> > get to check the new GameState to see if we should
> alter
> > it. For example enter a new Phase or declare the
> end
> > of the Game.
> >
> > The intention to encourage the implementer of a
> Game to
> > structure the rules instead of writing one huge
> Rule class
> > with "if-else if" clauses. And also make it
> possible to have
> > rules that applies to certain pieces or cards.
> >
> > -- Code section --
> >
> > /**
> > * Generic Move interface used to describe an
> action that
> > * a player makes. Could be moving a piece,
> playing a Card etc
> > *
> > */
> > interface Move {
> > GameBean[] getInvolvedBeans();
> > Player getPlayer();
> >
> > /**
> > * Updates the game state when this Move is
> made.
> > * This method will only be called if it is
> legal
> > * to execute this Move.
> > */
> > void update(GameState gs);
> > }
> >
> > interface Player { }
> >
> > interface Game {
> > GameState getCurrentState();
> > RuleBook getRuleBook();
> >
> > /**
> > * Checks if the move is legal and if so will
> update the
> > * GameState.
> > */
> > void execute(Move m);
> > }
> >
> > /**
> > * Holds all information about the current game
> situation.
> > * Such as stage, phase, pieces, cards played etc
> etc.
> > */
> > interface GameState {}
> >
> > interface RuleBook {
> > /**
> > * Checks all rules that applies to the move and
> current game state
> > * sorts them and returns them.
> > */
> > Rule[] getRules(Move m, GameState gs);
> > void addRule(Rule r);
> >
> > /**
> > * Overrides an old Rule with a new one.
> > * If the Condition for the new Rule is met then
> only that Rule
> > * will be checked. If the old Rule's Condition
> is met and the
> > * not the newVersion's, then the old rule is
> checked.
> > *
> > */
> > void overrideRule(Rule toOverride, Rule
> newVersion);
> >
> > }
> >
> > interface Rule extends Comparable {
> >
> > Condition getCondition();
> > boolean isLegal(Move m, GameState gs);
> > //Possibly there should be different types of
> rules
> > //One for legal checks and another for post
> conditions.
> > void postMoveCheck(GameState gs);
> > int compareTo(Object obj);
> > }
> >
> > /**
> > * Used to describe when a Rule applies.
> > */
> > interface Condition {
> > boolean doesApply(Move m, GameState gs);
> >
> > /**
> > * Condition for rules that should always be
> checked.
> > */
> > Condition ALWAYS = new Condition(){
> > public boolean doesApply(Move m, GameState
> gs){
> > return true;
> > }
> > }
> > }
> >
> > /**
> > * Used to describe a Condition for Rules that
> > * applies when certain GameBeans are involved
> > * in the Move.
> > */
> > class BasicCondition {
> >
> > GameBean[] appliesTo;
> >
> > public boolean doesApply(Move m, GameState gs){
> > for(int i = 0; i < appliesTo.length; i++){
> > for(int j = 0; j <
> m.getInvolvedBeans().length; j++){
> >
> if(appliesTo[i].equals(m.getInvolvedBeans()[j])){
> > return true;
> > }
> > }
> > }
> > return false;
> > }
> > }
> >
> > --
> >
> > Magnus Lundgren
> >
> >
> >
> >
>
-------------------------------------------------------
> > This SF.NET email is sponsored by: Thawte.com - A
> 128-bit
> > supercerts will allow you to extend the highest
> allowed 128
> > bit encryption to all your
> > clients even if they use browsers that are limited
> to 40 bit
> > encryption.
> > Get a guide
> >
>
here:http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0030en
> > _______________________________________________
>
=== message truncated ===
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
|