Ponder

Discussion of chess software programming and technical issues.

Moderator: Ras

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

Re: Ponder

Post by outAtime »

Think I found it:

Code: Select all

void post_stat_thinking(void)
{
  /* post our thinking output: */

  long int elapsed;

  elapsed = rdifftime (rtime (), start_time);
  printf ("stat01: %ld %ld %d 0 0\n", elapsed, nodes, i_depth);
I'll compile and see what shape its in.
outAtime
Gian-Carlo Pascutto
Posts: 1260
Joined: Sat Dec 13, 2008 7:00 pm

Re: Ponder

Post by Gian-Carlo Pascutto »

But unless I'm missing something, you abort and then restart your search, which I'd consider highly undesirable.
User avatar
hgm
Posts: 28379
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Ponder

Post by hgm »

Indeed I do. Why would that be undesirable? It does not seem too hardly have any effect at all. The search picks up exactly where it was interrupted, because everything that was already done is cut off by hash hits on the restart.
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Ponder

Post by outAtime »

OK, compiled, and Im getting output now, but Im not sure what to think about it, because by the output, it appears to only ponder to a 3 ply depth and then stop...not sure why. Any ideas?
outAtime
Daniel Shawul
Posts: 4186
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: Ponder

Post by Daniel Shawul »

I don't stop search on ponder hits, but to achieve that I had to pay the price of a complicated code. Your way is much simpler because for my case i have to check if the command received is a move or not and if it is a hit .
Things that made my winboard code spaghetti are pondering (hit,miss,short search to find a move to ponder on incase tt don't have it) and analysis mode.
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Ponder

Post by outAtime »

OK, but I dont see any real advantage at all to just pondering 3 ply and then stopping :) hmmmm
outAtime
User avatar
hgm
Posts: 28379
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Ponder

Post by hgm »

Are you sure you disabled the code that makes the search stop on timeout, during ponder? (Or, alternatively, give it a generous new time allotment?)

Could be that on the first time it checks the clock, it thinks it is already out of time, because it is still applying the standards of the previous search.
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Ponder

Post by outAtime »

I really dont know where to find that. Im surprised it even worked to 3 ply the first time, actually. Ive been trying to update with some different code, but Im getting parse errors and stuff when I try to compile it.

Code: Select all

762 int interrupt(void)
763 {
764   int c;
765     
766 #ifndef ANSI
767
768 #ifndef WIN32
769
770 int bioskey (void) {
771
772  fd_set readfds;
773
774  FD_ZERO (&readfds);
775  FD_SET (fileno (stdin), &readfds);
776  tv.tv_sec=0; tv.tv_usec=0;
777  select (16, &readfds, 0, 0, &tv);
778  if (FD_ISSET (fileno (stdin), &readfds));
779    {
780      c = getc(stdin);
781
782      if (c == '?')   /*Move now*/
783	{
784	  return 1;
785	}
786      else if (c == '.')     /* Stat request */
787	{
788	  getc(stdin);
789	  post_stat_thinking();
790	  return 0;
791	}
792
793      ungetc(c, stdin);
794
795      if (!is_pondering) return 0; 
796
797      return 1;
798    }
799   else return 0;
800#else
801#undef frame
802#include <windows.h>
803#define frame 0
804
805  int bioskey (void) {
806
807  static int init = 0, pipe;
808  static HANDLE inh;
809  DWORD dw;
810  if(xb_mode) {     // winboard interrupt code taken from crafty
811    if (!init) {
812      init = 1;
813      inh = GetStdHandle(STD_INPUT_HANDLE);
814      pipe = !GetConsoleMode(inh, &dw);
815      if (!pipe) {
816	SetConsoleMode(inh, dw &  ~(ENABLE_MOUSE_INPUT|ENABLE_WINDOW_INPUT));
817	FlushConsoleInputBuffer(inh);
818	FlushConsoleInputBuffer(inh);
819      }
820    }
821    if(pipe) {
822      if(!PeekNamedPipe(inh, NULL, 0, NULL, &dw, NULL)) 
823	{
824	  c = getc(stdin);
825
826	  if (c == '?')   /*Move now*/
827	    {
828	      return 1;
829	    }
830	  else if (c == '.')     /* Stat request */
831	    {
832	      getc(stdin);
833	      post_stat_thinking();
834	      return 0;
835	    }
836	  
837	  ungetc(c, stdin);
838	  
839	  if (!is_pondering) return 0; 
840	  
841	  return 1;
842	}
843      if (dw)
844	{
845	  c = getc(stdin);
846	  
847	  if (c == '?')   /*Move now*/
848	    {
849	      return 1;
850	    }
851	  else if (c == '.')     /* Stat request */
852	    {
853	      getc(stdin);
854	      post_stat_thinking();
855	      return 0;
856	    }
857	  
858	  ungetc(c, stdin);
859	  
860	  if (!is_pondering) return 0; 
861	  
862	  return 1;
863	}
864      else return 0;
865    } else {
866      GetNumberOfConsoleInputEvents(inh, &dw);
867      if (dw <= 1)
868	{ 
869	  return 0; 
870	}
871      else 
872	{ 
873	  c = getc(stdin);
874
875	  if (c == '?')   /*Move now*/
876	    {
877	      return 1;
878	    }
879	  else if (c == '.')     /* Stat request */
880	    {
881	      getc(stdin);
882	      post_stat_thinking();
883	      return 0;
884	    }
885	  
886	  ungetc(c, stdin);
887	  
888	  if (!is_pondering) return 0; 
889	  
890	  return 1;
891	};
892   }
893  }
894#else
895#endif
896#endif
897
898  return 0;
899}
900
Compiler says: In function 'bioskey':
799: error: parse error before 'else'
894:2: #else after #else
768:1: the conditional began here
In function 'interrupt':
899: parse error at end of input

It was doing 3 ply and then stopping the search before, now Im not sure what to do next, except to try and debug the code a bit. I could use any advice about where these parse errors, etc.. might be caused.
Dang, had to put in the line numbers!
outAtime
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Ponder

Post by outAtime »

Im going to look into the timeout.
outAtime
Ron Murawski
Posts: 397
Joined: Sun Oct 29, 2006 4:38 am
Location: Schenectady, NY

Re: Ponder

Post by Ron Murawski »

outAtime wrote:I really dont know where to find that. Im surprised it even worked to 3 ply the first time, actually. Ive been trying to update with some different code, but Im getting parse errors and stuff when I try to compile it.

Code: Select all

762 int interrupt(void)
763 {
764   int c;
765     
766 #ifndef ANSI
767
768 #ifndef WIN32
769
770 int bioskey (void) {
771
772  fd_set readfds;
773
774  FD_ZERO (&readfds);
775  FD_SET (fileno (stdin), &readfds);
776  tv.tv_sec=0; tv.tv_usec=0;
777  select (16, &readfds, 0, 0, &tv);
778  if (FD_ISSET (fileno (stdin), &readfds));
779    {
780      c = getc(stdin);
781
782      if (c == '?')   /*Move now*/
783	{
784	  return 1;
785	}
786      else if (c == '.')     /* Stat request */
787	{
788	  getc(stdin);
789	  post_stat_thinking();
790	  return 0;
791	}
792
793      ungetc(c, stdin);
794
795      if (!is_pondering) return 0; 
796
797      return 1;
798    }
799   else return 0;
800#else
801#undef frame
802#include <windows.h>
803#define frame 0
804
805  int bioskey (void) {
806
807  static int init = 0, pipe;
808  static HANDLE inh;
809  DWORD dw;
810  if(xb_mode) {     // winboard interrupt code taken from crafty
811    if (!init) {
812      init = 1;
813      inh = GetStdHandle(STD_INPUT_HANDLE);
814      pipe = !GetConsoleMode(inh, &dw);
815      if (!pipe) {
816	SetConsoleMode(inh, dw &  ~(ENABLE_MOUSE_INPUT|ENABLE_WINDOW_INPUT));
817	FlushConsoleInputBuffer(inh);
818	FlushConsoleInputBuffer(inh);
819      }
820    }
821    if(pipe) {
822      if(!PeekNamedPipe(inh, NULL, 0, NULL, &dw, NULL)) 
823	{
824	  c = getc(stdin);
825
826	  if (c == '?')   /*Move now*/
827	    {
828	      return 1;
829	    }
830	  else if (c == '.')     /* Stat request */
831	    {
832	      getc(stdin);
833	      post_stat_thinking();
834	      return 0;
835	    }
836	  
837	  ungetc(c, stdin);
838	  
839	  if (!is_pondering) return 0; 
840	  
841	  return 1;
842	}
843      if (dw)
844	{
845	  c = getc(stdin);
846	  
847	  if (c == '?')   /*Move now*/
848	    {
849	      return 1;
850	    }
851	  else if (c == '.')     /* Stat request */
852	    {
853	      getc(stdin);
854	      post_stat_thinking();
855	      return 0;
856	    }
857	  
858	  ungetc(c, stdin);
859	  
860	  if (!is_pondering) return 0; 
861	  
862	  return 1;
863	}
864      else return 0;
865    } else {
866      GetNumberOfConsoleInputEvents(inh, &dw);
867      if (dw <= 1)
868	{ 
869	  return 0; 
870	}
871      else 
872	{ 
873	  c = getc(stdin);
874
875	  if (c == '?')   /*Move now*/
876	    {
877	      return 1;
878	    }
879	  else if (c == '.')     /* Stat request */
880	    {
881	      getc(stdin);
882	      post_stat_thinking();
883	      return 0;
884	    }
885	  
886	  ungetc(c, stdin);
887	  
888	  if (!is_pondering) return 0; 
889	  
890	  return 1;
891	};
892   }
893  }
894#else
895#endif
896#endif
897
898  return 0;
899}
900
Compiler says: In function 'bioskey':
799: error: parse error before 'else'
894:2: #else after #else
768:1: the conditional began here
In function 'interrupt':
899: parse error at end of input

It was doing 3 ply and then stopping the search before, now Im not sure what to do next, except to try and debug the code a bit. I could use any advice about where these parse errors, etc.. might be caused.
Dang, had to put in the line numbers!
Line 778 has an extraneous semicolon

Ron