Ultima

Discussion of chess software programming and technical issues.

Moderator: Ras

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

Re: Ultima

Post by hgm »

Code: Select all

A chameleon attacks a piece the way the piece attacks it. Hence, a chameleon captures a piece the way it captures it.
OK, I though some more about it, and this definition does not seem to be entirely correct. At least not in the litteral sense, which suggest that the proper procedure would be to temporarily replace the Chameleon by a piece of type X to see if it can capture a given piece of type X. For the Ultima Chameleon this fails: in your multi-capture example, replacing the Chameleon with a Pincer, it could not capture the three Pincers, because a true Pincer would not be allowed to jump there.

I think the Ultima Chameleon is not a pure Chameleon (i.e. one satisfying the quote), because it can leap-capture on the way to making a capture f a non-leap-capturer. I therefore wonder if it is a good idea to try to generalize it. A pure Chameleon should not be allowed to capture non-leapers when leaping.

A pure Chameleon would be easy to generalize. To generate its captures you would run through the opponent's piece list, and for any piece you encounter do a capture test of a fictitious piece of that type of your own at the square of the Chameleon to the opponent piece. That is not excessively costly. An added observaton is that replacement captures are mandatory, while all other captures are optional. (I.e. even when you could not make the capture, you are still allowed to make the move, leaving the would-be victimstanding there.)

Another fundamental question is how to treat leap-capturing riders. (A rider is piece that repeats its basic step like a slider, where the basic step is not to a neighbor square.) Most logical would be if a leap-capturing Nightrider could only capture pieces on squares it could land on. A leap-capturing Alfil-rider should not capture d2 if it jumps from c1 to e3.

When a pure Chameleon would capture a Xiangqi Cannon, it would need to jump over a platform. It could do that whatever the platform is. But if the platform is an enemy leap-capturer, a pure Chameleon could not capture it at the same time, because when you would replace it by the leap capturer, it would not have been allowed to move to the square occupied by the Cannon.
Daniel Shawul
Posts: 4186
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: Ultima

Post by Daniel Shawul »

There are different rules. The cambridge rule doesn't allow that capture for instance. Relevant quote from wikipedia baroque page
On the diagram on the right, the white chameleon moves g6-e6-c6, astoundingly capturing all seven black pieces except the king in one move and delivering check.
It captures the black withdrawer by moving away from it.
It captures the black long-leapers by jumping over them.
It captures three black pawns by surrounding them. (A chameleon can only capture pawns on a horizontal move or vertical move, not on a diagonal move.)
It captures the black coordinator by rank/file coordination with the white king.
It delivers check by moving adjacent to the black king.
In the Cambridge rules, this capture is not possible. The move is legal, but it captures only the two leapers, because the move is not a legal move for any of the other target pieces. In the absence of the two black leapers, the same move would capture the other five pieces.
I should also add that a chameleon inherits the way the opponent piece attacks it. The opponent piece may _not_ be directly attacking it. That is only true for simple jumpers and sliders. For pinching captures f.i the chameleon do not have to sit on a square that it may get pinched. It just inherits the 'way' , and tests if it can capture that 'way' any any opponent pieces that could have captured same 'way'. So it is not necessarily a " I attack you , you attack me ".

So the cambridge rule doesn't follow this method but I think the definiton I gave should be correct for the other more common ultima rules.
User avatar
hgm
Posts: 28390
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Ultima

Post by hgm »

I was not aware of these Cambridge rules, but they seem to describe what I called a 'pure' Chameleon, and I think they make more sense than allowing capture of all 7 pieces simultaneously. So I would propose to implement Ultima by Cambridge rules. Then the Chameleon is easy to generalize, by the rule I gave: replace the Chameleon by the piece it tries to capture, and see if it can do it. This takes into account what you point out above.

If you implement the Chameleon captures by a loop through the opponent piece list, you would not try Knight-like captures if there was not indeed a Knight in that piece list. You would just need a generalized 0x88 A-attacks-B test for the various capture styles. For replacement capture it would need some board table with capture bit masks, and (for sliders/riders) a table of the basic step corresponding to the direction. These same tables could be used for withdrawal-style captures as well, except that you would have to use the step in reverse to test if you could move away from the piece in stead of towards it. For sandwich captures you would reserve bits in the table with masks that would be set (for Ultima Pincer Pawns) in the mask table on the orthogonals next to the piece, (similar to what you would use to calculate King Safety by attacks on the King neighborhood), and the step in the direction of the square where you should move to. Problem is there could be two (if you start diagonally next to the piece), so you need an extra step-vector table, and you would also want to have a table that would tell you what is the 'partner square' of the sandwich (also for each of the two possibilities). Leap-capture can again be done by the niormal 0x88 tables, but the ray scan would be different. Coordination is a pain. You could use the normal attack tables to test alignment with the opponent King. But if that occurs, ther could be several directions a coordinator could move in (3 for a coordinator with Queen moves), and several possible target squares, that should all be tabulated as function of the (coordinator-victim) step, for the two different types of King alignment.