Simple make question

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Simple make question

Post by outAtime »

This should be an easy one for you experts out there. Im trying to make the second move of the PV, but I also need to make it somewhere other than in search.c.

This is what the code for update pv looks like in search():

Code: Select all

      /* update the pv: */
      pv[ply][ply] = moves[i];
      for &#40;j = ply+1; j < pv_length&#91;ply+1&#93;; j++)
      pv&#91;ply&#93;&#91;j&#93; = pv&#91;ply+1&#93;&#91;j&#93;;
      pv_length&#91;ply&#93; = pv_length&#91;ply+1&#93;;
I would try make (&moves[1], 0), but I dont think that would be right, and moves[MOVE_BUFF] isn't a global variable anyways. Maybe I need to make a new global variable? pv[PV_BUFF][PV_BUFF] is global, but Im not sure if I can use that one to make the second move in the PV.

The regular make in search is:

Code: Select all

 make (&moves&#91;0&#93;, i&#41;;
Im trying to implement some pseudo-code suggested by H.G.Muller:

Code: Select all

// WB command loop&#58;
while&#40;1&#41; &#123;
  if&#40;stm == computer&#41; &#123;
    Search&#40;);
    abort = 0;
    bestMove = PV&#91;0&#93;; **in my case "bestMove"is&#58; comp_move = think&#40;);
    ponderMove = PV&#91;1&#93;; **haven't found a way other than flip the board
    MakeMove&#40;bestMove&#41;; ** in my case&#58; make (&comp_move, 0&#41;
if I change the 0 to 1, it flips the board. 
    PrintMove&#40;bestMove&#41;;
  &#125;
  if&#40;ponderOn&#41; &#123;
    if&#40;ponderMove&#41; &#123;
      MakeMove&#40;ponderMove&#41;;**Ive tried making new variables, none work
so far. They all just cause the board to flip 
and the engine has no idea about the first  PV move. 
      Search&#40;);
      UnMake&#40;);
    &#125; else Search&#40;);
  &#125;
  abort = 0;
  ReadLine&#40;inbuf&#41;;
  // execute command
  ....
&#125; 
Please help!! The above code is so simple, but I can't figure out how to make the second move in the PV!!!!!!!! For me PV[1], even if I make a global variable (I tried making a global variable pvmove[PV_BUFF]), just insn't working...do I need to do something in search() like:

Code: Select all

 moves&#91;i&#93; = pvmove&#91;i&#93; &#40;or maybe pvmove&#91;ply&#93;???)
How do I make the second move of the PV?? In the pseudo-code example, how is PV[1] able to be used?

In my code: (not working! this is just an example of a recent experiment)

Code: Select all

  if (&#40;allow_pondering && !force_mode && !result && game_ply != 0&#41; 
        || is_analyzing&#41;
	&#123;
	***  ponder_move = pv&#91;0&#93;&#91;0&#93;; ***
	  is_pondering = TRUE;
	  make (&ponder_move, 0&#41;;	    
	  think&#40;);
	  unmake (&ponder_move, 0&#41;; 	  
	  is_pondering = FALSE;
What should I change = pv[0][0] to, in order to have make (&ponder_move, 0) make the second move of the PV?
outAtime
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Simple make question

Post by bob »

outAtime wrote:This should be an easy one for you experts out there. Im trying to make the second move of the PV, but I also need to make it somewhere other than in search.c.

This is what the code for update pv looks like in search():

Code: Select all

      /* update the pv&#58; */
      pv&#91;ply&#93;&#91;ply&#93; = moves&#91;i&#93;;
      for &#40;j = ply+1; j < pv_length&#91;ply+1&#93;; j++)
      pv&#91;ply&#93;&#91;j&#93; = pv&#91;ply+1&#93;&#91;j&#93;;
      pv_length&#91;ply&#93; = pv_length&#91;ply+1&#93;;
I would try make (&moves[1], 0), but I dont think that would be right, and moves[MOVE_BUFF] isn't a global variable anyways. Maybe I need to make a new global variable? pv[PV_BUFF][PV_BUFF] is global, but Im not sure if I can use that one to make the second move in the PV.

The regular make in search is:

Code: Select all

 make (&moves&#91;0&#93;, i&#41;;
Im trying to implement some pseudo-code suggested by H.G.Muller:

Code: Select all

// WB command loop&#58;
while&#40;1&#41; &#123;
  if&#40;stm == computer&#41; &#123;
    Search&#40;);
    abort = 0;
    bestMove = PV&#91;0&#93;; **in my case "bestMove"is&#58; comp_move = think&#40;);
    ponderMove = PV&#91;1&#93;; **haven't found a way other than flip the board
    MakeMove&#40;bestMove&#41;; ** in my case&#58; make (&comp_move, 0&#41;
if I change the 0 to 1, it flips the board. 
    PrintMove&#40;bestMove&#41;;
  &#125;
  if&#40;ponderOn&#41; &#123;
    if&#40;ponderMove&#41; &#123;
      MakeMove&#40;ponderMove&#41;;**Ive tried making new variables, none work
so far. They all just cause the board to flip 
and the engine has no idea about the first  PV move. 
      Search&#40;);
      UnMake&#40;);
    &#125; else Search&#40;);
  &#125;
  abort = 0;
  ReadLine&#40;inbuf&#41;;
  // execute command
  ....
&#125; 
Please help!! The above code is so simple, but I can't figure out how to make the second move in the PV!!!!!!!! For me PV[1], even if I make a global variable (I tried making a global variable pvmove[PV_BUFF]), just insn't working...do I need to do something in search() like:

Code: Select all

 moves&#91;i&#93; = pvmove&#91;i&#93; &#40;or maybe pvmove&#91;ply&#93;???)
How do I make the second move of the PV?? In the pseudo-code example, how is PV[1] able to be used?

In my code: (not working! this is just an example of a recent experiment)

Code: Select all

  if (&#40;allow_pondering && !force_mode && !result && game_ply != 0&#41; 
        || is_analyzing&#41;
	&#123;
	***  ponder_move = pv&#91;0&#93;&#91;0&#93;; ***
	  is_pondering = TRUE;
	  make (&ponder_move, 0&#41;;	    
	  think&#40;);
	  unmake (&ponder_move, 0&#41;; 	  
	  is_pondering = FALSE;
What should I change = pv[0][0] to, in order to have make (&ponder_move, 0) make the second move of the PV?
If I am looking at your code correctly, pv[0] is the first move for any particular ply depth. pv[1] is the second, and so forth. So it looks to me like you want to use pv[something][1] to get to the second move. I think in the ponder case above, you want pv[0][1] it would seem. pv[0][0] should be the move you just played...
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Simple make question

Post by outAtime »

Thankyou very much for the reply. I tried this out:

Code: Select all

          ponder_move = pv&#91;0&#93;&#91;1&#93;;
	  is_pondering = TRUE;
	  make (&ponder_move, 0&#41;;  
	  think&#40;);
	  unmake (&ponder_move, 0&#41;; 
	  is_pondering = FALSE;	
It compiles and the engine ponders, but (I was playing white pieces) as soon as the engine captured one of my pieces (a knight) the score jumped to +6.30 and it looked like it was thinking about taking my unprotected bishop next, which I think means it was thinking as though it was its turn to move, without being able to realize I could recapture with a pawn before it could take my bishop. Is that the way its supposed to work?
I think thats wrong, isn't it supposed to know the capturing piece can be recaptured during ponder?
outAtime
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Simple make question

Post by outAtime »

I have no idea why I asked that, its obviously not working as it should.
outAtime
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Simple make question

Post by outAtime »

For now Im just trying different combinations of [x][x]. Ill post again if anything works. Also, the engine was clearing the PV before beginning a new search, I have disabled that for now.
outAtime
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Simple make question

Post by Sven »

outAtime wrote:For now Im just trying different combinations of [x][x]. Ill post again if anything works. Also, the engine was clearing the PV before beginning a new search, I have disabled that for now.
If everything else regarding your implementation of pondering and pv handling were correct then using pv[0][1] as second move of the PV should do it, unless the pv[][] table has already been cleared prior to that point.

But since you report that it caused new problems I would expect that you have another bug. That is all I can say at the moment.

Sven
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Simple make question

Post by outAtime »

Yes. Something else is not working properly. Ponder is calling think(), so Im guessing I need to change something there, as well as maybe a couple other places in search() where I give the engine instructions on how to handle input from the GUI.
outAtime
LiquidNitrogenOverclocker

Re: Simple make question

Post by LiquidNitrogenOverclocker »

It sounds like this is a great time to use the printf() call.

:)

Go through your PV and format your array (and call a conversion routine as needed) and just examine its contents.

It's much better than the aggravation of trying to remember which way you indexed your 2D array.