Check out Atomic Chess, our featured variant for November, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

how do you program a non-capture move[Subject Thread] [Add Response]
🕸Fergus Duniho wrote on Fri, Aug 16 04:03 PM UTC in reply to wdtr2 from Sat Jul 20 09:48 AM:

The elephant to me is a diagonal mover. It may leap 1 or two squares. I want to make a variant of the elephant that has the ability to change its diagonal color (checkered board). The changing of color is a special move.

I think the original suggestions I gave were mistaken.

def White_Elephant checkaleap #0 #1 0 -1 and cond empty #0 capture empty #1 or checkleap #0 #1 2 2;

def White_Elephant checkaleap #0 #1 0 -1 and cond empty #0 not capture empty #1 or checkleap #0 #1 2 2 or checkleap #0 #1 1 1;

def Black_Elephant checkaleap #0 #1 0 1 and cond empty #0 capture empty #1 or checkleap #0 #1 2 2;

def Black_Elephant checkaleap #0 #1 0 1 and cond empty #0 not capture empty #1 or checkleap #0 #1 2 2 or checkleap #0 #1 1 1;

So each one first checks whether the move is a diagonal leap of one or two spaces. If it is not, it checks the condition "cond empty #0 not capture empty #1". If the origin space is empty, it is checking an actual move. So it checks whether a capture has already been made. If the origin space is not empty, it is checking a potential move. So it checks whether the destination space is still empty. If it turns out to be a capturing move, the function immediately returns false. Otherwise, it evaluates whether it is a one-space move vertically backwards.