Any WB Shatranj engines out there?

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
hgm
Posts: 22274
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Any WB Shatranj engines out there?

Post by hgm » Thu Jul 31, 2008 7:46 pm

I recently adapted Fairy-Max to handle scoring of promoting Pawns a bit less silly in variants where they promote to useless pieces, like in Shatranj. As a consequence, it might actually now play at an acceptable level. (What also helps is that it now starts with the King in the coreect positions. :oops: ) I would like to test that against another Shatranj engine, but I coud not find any.

I thought Pulsar could do Shatranj, but the free download does not seem to include it. Just a bunch of other variant, like atomic, losers, 3checks and twokings.

Do there exist other free WinBoard Shatranj engines, or is Fairy-Max now the only one?

krazyken

Re: Any WB Shatranj engines out there?

Post by krazyken » Fri Aug 01, 2008 2:49 am

There's a python one here.

User avatar
hgm
Posts: 22274
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Any WB Shatranj engines out there?

Post by hgm » Fri Aug 01, 2008 6:25 am

Are you sure that is a Shatranj engine? From the description I got yhe impression that it is a Chess engine that is named 'Shatranj'.

krazyken

Re: Any WB Shatranj engines out there?

Post by krazyken » Fri Aug 01, 2008 6:41 am

yeah, you're probably right. :oops:

User avatar
Jim Ablett
Posts: 1327
Joined: Fri Jul 14, 2006 5:56 am
Location: London, England
Contact:

Re: Any WB Shatranj engines out there?

Post by Jim Ablett » Sat Aug 02, 2008 11:43 am

hgm wrote:I recently adapted Fairy-Max to handle scoring of promoting Pawns a bit less silly in variants where they promote to useless pieces, like in Shatranj. As a consequence, it might actually now play at an acceptable level. (What also helps is that it now starts with the King in the coreect positions. :oops: ) I would like to test that against another Shatranj engine, but I coud not find any.

I thought Pulsar could do Shatranj, but the free download does not seem to include it. Just a bunch of other variant, like atomic, losers, 3checks and twokings.

Do there exist other free WinBoard Shatranj engines, or is Fairy-Max now the only one?
Hi Harm,

Rival Chess 1.8.29 (the gui version) http://www.redhotpawn.com/rival/download/download.php
supports variant Shatranj and looking at the available source code seems to have some basic winboard support in there >

Code: Select all

[NewRival.cpp]

void
TRivalWindow::MonitorXBoard()
{
		char c;
		static char PreviousCommand[100];
		static count=0;
		count++;
					if (count>1) strcpy(PreviousCommand, command);
					scanf( "%s", command);
					if ((command[0]=='{' ||
							&#40;command&#91;0&#93;>='a' && command&#91;0&#93;<='z') ||
							&#40;command&#91;0&#93;>='A' && command&#91;0&#93;<='Z') ||
							&#40;command&#91;0&#93;>='0' && command&#91;0&#93;<='9'))) &#123;
							if &#40;Verbose&#41; writeMessage&#40;VERBOSE, "Receieved Command", count&#41;;
							if &#40;Verbose&#41; writeMessage&#40;VERBOSE, command&#41;;
					&#125;
					if &#40;strcmp&#40;"quit", command&#41;==0&#41; &#123;
						CloseWindow&#40;);
					&#125; else
					if &#40;strcmp&#40;"edit", command&#41;==0&#41; &#123;
						int colour=WHITE;
						if &#40;strcmp&#40;PreviousCommand, "a2a3")==0&#41; &#123;
							Game->Square&#91;MOVER&#93;=BLACK;
						&#125;
						int NewBoard&#91;89&#93;;
						int finished=FALSE;
						int piece=EMPTY;
						char editcom&#91;10&#93;;
						while (!finished&#41; &#123;
							scanf&#40;"%s", editcom&#41;;
							if &#40;strcmp&#40;editcom, "#")==0&#41; &#123;
								for &#40;int i=0; i<89; i++)
									NewBoard&#91;i&#93;=EMPTY;
							&#125; else
							if &#40;strcmp&#40;editcom, "c")==0&#41; &#123;
								colour=&#40;colour==WHITE ? BLACK &#58; WHITE&#41;;
							&#125; else
							if &#40;strcmp&#40;editcom, ".")==0&#41; &#123;
								finished=TRUE;
							&#125; else &#123;
								switch &#40;editcom&#91;0&#93;) &#123;
									case 'P' &#58; piece=PAWN; break;
									case 'Q' &#58; piece=QUEEN; break;
									case 'R' &#58; piece=ROOK; break;
									case 'N' &#58; piece=KNIGHT; break;
									case 'B' &#58; piece=BISHOP; break;
									case 'K' &#58; piece=KING; break;
								&#125;
								int newx=editcom&#91;1&#93;-&#40;int&#41;'a'+1;
								int newy=editcom&#91;2&#93;-&#40;int&#41;'0';
								NewBoard&#91;newx*10+newy&#93;=piece+100*&#40;colour==BLACK&#41;;
								NewBoard&#91;MOVER&#93;=Game->GetMover&#40;);
								NewBoard&#91;WROOK1MOVED&#93;=!&#40;NewBoard&#91;11&#93;==WR&#41;;// && Game->GetMover&#40;)==BLACK&#41;;
								NewBoard&#91;WROOK8MOVED&#93;=!&#40;NewBoard&#91;81&#93;==WR&#41;;// && Game->GetMover&#40;)==BLACK&#41;;
								NewBoard&#91;BROOK1MOVED&#93;=!&#40;NewBoard&#91;18&#93;==BR&#41;;// && Game->GetMover&#40;)==WHITE&#41;;
								NewBoard&#91;BROOK8MOVED&#93;=!&#40;NewBoard&#91;88&#93;==BR&#41;;// && Game->GetMover&#40;)==WHITE&#41;;
								NewBoard&#91;WKINGMOVED&#93;=!&#40;NewBoard&#91;51&#93;==WR&#41;;// && Game->GetMover&#40;)==BLACK&#41;;
								NewBoard&#91;BKINGMOVED&#93;=!&#40;NewBoard&#91;58&#93;==BR&#41;;// && Game->GetMover&#40;)==WHITE&#41;;
								NewBoard&#91;ENPAWN&#93;=0;
								NewBoard&#91;FIFTYMOVES&#93;=0;
								NewBoard&#91;MOVER&#93;=Game->GetMover&#40;);
							&#125;
						&#125;
						delete Game;
						Game=new TChessBoard&#40;NewBoard&#41;;
						Options.ComputerWhite=FALSE;
						Options.ComputerBlack=FALSE;
					&#125; else
					if &#40;strcmp&#40;"undo", command&#41;==0&#41; &#123;
//						Game->TakeBackMove&#40;);
					&#125; else
					if &#40;strcmp&#40;"time", command&#41;==0&#41; &#123;
						int hundreths;
						scanf&#40;"%i", &hundreths&#41;;
						if &#40;Verbose&#41; writeMessage&#40;VERBOSE, "I have left ", hundreths&#41;;
						// current mover is the opposition
						if &#40;Game->GetMover&#40;)==WHITE&#41; &#123;
							Game->SetBlackClock&#40;hundreths*10&#41;;
						&#125; else &#123;
							Game->SetWhiteClock&#40;hundreths*10&#41;;
						&#125;
					&#125; else
					if &#40;strcmp&#40;"otim", command&#41;==0&#41; &#123;
						int hundreths;
						scanf&#40;"%i", &hundreths&#41;;
						if &#40;Verbose&#41; writeMessage&#40;VERBOSE, "Opposition has left", hundreths&#41;;
						// current mover is the opposition
						if &#40;Game->GetMover&#40;)==WHITE&#41; &#123;
							Game->SetWhiteClock&#40;hundreths*10&#41;;
						&#125; else &#123;
							Game->SetBlackClock&#40;hundreths*10&#41;;
						&#125;
					&#125; else
					if &#40;strcmp&#40;"easy", command&#41;==0&#41; &#123;
						Options.Ponder = FALSE;
					&#125; else
					if &#40;strcmp&#40;"hard", command&#41;==0&#41; &#123;
						Options.Ponder = TRUE;
					&#125; else
					if &#40;strcmp&#40;"post", command&#41;==0&#41; &#123;
						Options.ShowAnalysis = TRUE;
					&#125; else
					if &#40;strcmp&#40;"nopost", command&#41;==0&#41; &#123;
						Options.ShowAnalysis = FALSE;
					&#125; else
					if &#40;strcmp&#40;"white", command&#41;==0&#41; &#123;
						Options.ComputerBlack = TRUE;
						Options.ComputerWhite = FALSE;
						Game->Square&#91;MOVER&#93;=WHITE;
					&#125; else
					if &#40;strcmp&#40;"black", command&#41;==0&#41; &#123;
						Options.ComputerWhite = TRUE;
						Options.ComputerBlack = FALSE;
						Game->Square&#91;MOVER&#93;=BLACK;
					&#125; else
					if &#40;strcmp&#40;"draw", command&#41;==0&#41; &#123;
						if &#40;IsDrawPosition&#40;)) &#123;
							WriteXBoard&#40; "offer draw\n" );
						&#125;
					&#125; else
					if &#40;strcmp&#40;"level", command&#41;==0&#41; &#123;
						int moves, minutes, increment;
						scanf&#40;"%i", &moves&#41;;
						scanf&#40;"%i", &minutes&#41;;
						scanf&#40;"%i", &increment&#41;;
						Options.Level = 2;
						Options.ChampMoves=moves;
						Options.ChampTime=minutes*60;
						Options.BaseMinutes=minutes;
						Options.Increment=increment;
						if &#40;moves==0&#41; &#123;
							searchmethod=Options.SearchMethod=BASEINCREMENT;
						&#125; else &#123;
							searchmethod=Options.SearchMethod=CHAMPIONSHIP;
						&#125;
						if &#40;Verbose&#41; writeMessage&#40;VERBOSE, "ChampTime", Options.ChampTime&#41;;
						if &#40;Verbose&#41; writeMessage&#40;VERBOSE, "ChampMoves", Options.ChampMoves&#41;;
					&#125; else
					if &#40;strcmp&#40;"force", command&#41;==0&#41; &#123;
						Options.ComputerWhite=false;
						Options.ComputerBlack=false;
					&#125; else
					if &#40;strcmp&#40;"new", command&#41;==0&#41; &#123;
						CmNewGame&#40;);
					&#125; else
					if &#40;strcmp&#40;"go", command&#41;==0&#41; &#123;
							if (!GameOver&#40;)) &#123;
								if &#40;Game->GetMover&#40;)==WHITE&#41; &#123;
									Options.ComputerWhite=true;
                           Options.ComputerBlack=false;
								&#125; else &#123;
									Options.ComputerBlack=true;
									Options.ComputerWhite=false;
								&#125;
								if (&#40;Options.ComputerWhite && Game->GetMover&#40;)==WHITE&#41; ||
									 &#40;Options.ComputerBlack && Game->GetMover&#40;)==BLACK&#41;) &#123;
								  if &#40;Options.Ponder&#41; ComputerMoveFlag = TRUE;
									else ComputerMove&#40;);
								&#125;
							&#125;
					&#125; else
					if (	command&#91;0&#93;>='a' && command&#91;0&#93;<='h' &&
							command&#91;1&#93;>='1' && command&#91;1&#93;<='8' &&
							command&#91;2&#93;>='a' && command&#91;2&#93;<='h' &&
							command&#91;3&#93;>='1' && command&#91;3&#93;<='8') &#123;
							int x1 = command&#91;0&#93;-&#40;int&#41;'a'+1;
							int y1 = command&#91;1&#93;-&#40;int&#41;'0';
							int x2 = command&#91;2&#93;-&#40;int&#41;'a'+1;
							int y2 = command&#91;3&#93;-&#40;int&#41;'0';
							TPoint p1&#40;	BoardOffsetX+5+&#40;Pawn->Width&#40;)*&#40;x1-1&#41;),
											BoardOffsetY+5+&#40;Pawn->Height&#40;)*&#40;8-y1&#41;));
							TPoint p2&#40;	BoardOffsetX+5+&#40;Pawn->Width&#40;)*&#40;x2-1&#41;),
											BoardOffsetY+5+&#40;Pawn->Height&#40;)*&#40;8-y2&#41;));
							if &#40;command&#91;4&#93;=='q' || command&#91;4&#93;=='Q') Select.PromotionPiece=QUEEN;
							if &#40;command&#91;4&#93;=='r' || command&#91;4&#93;=='R') Select.PromotionPiece=ROOK;
							if &#40;command&#91;4&#93;=='b' || command&#91;4&#93;=='B') Select.PromotionPiece=BISHOP;
							if &#40;command&#91;4&#93;=='n' || command&#91;4&#93;=='N') Select.PromotionPiece=KNIGHT;
							if &#40;Verbose&#41; &#123;
								int s1x=&#40;p1.x-BoardOffsetX&#41;/Pawn->Width&#40;)+1;
								int s1y=8-(&#40;p1.y-BoardOffsetY&#41;/Pawn->Height&#40;));
								int s2x=&#40;p2.x-BoardOffsetX&#41;/Pawn->Width&#40;)+1;
								int s2y=8-(&#40;p2.y-BoardOffsetY&#41;/Pawn->Height&#40;));
								FILE *log = fopen&#40;VERBOSE, "a");
								fprintf&#40; log, "\nMaking opposition move&#58; %c%c-%c%c-%c with %i%i-%i%i-%i\n",
									&#40;char&#41;x1+'a'-1, &#40;char&#41;y1+'0', &#40;char&#41;x2+'a'-1, &#40;char&#41;y2+'0', command&#91;4&#93;,
									s1x,s1y,s2x,s2y, Select.PromotionPiece );
								fclose&#40;log&#41;;
							&#125;
							Select.From = x1*10+y1;
							Select.To = x2*10+y2;
							if &#40;Game->VerifyMove&#40;Select&#41;==0&#41; &#123;
								MakeMove&#40;Game, Select&#41;;
							&#125; else &#123;
								char error&#91;200&#93;;
								char reason&#91;200&#93;;
								GetReason&#40;Game->VerifyMove&#40;Select&#41;, reason&#41;;
								sprintf&#40;error, "Illegal move (%s&#41;&#58; %c%c%c%c%c",
									reason,
									command&#91;0&#93;,
									command&#91;1&#93;,
									command&#91;2&#93;,
									command&#91;3&#93;,
									&#40;strlen&#40;command&#41;>4 ? command&#91;4&#93; &#58; ' '));
								WriteXBoard&#40;error&#41;;
							&#125;
							if (&#40;Game->GetMover&#40;)==WHITE && Options.ComputerWhite&#41;
								|| &#40;Game->GetMover&#40;)==BLACK && Options.ComputerBlack&#41;)
							makeWinboardComputerMove&#40;);
					&#125;
&#125;
Maybe you could tinker with it and get it to work.

Jim.

User avatar
Jim Ablett
Posts: 1327
Joined: Fri Jul 14, 2006 5:56 am
Location: London, England
Contact:

Re: Any WB Shatranj engines out there?

Post by Jim Ablett » Sat Aug 02, 2008 11:49 am

I just read the readme that is installed with the gui version and winboard support is there, but I can't get it to work.
As of v1.5.03, Rival can analyse the winboard.debug file and report the number of
wins for each side following a multi-match game.

To allow Rival to act as an engine for the Winboard interface:

newrival -winboard

Add the following line to the /firstChessProgramNames section of the winboard.ini file.

\"newrival -winboard\" /fd=\"c:\\Program Files\\RivalChess\"

The following is an example of how to run Rival on an ICS, such as the Internet Chess Club.

winboard -zp -ics -icshost chessclub.com -autoflag -fcp "newrival -winboard" -icshelper timestamp

Using the above command you can log into the ICC and type "seek 2 5", for example. Use the
ICC command "+alias gameend seek 2 5" to allow the program to play unattended.

An example of how to launch Winboard for two engines to play each other 50 times is

winboard /cp /tc 1 /inc 2 /mg 50

...you can then select the two engines from the Winboard front screen.

Rival does not support all Winboard commands. The following Winboard
commands are supported when recieved by Rival:
new
white
black
go
level
time
otim
move
draw
quit
edit
post
nopost
easy
hard

Rival sends out the following commands to Winboard:
move MOVE
offer draw
1-0 {White Mates}
0-1 {Black Mates}
1/2-1/2 {Stalemate}
1/2-1/2 {Draw by Repetition}
1/2-1/2 {Draw by Fifty Moves}
Illegal move (reason): move
Jim.

User avatar
Jim Ablett
Posts: 1327
Joined: Fri Jul 14, 2006 5:56 am
Location: London, England
Contact:

Re: Any WB Shatranj engines out there?

Post by Jim Ablett » Sun Aug 03, 2008 11:59 pm

Hi Harm,

I've added Shatranj support to Dabbaba. :)
Before I release it I want to make sure I've implemented everything necessary.
Two features I haven't added yet are 'checkmate by isolation' rule and 'checkmate by stalemate' rule.
Do I need to implement these in the engine, or does Winboard-F handle this itself?

Jim.

User avatar
hgm
Posts: 22274
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Any WB Shatranj engines out there?

Post by hgm » Mon Aug 04, 2008 6:55 am

Unfortunately, WinBoard does not implement these either. In any case the isolation rule. (I would have to check the code to see if it does the stalemate rule; I am pretty sure I implemented this for Xiangqi, and it would have been pretty illogical not to have tested for Shatranj at the same time.) I guess it should not be that difficult to implement the isolation rule, as there is already code there to count number of pieces for the purpose of adjudicating insufficient-material draws. I just would have to build in the delay of one move. (Which is only relevant in 2:1 positions.)

I haven't implemented those rules in Fairy-Max either; I wonder how important they really are for strategy. Stalemate is only likely when you are already down to a bare King, and that would already be a win in the first place. Fairy-Max is materialistic enough to bare the opponent anyway, if he gets the chance. But I did rely on the GUI then to declare the gme a win. (Which is what it does when playing on ICC.)

User avatar
Jim Ablett
Posts: 1327
Joined: Fri Jul 14, 2006 5:56 am
Location: London, England
Contact:

Re: Any WB Shatranj engines out there?

Post by Jim Ablett » Mon Aug 04, 2008 11:07 am

Hi Harm,

Here's the new version of Dabbaba (v1.21) with Shatranj support.

http://www.zshare.net/download/1650145823010304/

regards,
Jim.

User avatar
hgm
Posts: 22274
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Any WB Shatranj engines out there?

Post by hgm » Tue Aug 05, 2008 11:01 am

Well, thanks for your efforts, but it doesn't quite seem to work. Dabbaba insists on starting with an illegal move in shatranj (e2-e4).

Post Reply