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

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.