Check out Alice Chess, our featured variant for June, 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 ]

Ratings & Comments

EarliestEarlier Reverse Order LaterLatest
The birth of 3 new variants - part 2 : Grand Apothecary Chess Modern[Subject Thread] [Add Response]
Aurelian Florea wrote on Wed, Jul 7, 2021 06:43 AM UTC:

@Fergus

I am trying to write the game code for 2 new pieces I want for my newest chess variants. The first, a bent rider, called the lion should move like a bishop for 2 squares and then towards outside like a rook. It may also move like a dabbabah. I have written the code bellow that has the problem that allows the final rook moves without checking for the first bishop part of the move. Please take a look:

def Lyon

fn (checkride #0 #1 1 0 and empty #0)

where #0 2 sign - file #1 file #0 2 sign - rank #1 rank #0 #1

and not fn Knight #0 #1

or and checkride #0 #1 1 1 <= distance #0 #1 2

or fn Dabbabah #0 #1;

The second, it is also a bent rider, called the tiger should move like a rook for 3 squares and then towards outside like a bishop. It may also move like an alfil. In the same way as before the bishop moves are allowed by my code whitout checking the rook ride. Code so far:

def Tiger

fn (checkride #0 #1 1 1 and empty #0)

where #0 0 * 3 sign - rank #1 rank #0 #1

or fn (checkride #0 #1 1 1 and empty #0)

where #0 * 3 sign - file #1 file #0 0 #1

and not fn Knight #0 #1

or and checkride #0 #1 1 0 <= distance #0 #1 3

or fn Elephant #0 #1;

I could not find code that block the ride in the first part.


🕸Fergus Duniho wrote on Wed, Jul 7, 2021 06:12 PM UTC in reply to Aurelian Florea from 06:43 AM:

Since Markdown altered your code by removing the multiplication operators, and HTML interprets the less than sign as the beginning of a tag, I am responding in Text. Here is your code for the Lyon: def Lyon fn (checkride #0 #1 1 0 and empty #0) where #0 * 2 sign - file #1 file #0 * 2 sign - rank #1 rank #0 #1 and not fn Knight #0 #1 or and checkride #0 #1 1 1 <= distance #0 #1 2 or fn Dabbabah #0 #1; To rule out regular Rook moves, this should fix it. This produced the correct pattern on an empty 8x8 board with e4 as the origin and also when I blocked the diagonal move at f5. def Lyon checkaride #ts #1 0 sign #rd or checkaride #ts #1 sign #fd 0 and checkride #0 #ts 1 1 and empty #ts =ts where #0 * 2 sign #fd * 2 sign #rd and match 2 abs #fd abs #rd =fd - file #1 file #0 =rd - rank #1 rank #0 or and checkride #0 #1 1 1 <= distance #0 #1 2 or fn Dabbabah #0 #1; Instead of using a lambda function, this assigns values to variables that get reused. These are rd for rank distance, fd for file distance, and ts for turning space. After calculating fd and rd, it makes sure that one of them has an absolute value of 2. It then uses them to calculate ts. After checking that ts is empty, it checks that a diagonal move from #0 to #ts is legal, and it then uses the value of fd or rd with checkaride for checking a Rook move in a specific direction from #ts to #1. It first checks for a Rook move along the file of ts. If that returns false, it then checks for a Rook move along the rank of ts. When I tried checkride #ts 1 1 0, it gave inaccurate results. The following code gave the right results on an empty board, but it gave false positives when I blocked it on f5. def Lyon fn (checkride #0 #1 1 0 and empty #0) where #0 * 2 sign - file #1 file #0 * 2 sign - rank #1 rank #0 #1 and not fn Knight #0 #1 and not checkride #0 #1 1 0 or and checkride #0 #1 1 1 <= distance #0 #1 2 or fn Dabbabah #0 #1; I will let you figure out how to fix the Tiger, since you should have more of a clue now.


🕸Fergus Duniho wrote on Wed, Jul 7, 2021 08:38 PM UTC in reply to Fergus Duniho from 06:12 PM:
This also works: def Lyon checkride #ts #1 0 1 and checkride #0 #ts 1 1 and empty #ts =ts where #0 * 2 sign #fd * 2 sign #rd and == 2 min abs #fd abs #rd =fd - file #1 file #0 =rd - rank #1 rank #0 or and checkride #0 #1 1 1 <= distance #0 #1 2 or fn Dabbabah #0 #1; There are two main changes. Instead of "and match 2 abs #fd abs #rd", it now has "and == 2 min abs #fd abs #rd". Besides checking that one value is equal to 2, it also confirms that the other value is greater than or equal to 2. This rules out spaces that could be reached by a Knight's leap. This change allows the Rook move to be checked with a single checkride instead of two different checkarides with calculated values. In the tests I ran, it gave the same results as the previous Lyon function.

🕸Fergus Duniho wrote on Wed, Jul 7, 2021 11:50 PM UTC in reply to Aurelian Florea from 06:43 AM:
Since the Tiger has an extra challenge, I thought I would try it too. The following code has been tested to work on an empty 16x16 board and with various positions blocked. def Tiger checkride #ts #1 1 1 and checkride #0 #ts 1 0 and empty #ts =ts where #0 * 3 * sign #fd == abs #rd #n * 3 * sign #rd == abs #fd #n and == #n min abs #fd abs #rd =fd - file #1 file #0 =rd - rank #1 rank #0 =n - #d 3 and > #d 3 or and checkride #0 #1 1 0 <= #d 3 =d distance #0 #1 or fn Elephant #0 #1; The challenge was in figuring out how to avoid checking two different Bishop moves. This meant figuring out the precise value for ts instead of testing two possible values for it. Within each quadrant, each possible destination could be defined as a variation on either (n, n+3) or (n+3, n). The variations would include -n or -(n+3). To get the precise value for ts, I had to identify the quadrant and which form the destination had. I could identify the quadrant through the sign of fd and rd, and I could identify the form by checking whether rd or fd had an absolute value equal to n.

Aurelian Florea wrote on Thu, Jul 8, 2021 07:46 AM UTC:

@Fergus,

Brilliant, it works and I understood them well enough to be able to make even other pieces.


Aurelian Florea wrote on Thu, Jul 8, 2021 08:28 AM UTC:

@Fergus, Now I am trying to make the castling work.

The king is supposed to be able to castle with a rook by moving 3 spaces towards it or with a cannon by moving 4 spaces towards it, Usual conditions apply. I have used the following flags and variables:

set wcastle d1 c1 j1 k1; set bcastle d12 c12 j12 k12; setflag a1 b1 k1 l1; setflag a12 b12 k12 l12;

I have 2 problems. 1.The castling moves are not shown although they work. 2. The long cannon castle is not done entirely although the king moves correctly.


🕸Fergus Duniho wrote on Thu, Jul 8, 2021 11:49 AM UTC in reply to Aurelian Florea from 08:28 AM:

Can you give me a link to the preset you're working on?


🕸Fergus Duniho wrote on Thu, Jul 8, 2021 12:18 PM UTC in reply to Aurelian Florea from 08:28 AM:

set wcastle d1 c1 j1 k1; set bcastle d12 c12 j12 k12;

From these, I gather that the King lies somewhere between d and j.

setflag a1 b1 k1 l1; setflag a12 b12 k12 l12;

But here, nothing is flagged between d and j. Make sure to flag every single piece that can castle, including the King.


Aurelian Florea wrote on Thu, Jul 8, 2021 01:20 PM UTC in reply to Fergus Duniho from 12:18 PM:

I have repeated all my tests. The same two problems appear.


🕸Fergus Duniho wrote on Thu, Jul 8, 2021 02:03 PM UTC in reply to Aurelian Florea from 08:28 AM:

Test. I keep getting the error message, "There is no comment to post."


🕸Fergus Duniho wrote on Thu, Jul 8, 2021 04:32 PM UTC in reply to Aurelian Florea from 08:28 AM:
  1. The long cannon castle is not done entirely although the king moves correctly.

You don't seem to be unflagging spaces properly. I confirmed that you left the Rook's space unflagged by moving the Rook back after moving it and then castling with it. When the Rook's space remains flagged, you will not be able to castle with the Cannon. You should do as I do in Chess, which is to unflag every space moved to or from. The code used in Chess is

unsetflag $origin $dest;

🕸Fergus Duniho wrote on Thu, Jul 8, 2021 08:36 PM UTC in reply to Aurelian Florea from 08:28 AM:

I think I accidentally deleted a comment while deleting some test comments.

1.The castling moves are not shown although they work.

The code for this goes in the stalemated subroutine, and here is what you have in that subroutine:

// Castling code removed, since Apothecary Chess does not include castling.

So you need to add some code for it there. You can probably borrow some from the one in the fairychess include file. I'm not sure if it will require any modification. Try it without modification first and see how it works.


Aurelian Florea wrote on Mon, Jul 12, 2021 08:28 AM UTC in reply to Fergus Duniho from Thu Jul 8 08:36 PM:

@Fergus,

Why in the castle subroutine in fairychess.txt include file the line unsetflag #RPOS; is commented?


🕸Fergus Duniho wrote on Mon, Jul 12, 2021 05:44 PM UTC in reply to Aurelian Florea from 08:28 AM:

Why in the castle subroutine in fairychess.txt include file the line unsetflag #RPOS; is commented?

I suppose it could be uncommented if you wanted to be thorough, but it isn't necessary to prevent illegal castling. Once the King has moved, the space it moves from and the space it moves to both get unflagged, and every space the King moves to gets unflagged. So, no matter what, the King is still unable to castle. As long as the King can't castle, nothing can castle with the King. So, leaving a flag on the Rook's original space doesn't change anything critical to the game.


Aurelian Florea wrote on Tue, Jul 13, 2021 11:51 AM UTC:

@Fergus,

I am almost done with the castling. It was not that hard. I have left the normal stalemated subroutine which took care properly of the moves display. Also I am handling the flag sets and unsets properly as far as I can see. What I still need to do is delete a variable from wcastle or bcastle as the rook gets moved. How do I delete a value from an array?


🕸Fergus Duniho wrote on Tue, Jul 13, 2021 03:38 PM UTC in reply to Aurelian Florea from 11:51 AM:

What I still need to do is delete a variable from wcastle or bcastle as the rook gets moved.

That shouldn't be necessary, as other factors will determine that future castling moves are illegal without doing this.

How do I delete a value from an array?

Once the King has castled, it might be a bit of an optimization if you set wcastle or bcastle to an empty array, but it shouldn't be necessary.


Test[Subject Thread] [Add Response]
🕸Fergus Duniho wrote on Tue, Jul 13, 2021 03:47 PM UTC:

Posting from Chrome in Windows 10.


🕸Fergus Duniho wrote on Tue, Jul 13, 2021 03:54 PM UTC:
Adding response from Chrome on my Likebook Mars.

🕸Fergus Duniho wrote on Tue, Jul 13, 2021 03:56 PM UTC in reply to Fergus Duniho from 03:54 PM:

Replying from Chrome on my Likebook Mars.


🕸Fergus Duniho wrote on Tue, Jul 13, 2021 04:15 PM UTC:
Adding response with Chrome on my Likebook Mars without being signed in first.

🕸Fergus Duniho wrote on Tue, Jul 13, 2021 04:22 PM UTC in reply to Fergus Duniho from 04:15 PM:

Replying from Chrome on my Likebook Mars without being signed in first.


The birth of 3 new variants - part 2 : Grand Apothecary Chess Modern[Subject Thread] [Add Response]
Aurelian Florea wrote on Thu, Jul 15, 2021 07:57 AM UTC in reply to Fergus Duniho from Tue Jul 13 03:38 PM:

@Fergus Then I do not understand why after I move the rook I can castle with the cannon on the field that was supposed to be used only for the rook. I think I haven't explained that properly but only one castle is aloud. This is not free castling. So this is why I asked about wcastle and bcastle.


🕸Fergus Duniho wrote on Thu, Jul 15, 2021 05:36 PM UTC in reply to Aurelian Florea from 07:57 AM:

I do not understand why after I move the rook I can castle with the cannon on the field that was supposed to be used only for the rook.

So far, you have not made it clear that the King moves to a different space when castling with each piece. The rules you have underneath the game do not even mention castling. The castle subroutine was not written with such a rule in mind. You might be able to make it work by adjusting the values of bcastle and wcastle after a Rook moves.

I think I haven't explained that properly but only one castle is aloud.

Castling is allowed only once, which I understand, but what you say next doesn't fit with you trying to say that. Are you trying to say that the King has only once space it can go to when castling with a certain piece?

Regarding your preset, I don't understand why you are using four colors for checkering the board. Also, the dark blue squares do not contrast well with the color used for highlighting legal moves, which makes it hard to see legal moves highlighted on those squares. Additionally, your rules could use images of the pieces, so that someone looking at a piece on the board can more easily tell how it moves. Remember to use the shortcodes for displaying pieces, so that the piece images below match those on the board no matter what piece set is used.


H. G. Muller wrote on Thu, Jul 15, 2021 07:03 PM UTC:

@Aurelian: Just out of curiosity: what happens when you use the Play-Test Applet to convert the Interactive Diagram you made to GAME code? Does the castling work as intended then?


25 comments displayed

EarliestEarlier Reverse Order LaterLatest

Permalink to the exact comments currently displayed.