Anyway - i've updated the Phalanx homepage , including Jims zip archive and a note about it's status. The short of it is both versions have bugs
http://phalanx.sourceforge.net/
I'd recommend using JA's for Windows hosted tournaments and Andoid of course.
Josh - perhaps try passing this arg "-p+" , or ensuring ponder/"hard" is enabled. I don't think it plays well at per-move time controls, but seems to go ok for me otherwise.
Phalanx source code
Moderators: hgm, Rebel, chrisw
-
- Posts: 608
- Joined: Wed Oct 13, 2010 9:44 am
- Location: Australia
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: Phalanx source code
Yes it does. Here's my code from DiscoCheck 3.7.1 (POSIX and Windows)stevenaaus wrote:Jim is right. Moreover, i spent hours looking for win32 polling code on the web, and it doesn't seem to exist
Code: Select all
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#include <conio.h>
#else // assume POSIX
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#endif
...
bool input_available()
{
#if defined(_WIN32) || defined(_WIN64)
static bool init = false, is_pipe;
static HANDLE stdin_h;
DWORD val;
if (!init) {
init = true;
stdin_h = GetStdHandle(STD_INPUT_HANDLE);
is_pipe = !GetConsoleMode(stdin_h, &val);
}
if (stdin->_cnt > 0)
return true;
if (is_pipe)
return !PeekNamedPipe(stdin_h, NULL, 0, NULL, &val, NULL) ? true : val>0;
else
return _kbhit();
#else // assume POSIX
fd_set readfds;
FD_ZERO(&readfds);
FD_SET(STDIN_FILENO, &readfds);
struct timeval timeout;
timeout.tv_sec = timeout.tv_usec = 0;
select(STDIN_FILENO+1, &readfds, 0, 0, &timeout);
return FD_ISSET(STDIN_FILENO, &readfds);
#endif
}
-
- Posts: 608
- Joined: Wed Oct 13, 2010 9:44 am
- Location: Australia
Re: Phalanx source code
Thanks Lucas. Yes - Jim had found this code and (a slight variation of) it is in phalanx subversion - but we have related bug somewhere else in the code.
When one makes a move in Scid/Scid vs PC with the "+" sign, the engine does not see the updated line/the IO is not working properly, and Phalanx continues to give PV for the old position. .. This bug is described in this thread somewhere above.
I'm not an engine programmer or win32 coder and i don't have a windows dev environement (i cross compile), so finding it is tough for me.
I just tried applying your slightly different code (patch) and it doesn't make any diff to phalanx.
And i just gave Discocheck 3.6.2 a quick cross compile,
but it works fine, and doesn't evidence our bug.
Diff for Lucas implementation (no change)
Existing phalanx win32-only bug:
When one makes a move in Scid/Scid vs PC with the "+" sign, the engine does not see the updated line/the IO is not working properly, and Phalanx continues to give PV for the old position. .. This bug is described in this thread somewhere above.
I'm not an engine programmer or win32 coder and i don't have a windows dev environement (i cross compile), so finding it is tough for me.
I just tried applying your slightly different code (patch) and it doesn't make any diff to phalanx.
And i just gave Discocheck 3.6.2 a quick cross compile,
but it works fine, and doesn't evidence our bug.
Diff for Lucas implementation (no change)
Code: Select all
--- evaluate.c 2012-08-30 18:05:44.000000000 +1000
+++ evaluate.c.lucas 2012-08-30 18:05:39.000000000 +1000
@@ -305,9 +305,6 @@
/* If we're running under XBoard then we can't use _kbhit() as the input commands
* are sent to us directly over the internal pipe */
if (Flag.xboard) {
-#if defined(FILE_CNT)
- if (stdin->_cnt > 0) return stdin->_cnt;
-#endif
if (!init) {
init = 1;
inh = GetStdHandle(STD_INPUT_HANDLE);
@@ -317,13 +314,17 @@
FlushConsoleInputBuffer(inh);
}
}
+
+ if (stdin->_cnt > 0) return stdin->_cnt;
+
if (pipe) {
if (!PeekNamedPipe(inh, NULL, 0, NULL, &dw, NULL)) return 1;
return dw;
}
else {
- GetNumberOfConsoleInputEvents(inh, &dw);
- return dw <= 1 ? 0 : dw;
+ return _kbhit();
+ // GetNumberOfConsoleInputEvents(inh, &dw);
+ // return dw <= 1 ? 0 : dw;
}
}
else return _kbhit();
Code: Select all
These four commands don't reset the analysis under windows, though they are fine under Linux
Engine: 8 -1 91 384451 Pf5xe4 Pd2-d4 Ng8-f6
Engine: 9 1 233 919440 Pf5xe4 Pd2-d3 Ng8-f6 Pd3xe4 Pe7-e6 Bc1-g5 Ph7-h6 Bg5xf6 Qd8xf6 Nb1-c3 Bf8-a3
Engine: 9 1 350 1357705 Pf5xe4 Pd2-d3 Ng8-f6 Pd3xe4 Pe7-e6 Bc1-g5 Ph7-h6 Bg5xf6 Qd8xf6 Nb1-c3 Bf8-a3
Scid : exit
Scid : force
Scid : setboard rnbqkbnr/ppppp1pp/8/8/4p3/7P/PPPP1PP1/RNBQKBNR w KQkq - 0 3
Scid : analyze
Engine: 10 10 712 3127860 Pf5xe4 Pd2-d3 Pe4xd3 Bf1xd3 Ng8-f6 Ng1-f3 Nb8-c6 O-O Pd7-d5 Bc1-f4 Pe7-e6
Engine: 10 10 937 3885625 Pf5xe4 Pd2-d3 Pe4xd3 Bf1xd3 Ng8-f6 Ng1-f3 Nb8-c6 O-O Pd7-d5 Bc1-f4 Pe7-e6
-
- Posts: 608
- Joined: Wed Oct 13, 2010 9:44 am
- Location: Australia
Re: Phalanx source code
Ok - the cause of the bug is some issue with the "interrupt" proc.
This proc is getting called in Linux, but not in WIN32.
I tried changing all Jim's "signal(SIGINT, handleSigint);" to "signal(SIGINT,interrupt);" but it didn't work, so i'm assuming that on WIN32, io.c::interrupt() is getting replaced by a system call.
Sorry, but i'm unfamiliar with the signal command. Any idea about fixing this.
Code: Select all
void interrupt(int x)
{
int c;
signal(SIGINT,SIG_IGN);
if( Flag.polling )
{
/* ignore lines that begin with '.' */
c=getc(stdin); ungetc(c,stdin);
if( c=='.' ) { fgets(Inp,255,stdin); goto go_on; }
}
if( Flag.ponder < 2 )
{
puts("interrupted");
Abort = 1;
goto go_on;
}
while( command() ) {}
go_on:;
if( !Abort && !Flag.polling )
#if defined(_WIN32)
signal(SIGINT, handleSigint);
#else
signal(SIGINT,interrupt);
#endif
}
I tried changing all Jim's "signal(SIGINT, handleSigint);" to "signal(SIGINT,interrupt);" but it didn't work, so i'm assuming that on WIN32, io.c::interrupt() is getting replaced by a system call.
Sorry, but i'm unfamiliar with the signal command. Any idea about fixing this.
-
- Posts: 319
- Joined: Fri Dec 18, 2009 11:40 am
- Location: Naperville, IL
Re: Phalanx source code
The signal function just installs a signal handler. I was under the impression that this wasn't necessary for Windows engines.
-
- Posts: 608
- Joined: Wed Oct 13, 2010 9:44 am
- Location: Australia
Re: Phalanx source code
Hmmm -UncombedCoconut wrote:The signal function just installs a signal handler. I was under the impression that this wasn't necessary for Windows engines.
Sounds like this is applicable.There are two reasons why WinBoard does not send the Win32 equivalent of SIGINT (which is called CTRL_C_EVENT) to local engines. First, the Win32 GNU Chess 4 port does not need it. Second, I could not find a way to get it to work. Win32 seems to be designed under the assumption that only console applications, not windowed applications, would ever want to send a CTRL_C_EVENT.
Anyway, Something in this patch of Jims (i think) makes the engine crash on windows 7, and i might revert it.
http://phalanx.svn.sourceforge.net/view ... evision=12
Also - i've updated the svn/webpage with some doco.
http://phalanx.sourceforge.net/