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

RE: [pbmserv-dev] ForcedMove



That fixed it, thanks!  Gee, what a rookie mistake - my coding is rustier
than I thought.

Mike

-----Original Message-----
From: owner-pbmserv-dev@gamerz.net
[mailto:owner-pbmserv-dev@gamerz.net]On Behalf Of Scott Huddleston
Sent: Saturday, September 03, 2005 1:15 AM
To: pbmserv-dev@gamerz.net
Subject: Re: [pbmserv-dev] ForcedMove



>      for (i=0;i==2;i++) {

should be

>      for (i=0;i<=2;i++) {

and ditto for the j loop.

>Coding an implementation of TicTacToe for practice, and my implementation
of
>ForcedMove isn't quite up to snuff.  I'm sure I'm missing something
obvious,
>but I don't know what it may be.  Moves are made by entering numbers 1-9.
>Code is below.
>
> 1 | 2 | 3
>-----------
> 4 | 5 | 6
>-----------
> 7 | 8 | 9
>
>My logic is: if it's the last turn, you have to play in the only open
space.
>Did I miss something?
>
>Mike
>
>const char *Tictactoe::ForcedMove(void)
>{
>
>
>   static char forced[2];
>   int i;
>   int j;
>
>   if (moves.Count() == 8)  {
>      for (i=0;i==2;i++) {
>         for (j=0;j==2;j++) {
>	    if (IsBlank(i,j)) {
>                 sprintf(forced,"%c",i*3+j+1);
>	         return forced;
>             }
>         }
>      }
>   }
>   return NULL;
>}


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.