Phalanx source code

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

stevenaaus
Posts: 613
Joined: Wed Oct 13, 2010 9:44 am
Location: Australia

Re: Phalanx source code

Post by stevenaaus »

lucasart wrote:
Here's what I have, although I've never tested it as I don't use windows (according to function specs on microsoft.com it should work)

Code: Select all

bool input_available()
{
#ifdef 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);

#else	// assume windows

	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();
	
#endif
}
This is very similar/identical to JIm's/Olithink's solution, and unfortunately has the same bug on my winXP box.
Olithink *does* work properly on winXP though, so the solution is there somewhere. :?
Elorejano
Posts: 121
Joined: Sat Mar 20, 2010 3:31 am

Re: Phalanx source code

Post by Elorejano »

Hi, again!
I couldnt compile the new source (Jim´s + Miguel bugfixed) with Visual Studio (give me 97 errors).
Furthemore, it is posible that Phalanx dont have implemented all winboard protocol?
Master Jim???
Thanks in advance
User avatar
Jim Ablett
Posts: 2291
Joined: Fri Jul 14, 2006 7:56 am
Location: London, England
Full name: Jim Ablett

Re: Phalanx source code

Post by Jim Ablett »

Elorejano wrote:Hi, again!
I couldnt compile the new source (Jim´s + Miguel bugfixed) with Visual Studio (give me 97 errors).
Furthemore, it is posible that Phalanx dont have implemented all winboard protocol?
Master Jim???
Thanks in advance

I've fixed the code to compile with Msvc. (includes Miguel's time fix & illegal move error messages fix)

Here's are my complete msvc 2005 project files >
http://dl.dropbox.com/u/5047625/phalanx ... roject.zip

Jim.
stevenaaus
Posts: 613
Joined: Wed Oct 13, 2010 9:44 am
Location: Australia

Re: Phalanx source code

Post by stevenaaus »

Ok, all of Jim's changes from the last link are in sourceforge's phalanx subversion. (I made a few formatting changes, and removed the 'JA' from #define VERSION).

Using this version as a base would be nice.
Can get it by

Code: Select all

svn co https://phalanx.svn.sourceforge.net/svnroot/phalanx phalanx


I added phalanx.vcproj to the src directory. There were many other files in the zip. Are any of these others essential for compiling with msvc ?
User avatar
Jim Ablett
Posts: 2291
Joined: Fri Jul 14, 2006 7:56 am
Location: London, England
Full name: Jim Ablett

Re: Phalanx source code

Post by Jim Ablett »

stevenaaus wrote:Ok, all of Jim's changes from the last link are in sourceforge's phalanx subversion. (I made a few formatting changes, and removed the 'JA' from #define VERSION).

Using this version as a base would be nice.
Can get it by

Code: Select all

svn co https://phalanx.svn.sourceforge.net/svnroot/phalanx phalanx


I added phalanx.vcproj to the src directory. There were many other files in the zip. Are any of these others essential for compiling with msvc ?
Hi Steven,

GETOPT.C is only extra file needed by Msvc. This will be ignored by other compilers. All other extra files here are created by Msvc for project.

Jim.
Elorejano
Posts: 121
Joined: Sat Mar 20, 2010 3:31 am

Re: Phalanx source code

Post by Elorejano »

Thanks, Jim!
I will try.
Results later
stevenaaus
Posts: 613
Joined: Wed Oct 13, 2010 9:44 am
Location: Australia

Re: Phalanx source code

Post by stevenaaus »

Jim Ablett wrote: GETOPT.C is only extra file needed by Msvc. This will be ignored by other compilers. All other extra files here are created by Msvc for project.
Jim.
Ok - getopt.c should already be there. I was guessing the case wouldn't matter because it being microsoft, but I've now edited phalanx.vcproj:

- RelativePath=".\src\GETOPT.C"
+ RelativePath=".\src\getopt.c"
Elorejano
Posts: 121
Joined: Sat Mar 20, 2010 3:31 am

Re: Phalanx source code

Post by Elorejano »

I discover the "big" bug.
With ponder=off, Phalanx plays right (dont have any lose in time with Miguel´s fix).
But with ponder=on, Phalanx seems to freeze..so its not (and was not) a TM problem.
Masters?
Thanks in advance
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: Phalanx source code

Post by michiguel »

Elorejano wrote:I discover the "big" bug.
With ponder=off, Phalanx plays right (dont have any lose in time with Miguel´s fix).
But with ponder=on, Phalanx seems to freeze..so its not (and was not) a TM problem.
Masters?
Thanks in advance
Makes sense because I never played Phalanx with ponder=on. I made the changes so it could play really fast games without losing on time.

Miguel
stevenaaus
Posts: 613
Joined: Wed Oct 13, 2010 9:44 am
Location: Australia

Re: Phalanx source code

Post by stevenaaus »

Phalanx does not implement the xboard "ponder" command, so put this is on the todo list :)

It does have the "-p+" option for permanent thinking (which is the same as ponder i suppose), but in my testing on Linux, the time control is unaffected.
I really should find time to test it properly on Windows and/or with Xboard.