[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pbmserv-dev] Non-sequential
On Thu, 30 Jun 2005, Michael Hammond wrote:
> Has anybody built any non-sequential games for the server? I was wandering
> through the Game.cpp code and wondered how the simultaneous stuff works.
ToW (Tug-of-War) is the best example of a simultaneous move game.
> I still haven't figured out why the wins for my test game are getting
> reported late - code for that is below...
OK, it's coming back to me now...
When IsGameOver is called, the move has already been made and the move has
been added to the moves array. CurrentPlayer() just does "return
moves.Count() % players.Count()", so to get the real CurrentPlayer()
inside IsGameOver you have to subtract 1 (with appropriate modulus).
For 2-player games, replacing "CurrentPlayer()" with "!CurrentPlayer()"
works.
~ John Williams
> -----Original Message-----
> From: owner-pbmserv-dev@gamerz.net [mailto:owner-pbmserv-dev@gamerz.net] On
> Behalf Of Michael Hammond
> Sent: Thursday, June 30, 2005 11:29 AM
> To: pbmserv-dev@gamerz.net
> Subject: RE: [pbmserv-dev] Entirely new question from the new guy
>
> > You might have to post the IsGameOver function.
>
> Here's the GameOver code. I borrowed liberally from the connect4 code.
> Note that this is NOT the finished code - for simplicity, I'm saying whoever
> plays in the middle square wins.
>
> int Tictactoe::IsGameOver(const char *&winner)
> {
> int row, col;
> /* Check for win... */
> if ( GetAt(1,1)==PlayerPieces(CurrentPlayer())) {
> winner = players[CurrentPlayer()];
> return 1;
> }
>
> for (col=0 ; col<= 2 ; col++)
> for (row=0 ; row <=2 ; row++)
> if (IsBlank(row,col))
> return 0;
>
> winner = NULL;
> return 1;
> }
>
> -----Original Message-----
> From: owner-pbmserv-dev@gamerz.net [mailto:owner-pbmserv-dev@gamerz.net] On
> Behalf Of John Williams
> Sent: Thursday, June 30, 2005 10:58 AM
> To: pbmserv-dev@gamerz.net
> Subject: RE: [pbmserv-dev] Entirely new question from the new guy
>
> On Thu, 30 Jun 2005, Michael Hammond wrote:
>
> > Thanks, that was great. Now I have a new snag. I've simplified my
> > win-scenario code for testing purposes. When one player hits the win
> > condition, the win isn't reported until the next player makes their move.
> > It correctly reports who the winner was, but that next move should not be
> > allowed to take place.
>
> You might have to post the IsGameOver function.
>
> You have to return 1 to indicate the game is over, and set the winner
> parameter to the name of the winner (or NULL for a draw).
> You are not doing "return CurrentPlayer()" on a win, are you?
>
> > Separately (and less importantly) I was getting stack dumps after a win
> > because I was tripping over something in the ratings code. I disabled
> > ratings as a band-aid - is there a better fix?
>
> You probably need to create the $PBMSERV/ratings and $PBMSERV/standings
> directories.
>
> ~ John Williams
>
>
>
> To unsubscribe, send a message to esquire@gamerz.net with
> unsubscribe pbmserv-dev@gamerz.net
> as the BODY of the message. The SUBJECT is ignored.
>
>
>
> To unsubscribe, send a message to esquire@gamerz.net with
> unsubscribe pbmserv-dev@gamerz.net
> as the BODY of the message. The SUBJECT is ignored.
>
>
>
> To unsubscribe, send a message to esquire@gamerz.net with
> unsubscribe pbmserv-dev@gamerz.net
> as the BODY of the message. The SUBJECT is ignored.
>