King of the Hill programs?

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

Moderators: hgm, Rebel, chrisw

User avatar
Guenther
Posts: 4610
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

King of the Hill programs?

Post by Guenther »

Currently I am watching sometimes the 'King of the Hill' chess variant in online games and I like it quite a lot.
I guess I will try this myself after fully understanding the strategical aspects.

For explanation: the rules(pieces and board etc. too) are exactly the same as in normal chess, except you also win
when your King legally enters one of the two center squares of your side, e.g. d4/e4 or d5/e5.

Are there programs out which are capable of playing this variant?(strength is not important)

Guenther
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: King of the Hill programs?

Post by Evert »

It should be easy to configure Sjaak to play this: all that is needed is to add "flags" to the game definition and add a victory condition for "capture the flag".

The following game definition in "variants.txt" should do it (but you need to tell Sjaak to load that file, for instance using its engine options in XBoard).

Code: Select all

Variant: King of the Hill
Board: 8x8
FEN: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -"
Zone: rank8 = a8,b8,c8,d8,e8,f8,g8,h8
Zone: rank7 = a7,b7,c7,d7,e7,f7,g7,h7
Zone: rank2 = a2,b2,c2,d2,e2,f2,g2,h2
Zone: rank1 = a1,b1,c1,d1,e1,f1,g1,h1

BlackFlag: e4,d4
WhiteFlag: e5,d5

Rule: captureanyflag = win

Piece: Knight
Move: leap (2,1)
Symbol: "N", "N,n"
Value: 320

Piece: Bishop
Move: slide (D,A)
Symbol: "B", "B,b"
Value: 325

Piece: Rook
Move: slide (H,V)
Symbol: "R", "R,r"
Value: 500

Piece: Queen
Move: slide (D,A,H,V)
Symbol: "Q", "Q,q"
Value: 950

Piece: King
Move: leap(0,1)|(1,1)
Symbol: "K", "K,k"
Flags: royal, castle

Piece: White Pawn
Move: step N
Capture: step NE,NW
Special: rank2, step 2N
Symbol: " ", "P"
Flags: set_ep,take_ep
Promotion: rank8, "QRBN"
Value: 100

Piece: Black Pawn
Move: step S
Capture: step SE,SW
Special: rank7, step 2S
Symbol: " ", ",p"
Flags: set_ep,take_ep
Promotion: rank1, "QRBN"
Value: 100
Untested.
User avatar
hgm
Posts: 27811
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: King of the Hill programs?

Post by hgm »

If stregth is not important, Any normal Chess engine would do. They would just not know when the game was finished, and would not realize they could win it even when they were only one move away from a win. :lol:

I suppose that normal rules w.r.t. not moving into check apply here? And that you thus can also win by checkmate? Or can you let your King be captured here, and still play on for a draw?

It is easy enough to adapt any engine to recognize the winning condition. That would allow it to recognize wins tactically, i.e. whan they are within the search horizon. But the chances that it would ever get a win within the horizon would be near zero, if you don't adjust its strategy as well by tweeking the evaluation. Otherwise it would be much like playing normal chess with an engine that has negative piece values. It would recognize mate-in-11, but as it will sac all its material from move 1 on, it will never get in a position to deliver such a mate.

Normal engines are programmed to safely tug away their King in a corner, staying away from the center as far as they can. That seems like the opposite of what you need in this game. So to get play that makes any sense at all, you should at least add a piece-square table that awards the King for approaching the center. And probably an enhanced King-Safety term for exposure to enemy attack to prevent it will take too much risk when attempting this.

Piece values would probably also have to be completely different. A Pawn doesn't seem worth very much in this game.
Uri Blass
Posts: 10310
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: King of the Hill programs?

Post by Uri Blass »

hgm wrote:If stregth is not important, Any normal Chess engine would do. They would just not know when the game was finished, and would not realize they could win it even when they were only one move away from a win. :lol:

I suppose that normal rules w.r.t. not moving into check apply here? And that you thus can also win by checkmate? Or can you let your King be captured here, and still play on for a draw?

It is easy enough to adapt any engine to recognize the winning condition. That would allow it to recognize wins tactically, i.e. whan they are within the search horizon. But the chances that it would ever get a win within the horizon would be near zero, if you don't adjust its strategy as well by tweeking the evaluation. Otherwise it would be much like playing normal chess with an engine that has negative piece values. It would recognize mate-in-11, but as it will sac all its material from move 1 on, it will never get in a position to deliver such a mate.

Normal engines are programmed to safely tug away their King in a corner, staying away from the center as far as they can. That seems like the opposite of what you need in this game. So to get play that makes any sense at all, you should at least add a piece-square table that awards the King for approaching the center. And probably an enhanced King-Safety term for exposure to enemy attack to prevent it will take too much risk when attempting this.

Piece values would probably also have to be completely different. A Pawn doesn't seem worth very much in this game.
I did not analyze this game but I do not think that the evaluation should be significantly different.

If you develop your king in the opening then the opponent may win by a king attack that does not let your king to go into the center of the board so I do not think that the strategy of developing your king is a good strategy.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: King of the Hill programs?

Post by Evert »

Actually, scratch that. There is no limit on what piece type should capture the flag, so white would win immediately with 1. e4...
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: King of the Hill programs?

Post by Evert »

hgm wrote:It is easy enough to adapt any engine to recognize the winning condition. That would allow it to recognize wins tactically, i.e. whan they are within the search horizon. But the chances that it would ever get a win within the horizon would be near zero, if you don't adjust its strategy as well by tweeking the evaluation. Otherwise it would be much like playing normal chess with an engine that has negative piece values. It would recognize mate-in-11, but as it will sac all its material from move 1 on, it will never get in a position to deliver such a mate.

Normal engines are programmed to safely tug away their King in a corner, staying away from the center as far as they can. That seems like the opposite of what you need in this game. So to get play that makes any sense at all, you should at least add a piece-square table that awards the King for approaching the center. And probably an enhanced King-Safety term for exposure to enemy attack to prevent it will take too much risk when attempting this.

Piece values would probably also have to be completely different. A Pawn doesn't seem worth very much in this game.
This is of course a concern. However, immediately blocking the centre will make it tricky to walk the king there - and a king attack that drives the king out into the open runs the risk of him "capturing the flag" before you can mate him.

I think Sjaak should adjust the piece square tables so it will try to move pieces towards the targets (flags), but it's entirely possible that didn't make it off the TODO list yet. I certainly didn't design it with the intension of restricting the piece type that can capture the flag, but that should be easy to add regardless.
User avatar
hgm
Posts: 27811
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: King of the Hill programs?

Post by hgm »

It also seems important not to block your central squares by putting Pawns on them.

Does moving the King to a central square mean an immediate win (like capturing the opponent King would)? Or does the opponent get some 'after turn' to (re-)capture my King in case it moved to a protected square? In the latter case it becomes more like Shatranj baring: capturing the King remains the primary winning condition, but when you cannot do that, and after your move the opponent's King is 'on the hill', you lost. Or equivalently, only if at the start of your turn your King is on the hill you win, while capturing a King is an immediate win at the end of the turn where you do it.
User avatar
Guenther
Posts: 4610
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: King of the Hill programs?

Post by Guenther »

hgm wrote:It also seems important not to block your central squares by putting Pawns on them.

Does moving the King to a central square mean an immediate win (like capturing the opponent King would)? Or does the opponent get some 'after turn' to (re-)capture my King in case it moved to a protected square? In the latter case it becomes more like Shatranj baring: capturing the King remains the primary winning condition, but when you cannot do that, and after your move the opponent's King is 'on the hill', you lost. Or equivalently, only if at the start of your turn your King is on the hill you win, while capturing a King is an immediate win at the end of the turn where you do it.
You win immediately when legally moving to a center square.
When I said strength is irrelevant I actually meant it still should try to win or at least try to defend against a loss and and not only know the rules when the game is over.
(Of course you cannot move to an occupied or defended square that would not be allowed as all other rules of chess remain like I said)

Well from looking at some games at speed slower than bullet or very fast blitz it seems the best Humans just play normally
(just that some mate patterns don't work when the King going to be mated would be hunted to a center square at the mating route and some endgame tricks overloading the squares to be defended by sacs)

About blocking the center with pawns I don't know yet, it is double edged. The game lasts longer, because both Kings cannot get easily to the desired squares.
OTH you still must calculate piece sacs removing the pawn defender and then it gets difficult to control the squares especially when the King is already in the neighbourhood.

But maybe strong programs with normal play and just knowing the rule when the game is over are already that good that you just lose too much material
before a chance appears to trick it with moves enabling your King to get where it should?

Hope that makes some sense.
User avatar
Guenther
Posts: 4610
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: King of the Hill programs?

Post by Guenther »

Uri Blass wrote:
hgm wrote:If stregth is not important, Any normal Chess engine would do. They would just not know when the game was finished, and would not realize they could win it even when they were only one move away from a win. :lol:

I suppose that normal rules w.r.t. not moving into check apply here? And that you thus can also win by checkmate? Or can you let your King be captured here, and still play on for a draw?

It is easy enough to adapt any engine to recognize the winning condition. That would allow it to recognize wins tactically, i.e. whan they are within the search horizon. But the chances that it would ever get a win within the horizon would be near zero, if you don't adjust its strategy as well by tweeking the evaluation. Otherwise it would be much like playing normal chess with an engine that has negative piece values. It would recognize mate-in-11, but as it will sac all its material from move 1 on, it will never get in a position to deliver such a mate.

Normal engines are programmed to safely tug away their King in a corner, staying away from the center as far as they can. That seems like the opposite of what you need in this game. So to get play that makes any sense at all, you should at least add a piece-square table that awards the King for approaching the center. And probably an enhanced King-Safety term for exposure to enemy attack to prevent it will take too much risk when attempting this.

Piece values would probably also have to be completely different. A Pawn doesn't seem worth very much in this game.
I did not analyze this game but I do not think that the evaluation should be significantly different.

If you develop your king in the opening then the opponent may win by a king attack that does not let your king to go into the center of the board so I do not think that the strategy of developing your king is a good strategy.
You are almost correct I guess but there seem to be exceptions.
If you don't get trapped in a mating net and don't lose a lot of material and the opponent cannot
easily control certain squares before the center you can e.g. move to d2/e2 in the opening.
Still this is just a first step and it might backfire, I really don't know.

So far I have only watched very fast games and here all kind of very different plans/intuition
can be seen(far from Human calculation horizon probably)
User avatar
Guenther
Posts: 4610
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: King of the Hill programs?

Post by Guenther »

Evert wrote:
hgm wrote:It is easy enough to adapt any engine to recognize the winning condition. That would allow it to recognize wins tactically, i.e. whan they are within the search horizon. But the chances that it would ever get a win within the horizon would be near zero, if you don't adjust its strategy as well by tweeking the evaluation. Otherwise it would be much like playing normal chess with an engine that has negative piece values. It would recognize mate-in-11, but as it will sac all its material from move 1 on, it will never get in a position to deliver such a mate.

Normal engines are programmed to safely tug away their King in a corner, staying away from the center as far as they can. That seems like the opposite of what you need in this game. So to get play that makes any sense at all, you should at least add a piece-square table that awards the King for approaching the center. And probably an enhanced King-Safety term for exposure to enemy attack to prevent it will take too much risk when attempting this.

Piece values would probably also have to be completely different. A Pawn doesn't seem worth very much in this game.
This is of course a concern. However, immediately blocking the centre will make it tricky to walk the king there - and a king attack that drives the king out into the open runs the risk of him "capturing the flag" before you can mate him.

I think Sjaak should adjust the piece square tables so it will try to move pieces towards the targets (flags), but it's entirely possible that didn't make it off the TODO list yet. I certainly didn't design it with the intension of restricting the piece type that can capture the flag, but that should be easy to add regardless.
Welcome back Evert, just saw the 'returning' thread.
Games of King of the Hill can be watched at LiChess(online chess site which runs in browser).
Afaik they implemented this not too long ago.