[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pbmserv-dev] Adding a command to a game
On Wed, Sep 21, 2005 at 04:48:33PM -0600, Robert Barrell wrote:
> Hello.
>
> For my first foray into PBM-related development, I would like to add an
> SGF function to Go. I have a test server set up, and have the code
> almost done, but I am used to using C, AWK, Shell, etc., and not C++, so
> I have not yet figured out how to get it to work from the go.cpp module
> (at this point, it is working fine within game.cpp). Ideally, since the
> SGF format also supports other games, the best approach would be to:
>
> * Add an "sgf" comnmand to game.cpp and have it call the SGF function of
> the game for which it is being run.
> * Add the functioning SGF function to go.cpp for use now.
> * Add SGF functions to the code for existing games, but have them return
> a "failure" status so that game.cpp could say "The 'sgf' command is not
> implemented for game %s" but also allow future SGF programmers to add
> SGF to other games without having to modify game.cpp or game.h (they
> would only need to have their SGF function return a "success" status).
>
> Unfortunately, after trying several different things, I have not been
> able to figure out how to make the function a member of the Go class,
> then have it called from the command-parsing section of game.cpp.
Define a couple of virtual methods in Game
Game::ShowSGF()
Look at the code for Game::ShowAs().
ShowSGF could call doShowSGF...
Game::doShowSGF()
which might be defined as 'sgf format not defined for $GameType'
But then you could override that with Go::doShowSGF()
so... game.cpp does the cmd parsing... and calls ShowSGF().
ShowSGF() runs through the list of arguments to get the boards to display
and for each one, calls doShowSGF() [which is board specific]
Again... much like game.cpp calls ShowAs.... which calls PrintBoardAs
(details are foggy, but you get the idea)
--
/ \__ | Richard Rognlie / Sendmail Ninja / Gamerz.NET Lackey
\__/ \ | http://www.gamerz.net/~rrognlie <rrognlie at gamerz.net>
/ \__/ | Creator of pbmserv@gamerz.net
\__/ | Helping reduce world productivity since 1994