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

Flipping Boards



Hi pbmserv developers,

I've just changed the pbmserv chess output (in chess, capablanca,
grandchess, quickchess and chex) to show your pieces on the bottom of the
board, so your pawns always advance up. The board is now flipped for
players playing as Black.

To do this I have updated game.*. The new game.*, by default, calls
PrintBoardAs. The default declarations are:

    virtual void PrintBoard(FILE *fp) { (void)fp; return; }
    virtual void PrintBoardAs(FILE *fp, int what, int which)
        { (void)what; (void)which; PrintBoard(fp); }

In other words, new games may override PrintBoardAs or PrintBoard. If you
use both, PrintBoardAs will be used. For older games which override
PrintBoard, the new default PrintBoardAs calls PrintBoard.

The arguments are:
    FILE *fp = pointer to the FILE structure describing a file opened
        for writing the board to
    int what = 0, 1, 2 or 3 (see below)
    int which = (depends on what)

Basically the new arguments are there to tell you whom the board should be
printed to, so that you can reflect the boards for Black players etc.

    If what = 1, the board is being sent to players[which].

    If what = 2, the board is being sent to subscribers[which].

    If what = 3, the board is being sent to notifiers[which].

    If what = 0 (which is irrelevant), the board is being sent to none of
        the above (eg. via 'show').

    Normally, what is always 0, 1, 2 or 3 and if what = 0, which = 0. But
        your code should assume that if what < 1 or what > 3 it is being
        sent to an undetermined person.

To get the relevant userid, refer to the named array (eg. players[which]).
Each string lists are implemented as char*. I implemented this as a number
to allow you to determine who gets the reflected board, even if you're
playing "chex challenge rrognlie rrognlie", for example. :-)

For chess variants, I use this simple rule:

    Only reflect the board if (what == 1 && which == 1).

You may be interested to fetch.2 the new chess.cpp reversal code, it's
actually a simple hack. Maybe someone is interested to reverse hexagonal
game variants like Abalone-for-6-players? :-)

Note that some games do not require this feature (eg.
ataxx-connect4-othello-pente-etc, mostly x-and-o games except gess when
implemented), but some do (eg.
jungle-entropy-congo-chess-chex-capablanca-grandchess-quickchess-etc).

Remember that which is zero-based, so that players[0] is white and
players[1] is black.

I'd like to hear any comments you might have about this (maybe you think
some other games need this; maybe you find a bug; maybe ...).

Enjoy!

- akur

PS. Anyone interested in implemented Chinese Chess (xiangqi)?
    Or even... Stratego? You can uncover only the pieces of the player
    whom you are sending the board to now! ;-)