bug-gnubg
[Top][All Lists]
Advanced

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

Re: [Bug-gnubg] How would I do this?


From: Joern Thyssen
Subject: Re: [Bug-gnubg] How would I do this?
Date: Mon, 12 Aug 2002 19:44:51 +0000
User-agent: Mutt/1.4i

On Mon, Aug 12, 2002 at 09:20:42PM +0200, Jim Segrave wrote
> 
> I was playing with the idea of having a command which would do an
> CommandAnalyzeMove() for any 'marked' move. This would be for those
> who do a quick analysis of a game to find the serious errors. Then
> you'd set a better analysis and run 'Anlyse marked' to re-evaluate all
> the marked moves to get a better indication of what was wrong/how
> wrong it was. I realise that some moves which weren't marked at all
> with a say, 0 ply analysis, would not be handled by this method, but
> still it might be useful.
> 
> I tried using the CommandAnalyzeMatch code and the underlying
> AnalyzeMatch function as a model, but it doesn't work correctly. I
> assume when skipping through the move list to the next move to
> analyse, I'm not setting some portion of the state needed for
> AnalyzeMove to function correctly. So the re-analysis is not, as far
> as I can see, actually re-analysing the move I think it is.
> 
> What I tried was (leaving out the odds end ends necessary to make this
> a command in gnubg.c and gtkgame.c and so forth:
> 
> extern void CommandAnalyseMarked (char *sz) {
> 
>     list      *pl;
>     moverecord *pmr;
>     matchstate msx;
>       int             nMoves;
> 
>       if( !plGame ) {
>         outputl( _("No game is being played.") );
>         return;
>       }
> 
>       if( CheckSettings() )
>         return;
> 
>       nMoves = NumberMovesGame ( plGame );
> 
>       ProgressStartValue( _("Analysing marked moves; move:"), nMoves );
> 
>       for( pl = plGame->plNext; pl != plGame; pl = pl->plNext ) {
> 
>         pmr = pl->p;
>         ProgressValueAdd( 1 );
>         if (MoveIsMarked (pmr)) {

remove this line                memcpy ( &msx, &ms, sizeof ( matchstate ) );

>               if( AnalyzeMove ( pmr, &msx, NULL,
>                                                       &esAnalysisChequer,
>                                                       &esAnalysisCube, FALSE 
> ) < 0 ) 
>                       break;
>         }
          else
             /* update the board, turn etc */
             ApplyMoveRecord ( &msx, pmr );



> #if USE_GTK
>         if( fX )
>               GTKUpdateAnnotations();
> #endif
>       }
>       
>       ProgressEnd();
> 
>         
> }                     

ApplyMoveRecord applies the moverecord (wow!), i.e., updates the board
after chequer play, update who's on roll etc.

The first moverecord in each game is a movegameinfo. For this particular
moverecord ApplyMoveRecord will initialise the board with the starting
position and more, so it's not necesary to initialise msx if you're
analysing the entire game, hence the removal of "memcpy (..)".

AnalyseMove includes a call to ApplyMoveRecord, hence the "else
ApplyMoveRecord ( &msx, pmr );".

I've not testet the code above, but I think it would work, otherwise
ask again :-)

Jørn

-- 
Joern Thyssen, PhD
Vendsysselgade 3, 3., DK-9000 Aalborg, Denmark
+45 9813 2791 (private) / +45 2077 2689 (mobile) / +45 9633 7036 (work)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]