Chess(variants): Draw by insufficient... Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » Chess(variants): Draw by insufficient material « Previous Next »

Author Message
Andreas Speiger (Andique)
New member
Username: Andique

Post Number: 21
Registered: 11-2007
Posted on Saturday, September 05, 2015 - 6:49 am:   

I have looked into many zrf-files of chessvariants, but i have never seen a draw-condition by insufficient material.
So, here is the code for chesslike pieces:

(draw-condition (White Black)
(or (and (total-piece-count 0 Pawn)
(total-piece-count 0 Knight) (total-piece-count 0 Bishop) (total-piece-count 0 Rook) ( total-piece-count 0 Queen) )
(and (total-piece-count 0 Pawn) (total-piece-count 1 Knight) (total-piece-count 0 Bishop) (total-piece-count 0 Rook) ( total-piece-count 0 Queen) )
(and (total-piece-count 0 Pawn) (total-piece-count 0 Knight) (total-piece-count 1 Bishop) (total-piece-count 0 Rook) ( total-piece-count 0 Queen) )
(and (total-piece-count 0 Pawn) (total-piece-count 2 Knight) (total-piece-count 0 Bishop) (total-piece-count 0 Rook) ( total-piece-count 0 Queen) )
(and (total-piece-count 0 Pawn) (total-piece-count 0 Knight) (total-piece-count 2 Bishop) (total-piece-count 0 Rook) ( total-piece-count 0 Queen)
(absolute-config Bishop (board) ) (absolute-config (opponent Bishop) (board) ) )
(and (total-piece-count 0 Pawn) (total-piece-count 1 Knight) (total-piece-count 1 Bishop) (total-piece-count 0 Rook) ( total-piece-count 0 Queen)
(absolute-config Knight (board) ) (absolute-config (opponent Bishop) (board) ) )
)
)

The code got into a mess, but i think it is understandable.
King + 2 Knights vs. King is mostly a draw. The stronger side can't force a mate, in rare cases, dependent on the position, it is a mate.

I hope, I haven't overlooked something.

Certainly, if you have special figures, you must work out by yourself, if they can force the mate.

board = chessboard as a zone.

Regards from germany!
Malcolm James Webb (Mjw)
New member
Username: Mjw

Post Number: 19
Registered: 5-2008
Posted on Saturday, March 04, 2017 - 11:19 pm:   

As I understand it the FIDE rules about "draw through insufficient material" are no longer explicitly stated; instead they say,

"The game is drawn when a position is reached from which a checkmate cannot occur by any possible series of legal moves. This immediately ends the game,..."

Therefore "Draw through insufficient material" is derived from the above statement and is a subset of that rule. This is satisfied by:
- King v King;
- King v King & 1 knight;
- King v King & 1 bishop;
- King v king & multiple bishops, provided they all move on the same colour squares (possible only through pawn under promotion);
- King and multiple bishops v King & multiple bishops, provided all bishops on the board move on the same colour squares.

(King & 2 knights v King) and (King v King & Knight & Bishop) does NOT satisfy that rule as checkmate is still possible, but cannot be forced.

A simpler Zillions code to partially implement the above rule is:

(draw-condition (total-piece-count 2))
; drawn game if King v King

(draw-condition
(and (total-piece-count 3)
(or (total-piece-count 1 Knight)
(total-piece-count 1 Bishop)
)))
; drawn game if King v King + one minor piece

The reason this works is that in a checkmate-game such as Chess the two Kings will always be on the board. I have implemented a similar code for "Elsborg's Courier Chess", but there are three minor piece types in that game.

It would probably be possible to implement the more elaborate situations with multiple bishops all moving on the same colour-squares. However it wouldn't be possible to specify in advance each and every position which would be considered a "dead" position.
Andreas Speiger (Andique)
New member
Username: Andique

Post Number: 22
Registered: 11-2007
Posted on Saturday, June 10, 2017 - 7:05 am:   

Hello Malcolm,
thank you for your answer.
Your code is wrong for some reason.
First there is (White Black) missing.
Second you must count all pieces with a Zero. Look how i did it.
I have tested it, it don't work.
And then your code is too simple, misses some possibilities.
regards from germany
Mohamed El Mokhtar Messaoudi (Noggluggoid)
New member
Username: Noggluggoid

Post Number: 9
Registered: 5-2016
Posted on Saturday, June 10, 2017 - 2:06 pm:   

Constructs with 'opponent' key-word never worked for me, I have always had to resort to complicated things instead. Curious.
Malcolm James Webb (Mjw)
New member
Username: Mjw

Post Number: 25
Registered: 5-2008
Posted on Monday, June 12, 2017 - 12:02 am:   

I have just re-tested this code which appears in two of my recent submissions, Elsborg Courier Chess, and Pole Chess. It works fine.

It is possible to omit the player list when using "total-piece-count". Are you using "total-piece-count" or are you using "pieces-remaining"? And are you running Zillions 2.0 / 2.1 or an earlier version of Zillions?

Here is my code for the ending game positions exactly as they appear in Elsborg Courier Chess. I recommend you look at this game rather than Pole Chess, as the "Insufficient Material" condition is more complicated in Pole Chess (especially in Variant 8).

(loss-condition (White Black) (checkmated King))

(draw-condition (total-piece-count 2)) ; drawn game if King v King

(draw-condition (White Black)
(and (total-piece-count 3)
(or (total-piece-count 1 Runner)
(total-piece-count 1 Knight)
(total-piece-count 1 Bishop)
))) ; drawn game if King v King + one minor piece

NB: In Anders' game there are two different types of "bishops"; the "Runner" and the "Bishop".

If "total-piece-count" is ever 2, then logically the two remaining pieces must be Kings (as Kings aren't captured). Therefore it's King v King, which is a draw. It isn't necessary to stipulate all pieces with a Zero, as we know they aren't there because there are only two pieces left.

When "total-piece-count" evaluates to three, we know that two of those pieces must be Kings, so we only need to know which is the third piece. If that is one of the minor pieces (Knight or Bishop or Runner) then it is impossible to ever produce a checkmate position even if the side with only a King tries to help himself be checkmated.

I suggest you download "Elsborg Courier Chess" and see for yourself that it works.

(I implemented for "Pole Chess", but that is more complicated due to the Pole piece, and the use of a neutral dummy piece. And the insufficient material draw rule doesn't apply to Ito Shogi or to Abagoren Chess, for different reasons).
Malcolm James Webb (Mjw)
New member
Username: Mjw

Post Number: 26
Registered: 5-2008
Posted on Monday, June 12, 2017 - 12:25 am:   

I had a further look at your original code, and I see you are using "total-piece-count" and you must be using Zillions v 2.0 or above. But what you don't do is use "total-piece-count" without piece arguments, see below:

(draw-condition (total-piece-count 2))

This command counts every single piece on the board, regardless of whose side they are on or what type of piece they are. So it isn't necessary to check every piece-type and see that there are none of those pieces left. In a checkmate game, when there are only two pieces left, they must be the two Kings.
Malcolm James Webb (Mjw)
New member
Username: Mjw

Post Number: 27
Registered: 5-2008
Posted on Monday, June 12, 2017 - 12:55 am:   

Finally you state that my code misses some possibilities, and you are quite right. But all draw possibilities cannot be covered in Zillions.

The relevant rules of F.I.D.E. chess are:
5.2 b,
"The game is drawn when a position has arisen in which neither player can checkmate the opponent’s king with any series of legal moves. The game is said to end in a ‘dead position’. This immediately ends the game, provided that the move producing the position was in accordance with Article 3 and Articles 4.2 – 4.7."
and 9.7,
"The game is drawn when a position is reached from which a checkmate cannot occur by any possible series of legal moves. This immediately ends the game, provided that the move producing this position was in accordance with Article 3 and Articles 4.2 – 4.7."

"Insufficient material" is one of the possible conditions which comply with that rule. It is possible to have sufficient number of pieces on the board but arranged so that checkmate will never be possible. I think you will agree that it would be impractical for Zillions to test for all possible piece configurations which satisfy that condition.

As for the "insufficient material" condition, then the other conditions which satisfy that condition in F.I.D.E. chess are:

King v King + n Bishops (where n = 1 to 9) provided all Bishops move on the same colour squares

King + n Bishops v King v n Bishops provided that every Bishop on the board is moving on the same colour squares.

This would require differentiating between "Light-Square-Bishops" and "Dark-Square-Bishops", with each side having one of each. It would mean the Pawn promotion rules would be more complicated as I would have to stipulate two promotion-zones, for light squares and dark squares. And this is all to cover the remote possibility that a player would promote a Pawn to a Bishop rather than to a Queen.

It would be even more complicated in Elsborg's Courier Chess, as I would have to test for all permutations and combinations of Bishops and Runners on one or both sides.

Note that
King v King + two Knights
is NOT an automatic draw under the F.I.D.E. rules of chess.

Naturally Zillions already has an implementation of Chess, so most game-developers are making chess variants. And it is up to the game inventor to stipulate their own draw conditions.
Malcolm James Webb (Mjw)
New member
Username: Mjw

Post Number: 28
Registered: 5-2008
Posted on Tuesday, June 13, 2017 - 11:17 pm:   

I have looked further into the problem of implementing "Insufficient Material Draw Rule".

1) "total-piece-count" needs the player list (White Black) ONLY if used with "and" or "or". So using:

(draw-condition (total-piece-count 2))

is OK because there is no "and" or "or", but (White Black) is needed if there is more than one argument:

(draw-condition (White Black)
(and (total-piece-count 3)
(or (total-piece-count 1 Knight)
(total-piece-count 1 Bishop)
)))

These two draw conditions above would cover most of the "insufficient material" draws in FIDE chess. But to cover all of them one has to cover the possibility that there may be more than one Bishop on the board, but all are moving on the same colour squares. This requires defining two Bishop pieces, one for dark squares, one for light squares.

NB: This is only to cover the possibilities for automatic draw under FIDE chess. Other positions are not automatic draws, although checkmate is only possible if one plays very badly:

King v King & 2 Knights,
King & Knight v King & Knight,
King & Knight v King & Bishop,
King & Bishop v King & Bishop (but only if the two Bishops move on differently coloured squares),
Malcolm James Webb (Mjw)
New member
Username: Mjw

Post Number: 29
Registered: 5-2008
Posted on Tuesday, June 13, 2017 - 11:47 pm:   

To totally cover ALL possible "insufficient material" draws in FIDE Chess (including the remote possibility that a player would promote pawns to bishops):

A) In "Board Definitions", in place of the two "promotion-zone" arguments, put:

(zone (name lprom-zone) (players White) (positions a8 c8 e8 g8))

(zone (name lprom-zone) (players Black) (positions b1 d1 f1 h1))

(zone (name dprom-zone) (players White) (positions b8 d8 f8 h8))

(zone (name dprom-zone) (players Black) (positions a1 c1 e1 g1))

B) Make two definitions for bishops, call one "DBishop", call the other "LBishop" (but otherwise they are identical)

C) In the move logic for pawns, substitute the following macro for "Pawn-add"

(define Pawn-add (if (in-zone? dprom-zone) (add Queen Rook Knight DBishop) else
(if (in-zone? lprom-zone) (add Queen Rook Knight LBishop)
else add)))

D) In the Board Setup, substitute the following:

(board-setup
(White
(Pawn a2 b2 c2 d2 e2 f2 g2 h2)
(Knight b1 g1)
(DBishop c1)
(LBishop f1)
(Rook a1 h1)
(Queen d1)
(King e1)
)
(Black
(Pawn a7 b7 c7 d7 e7 f7 g7 h7)
(Knight b8 g8)
(DBishop f8)
(LBishop c8)
(Rook a8 h8)
(Queen d8)
(King e8)
)
)

E) For the goal conditions, have:

(loss-condition (White Black) (checkmated King))

(draw-condition (White Black) (and (total-piece-count 3) (total-piece-count 1 Knight)))

(draw-condition (White Black)
(and (total-piece-count 0 Queen) (total-piece-count 0 Rook)
(total-piece-count 0 Knight) (total-piece-count 0 Pawn)
(or (total-piece-count 0 LBishop) (total-piece-count 0 DBishop))))
Andreas Speiger (Andique)
New member
Username: Andique

Post Number: 23
Registered: 11-2007
Posted on Wednesday, June 14, 2017 - 10:11 am:   

I have tested your Elsborg Courier Chess.

Your code runs not well for me and my game "AstalChess". AstralChess is in princible "Astralschach 2.0" and not published yet. Astralschach is published.

But i figured out the reason why your code don't work (for AstralChess):
I have three players (White, Black and Neutral). Certainly only the turn-order (White Black). This is not the problem. The problem is i have associated many dummy-pieces with the Neutral player in the board setup.

I have two dummies associated with the White player, two with Black and 16 (!) with Neutral.

If i correct your code into following:

(draw-condition (total-piece-count 22 ) )

then it is really a draw for King vs. King endposition.

The draw- condition for King vs. King + minor piece is:

(draw-condition (White Black) (and (total-piece-count 23) (or (total-piece-count 1 Knight) (total-piece-count 1 Bishop) ) ) )

Now the critical point:
King + minor piece vs. King + minor piece:

(draw-condition (White Black) (or (and (total-piece-count 24) (total-piece-count 2 Bishop)
(absolute-config Bishop (chessboard) ) (absolute-config (opponent Bishop) (chessboard) ) ) (and (total-piece-count 24) (total-piece-count 2 Knight) (absolute-config Knight (chessboard) ) (absolute-config (opponent Knight) (chessboard) ) ) (and (total-piece-count 24) (total-piece-count 1 Bishop) (total-piece-count 1 Knight) (absolute-config Bishop (chessboard) ) (absolute-config (opponent Knight) (chessboard) ) ) ) )

The last one is really a little bit complicated and if you are right we can do it without.

My code from my opening posting is without the critical situations:

(draw-condition (White Black) (or
(and (total-piece-count 0 Pawn) (total-piece-count 0 Knight) (total-piece-count 0 Bishop) (total-piece-count 0 Rook) ( total-piece-count 0 Queen) )
(and (total-piece-count 0 Pawn) (total-piece-count 1 Knight) (total-piece-count 0 Bishop) (total-piece-count 0 Rook) ( total-piece-count 0 Queen) )
(and (total-piece-count 0 Pawn) (total-piece-count 0 Knight) (total-piece-count 1 Bishop) (total-piece-count 0 Rook) ( total-piece-count 0 Queen) ) ) )

This is not too difficult, implied all important endpositions and works for all games
independent how many dummies you have.

I have thought about the splitting Bishops earlier, but this is not necessary for AstralChess, because the bishops can change the colour of the squares.

regards from germany
another question:
How good is my english?
Malcolm James Webb (Mjw)
New member
Username: Mjw

Post Number: 30
Registered: 5-2008
Posted on Thursday, June 15, 2017 - 9:53 am:   

Hi Andreas, your English is a lot better than my Deutsch!
Yes, one must count the dummy pieces for total-piece-count, I had to do the same for Pole Chess where I used a dummy piece as part of the visual display.

And you're right, if the Bishops can switch from one colour to the other, then King & 2 Bishops v King would allow a forced checkmate.

And the conditions for King v King and for King v King + minor piece seem fine.

In F.I.D.E. Chess,
King + minor piece v King + minor piece
is NOT an automatic draw (unless the two minor pieces are Bishops moving on the same colour squares), but your game might be different.

If you have Black King on h8, Black Knight on g8, White King on g6 and White Knight on f7 then Black is checkmated (but Black has played very badly for this to happen). It can also be set up with Knight and Bishop or two Bishops.

However as Astralschach is your invention, the draw conditions may be different.

If you are to set up King + minor piece v King + minor piece, then perhaps the use of "pieces-remaining" might help, which is specific for one player or the other? Because it is possible to mix "total-piece-count" and "pieces-remaining" in the same draw condition.

Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: