Question about "shuffle" and "nocastle"

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

Moderator: Ras

Volker Pittlik
Posts: 628
Joined: Wed Mar 08, 2006 9:10 pm
Location: Murten / Morat, Switzerland
Full name: Volker Pittlik

Question about "shuffle" and "nocastle"

Post by Volker Pittlik »

In Fischer Random Chess the opening position for black and white has to be mirrored. Is that true for the shuffle and nocastle variant as well?

Or is this:

[d]qbbrnnrk/pppppppp/8/8/8/8/PPPPPPPP/RRKNBQBN w - - 0 1

a valid opening position for the shuffle variation?

Shouldn't not all engines with an implemented "setboard" option be able to play a game from that position?


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

Re: Question about "shuffle" and "nocastle&am

Post by hgm »

The consept "wild" on an ICS is a bit different from that of an XBoard "variant". Most of the time wilds are just normal Chess not starting from the canonical opening position. Very often, but not always, the position is reachable from the opening position. XBoard indeed maps all such wilds on the single variant "normal".

Now variant "nocastle" is basically normal Chess where you initially had no castling rights. The only reason that XBoard considers it a different variant from "normal" is historical: in WB protocol v1 there is no way to tell an engine the catling rights. If a Rook & King would happen to start in the normal place in "nocastle", a v1 engine would think it could castle with them. Rather than extending the protocol with castling rights, the kludge was used to add a new variant, and send it that. But v2 engines that support the "setboard" command have no need for variant "nocastle", and could play the games just as well as variant "normal".

After this lengthy introduction, I get to your first question. There are several ICS wilds that translate to "nocastle", with different initial positions: wild 2, 3 and 4. IIRC in wild/2 the white and black positions are each other's mirror image, but in wild/3 they are shuffled independently. In wild/4 they are again mirror images, but now it is not so much a shuffle as that it is randomly decided per square what piece you get there. So you could start with multiple Queens, or three Bishops all on the same color, or whatever, with the only restriction that you get exactly one King.

Note that normal, wildcastle (wild 1) and nocastle (wild 2 and 3) are all sing positions that could also occur in FRC. Wild 4 is weirder, and I could imagine that some engines could not play it because they can handle at most two Knights, Bishops and Rooks.
Volker Pittlik
Posts: 628
Joined: Wed Mar 08, 2006 9:10 pm
Location: Murten / Morat, Switzerland
Full name: Volker Pittlik

Re: Question about "shuffle" and "nocastle&am

Post by Volker Pittlik »

Thanks. I'll implement something most similar to "wild2". As you wrote all xboard v2 engine as well as all UCIs should play that.

vp
User avatar
David Dahlem
Posts: 900
Joined: Wed Mar 08, 2006 9:06 pm

Re: Question about "shuffle" and "nocastle&am

Post by David Dahlem »

How are wild2, wild3, and wild4 positions generated?
Volker Pittlik
Posts: 628
Joined: Wed Mar 08, 2006 9:10 pm
Location: Murten / Morat, Switzerland
Full name: Volker Pittlik

Re: Question about "shuffle" and "nocastle&am

Post by Volker Pittlik »

David Dahlem wrote:How are wild2, wild3, and wild4 positions generated?
I use a bash script for wild2 and use another script I use for playing tests and tournaments to set the position up. I can post it if you like. It should be usable in windows with the help of cygwin, but it is untested. Warning: so far this script is for my personal use so it is not designed to win a price for nice coding.

vp
User avatar
David Dahlem
Posts: 900
Joined: Wed Mar 08, 2006 9:06 pm

Re: Question about "shuffle" and "nocastle&am

Post by David Dahlem »

Volker Pittlik wrote:
David Dahlem wrote:How are wild2, wild3, and wild4 positions generated?
I use a bash script for wild2 and use another script I use for playing tests and tournaments to set the position up. I can post it if you like. It should be usable in windows with the help of cygwin, but it is untested. Warning: so far this script is for my personal use so it is not designed to win a price for nice coding.

vp
Yes, please post your script, if you don't mind. :)
Volker Pittlik
Posts: 628
Joined: Wed Mar 08, 2006 9:10 pm
Location: Murten / Morat, Switzerland
Full name: Volker Pittlik

Re: Question about "shuffle" and "nocastle&am

Post by Volker Pittlik »

David Dahlem wrote:...
Yes, please post your script, if you don't mind. :)
I'm going to extend it for some other wild versions if my interest for this variants continue.

vp

Code: Select all

#! /bin/bash
# Generate an opening position for the "wild2" chess variant
# change the follwing for you needs (for example if you use windows).
savepos=/tmp/wild2.fen
f1=" "; f2=" "; f3=" "; f4=" "; f5=" "; f6=" "; f7=" "; f8=" "
# find position for kings
piece="k"
file=$[$RANDOM%8+1]
case $file in
	1) f1="$piece" ;;
	2) f2="$piece" ;;
	3) f3="$piece" ;;
	4) f4="$piece" ;;
	5) f5="$piece" ;;
	6) f6="$piece" ;;
	7) f7="$piece" ;;
	8) f8="$piece" ;;
	*) echo "bug in "nocastle". file: $file, 1"; exit 1 ;;
esac
# queens
piece="q"
while true
do
	file=$[$RANDOM%8+1]
	case $file in
# method is identical for all following pieces. Therefore written down once
# "correctly" then saving some space.
		1) 	if [ "$f1" = " " ]
			then
				f1="$piece"
				break
			else
				continue
			fi ;;
		2) 	if [ "$f2" = " " ]; then f2="$piece"; break
			else continue; fi ;;
		3) 	if [ "$f3" = " " ]; then f3="$piece"; break
			else continue; fi ;;
		4) 	if [ "$f4" = " " ]; then f4="$piece"; break
			else continue; fi ;;
		5) 	if [ "$f5" = " " ]; then f5="$piece"; break
			else continue; fi ;;
		6) 	if [ "$f6" = " " ]; then f6="$piece"; break
			else continue; fi ;;
		7) 	if [ "$f7" = " " ]; then f7="$piece"; break
			else continue; fi ;;
		8) 	if [ "$f8" = " " ]; then f8="$piece"; break
			else continue; fi ;;
		*) 	echo "bug in "nocastle". file: $file, 2"; exit 1 ;;
	esac
done
# 2 rooks now
piece="r"
while true
do
	file=$[$RANDOM%8+1]
	case $file in
		1) 	if [ "$f1" = " " ]; then f1="$piece"; break
			else continue; fi ;;
		2) 	if [ "$f2" = " " ]; then f2="$piece"; break
			else continue; fi ;;
		3) 	if [ "$f3" = " " ]; then f3="$piece"; break
			else continue; fi ;;
		4) 	if [ "$f4" = " " ]; then f4="$piece"; break
			else continue; fi ;;
		5) 	if [ "$f5" = " " ]; then f5="$piece"; break
			else continue; fi ;;
		6) 	if [ "$f6" = " " ]; then f6="$piece"; break
			else continue; fi ;;
		7) 	if [ "$f7" = " " ]; then f7="$piece"; break
			else continue; fi ;;
		8) 	if [ "$f8" = " " ]; then f8="$piece"; break
			else continue; fi ;;
		*) 	echo "bug in "nocastle". file: $file, 3"; exit 1 ;;
	esac
done
while true
do
	file=$[$RANDOM%8+1]
	case $file in
		1) 	if [ "$f1" = " " ]; then f1="$piece"; break
			else continue; fi ;;
		2) 	if [ "$f2" = " " ]; then f2="$piece"; break
			else continue; fi ;;
		3) 	if [ "$f3" = " " ]; then f3="$piece"; break
			else continue; fi ;;
		4) 	if [ "$f4" = " " ]; then f4="$piece"; break
			else continue; fi ;;
		5) 	if [ "$f5" = " " ]; then f5="$piece"; break
			else continue; fi ;;
		6) 	if [ "$f6" = " " ]; then f6="$piece"; break
			else continue; fi ;;
		7) 	if [ "$f7" = " " ]; then f7="$piece"; break
			else continue; fi ;;
		8) 	if [ "$f8" = " " ]; then f8="$piece"; break
			else continue; fi ;;
		*) 	echo "bug in "nocastle". file: $file, 4"; exit 1 ;;
	esac
done
# the bishops
piece="b"
while true
do
	file=$[$RANDOM%8+1]
	case $file in
		1) 	if [ "$f1" = " " ]; then f1="$piece"; break
			else continue; fi ;;
		2) 	if [ "$f2" = " " ]; then f2="$piece"; break
			else continue; fi ;;
		3) 	if [ "$f3" = " " ]; then f3="$piece"; break
			else continue; fi ;;
		4) 	if [ "$f4" = " " ]; then f4="$piece"; break
			else continue; fi ;;
		5) 	if [ "$f5" = " " ]; then f5="$piece"; break
			else continue; fi ;;
		6) 	if [ "$f6" = " " ]; then f6="$piece"; break
			else continue; fi ;;
		7) 	if [ "$f7" = " " ]; then f7="$piece"; break
			else continue; fi ;;
		8) 	if [ "$f8" = " " ]; then f8="$piece"; break
			else continue; fi ;;
		*) 	echo "bug in "nocastle". file: $file, 5"; exit 1 ;;
	esac
done
while true
do
	file=$[$RANDOM%8+1]
	case $file in
		1) 	if [ "$f1" = " " ]; then f1="$piece"; break
			else continue; fi ;;
		2) 	if [ "$f2" = " " ]; then f2="$piece"; break
			else continue; fi ;;
		3) 	if [ "$f3" = " " ]; then f3="$piece"; break
			else continue; fi ;;
		4) 	if [ "$f4" = " " ]; then f4="$piece"; break
			else continue; fi ;;
		5) 	if [ "$f5" = " " ]; then f5="$piece"; break
			else continue; fi ;;
		6) 	if [ "$f6" = " " ]; then f6="$piece"; break
			else continue; fi ;;
		7) 	if [ "$f7" = " " ]; then f7="$piece"; break
			else continue; fi ;;
		8) 	if [ "$f8" = " " ]; then f8="$piece"; break
			else continue; fi ;;
		*) 	echo "bug in "nocastle". file: $file, 6"; exit 1 ;;
	esac
done
# the knights
piece="n"
i=1
while [ $i -le 8 ]
do
	case $i in
		1) 	if [ "$f1" = " " ]; then f1="$piece"; fi ;;
		2) 	if [ "$f2" = " " ]; then f2="$piece"; fi ;;
		3) 	if [ "$f3" = " " ]; then f3="$piece"; fi ;;
		4) 	if [ "$f4" = " " ]; then f4="$piece"; fi ;;
		5) 	if [ "$f5" = " " ]; then f5="$piece"; fi ;;
		6) 	if [ "$f6" = " " ]; then f6="$piece"; fi ;;
		7) 	if [ "$f7" = " " ]; then f7="$piece"; fi ;;
		8) 	if [ "$f8" = " " ]; then f8="$piece"; fi ;;
		*) 	echo "bug in "nocastle". i: $i"; exit 1 ;;
	esac
	i=`expr $i + 1`
done
# mirror for black
case "$f1" in
	"k") b1="K" ;;
	"q") b1="Q" ;;
	"r") b1="R" ;;
	"b") b1="B" ;;
	"n") b1="N" ;;
	*) echo "bug in "nocastle". f1: $f1"; exit 1 ;;
esac
case $f2 in
	"k") b2="K" ;;
	"q") b2="Q" ;;
	"r") b2="R" ;;
	"b") b2="B" ;;
	"n") b2="N" ;;
	*) echo "bug in "nocastle". f2: $f2"; exit 1 ;;
esac
case $f3 in
	"k") b3="K" ;;
	"q") b3="Q" ;;
	"r") b3="R" ;;
	"b") b3="B" ;;
	"n") b3="N" ;;
	*) echo "bug in "nocastle". f3: $f3"; exit 1 ;;
esac
case $f4 in
	"k") b4="K" ;;
	"q") b4="Q" ;;
	"r") b4="R" ;;
	"b") b4="B" ;;
	"n") b4="N" ;;
	*) echo "bug in "nocastle". f4: $f4"; exit 1 ;;
esac
case $f5 in
	"k") b5="K" ;;
	"q") b5="Q" ;;
	"r") b5="R" ;;
	"b") b5="B" ;;
	"n") b5="N" ;;
	*) echo "bug in "nocastle". f5: $f5"; exit 1 ;;
esac
case $f6 in
	"k") b6="K" ;;
	"q") b6="Q" ;;
	"r") b6="R" ;;
	"b") b6="B" ;;
	"n") b6="N" ;;
	*) echo "bug in "nocastle". f6: $f6"; exit 1 ;;
esac
case $f7 in
	"k") b7="K" ;;
	"q") b7="Q" ;;
	"r") b7="R" ;;
	"b") b7="B" ;;
	"n") b7="N" ;;
	*) echo "bug in "nocastle". f7: $f7"; exit 1 ;;
esac
case $f8 in
	"k") b8="K" ;;
	"q") b8="Q" ;;
	"r") b8="R" ;;
	"b") b8="B" ;;
	"n") b8="N" ;;
	*) echo "bug in "nocastle". f8: $f8"; exit 1 ;;
esac

echo "$f1$f2$f3$f4$f5$f6$f7$f8/pppppppp/8/8/8/8/PPPPPPPP/\
$b1$b2$b3$b4$b5$b6$b7$b8 w - - 0 1" >$savepos
# coment the following out to see the fen string
#cat $savepos
User avatar
hgm
Posts: 28387
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Question about "shuffle" and "nocastle&am

Post by hgm »

Note that WinBoard / XBoard allow you to play any variant as a shuffle variant, in interactive mode. All you have to do is use the menu "New Shuffle Game" in the "File" menu, and it sets up a new (symmetric) shuffle for the currently selected variant. It is smart enough to know what to shuffle and what to leave alone, deppending on tha castling rules. If FRC castling is allowed, it leaves the King between the Rooks. If normal castling is allowed, it leaves King and Rooks in place. In nocastle (or shatranj, courier, makruk) it shuffles everything. The shuffling remains in force until you select a new variant.

It is currently not possible to set the internal variable (that is set by using the shuffle menu) through a command-line option. It would be totally trivial to add such an option, though, if there was any interest in this. e.g. a volatile (= not stored in the settings file) option -shuffleopenings that would force shuffles even if the variant is not FRC or CRC.

In this particular case (shuffled normal chess) you could of course also do

xboard -variant nocastle

Then XBoard will make the shuffle for you, according to the setting of -defaultFrcPosititon. (I.e. a new shuffle for every game if this is -1, and the same shuffle specified by the number if it is >=0.)
Volker Pittlik
Posts: 628
Joined: Wed Mar 08, 2006 9:10 pm
Location: Murten / Morat, Switzerland
Full name: Volker Pittlik

Re: Question about "shuffle" and "nocastle&am

Post by Volker Pittlik »

hgm wrote:Note that WinBoard / XBoard allow you to play any variant as a shuffle variant, in interactive mode. All you have to do is use the menu "New Shuffle Game" in the "File" menu, and it sets up a new (symmetric) shuffle for the currently selected variant... It would be totally trivial to add such an option, though, if there was any interest in this....
At the moment I don't use the interactive mode very much. My tests and tournaments are controlled by some scripts I wrote and I just got used to make changes in the scripts rather than using the menus.

For example

Code: Select all

# variant (normal, wild2)
variant=wild2
From all the other wild variants (FICS Wild) I like (besides 2) style 3, possibly 4 (although very similar to 2). You have implemented FRC in xboard so I'll test that before I extend my own scripts if necessary.

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

Re: Question about "shuffle" and "nocastle&am

Post by hgm »

And the -variant nocastle does not work because the engine says it does not know how to play nocastle? (Although in reality it does...)

I guess XBoard should not really send variant nocastle to v2 engines that support setboard. It should simply pass it off as 'normal' in that case. InBetween could solve that as well, with the rule "nocastle := normal".