How to teach a program to press the King to the baseline?

Programming Topics (Computer Chess) and technical aspects as test techniques, book building, program tuning etc

Moderator: Andres Valverde

How to teach a program to press the King to the baseline?

Postby JoelH » 26 Jun 2010, 12:46

At first, sorry about my bad english, its not my native language.

I just created a game almost like Chess, but with some different pieces etc. But basicly its the same.

I have also written a computer engine to play the Game. The Program plays tactically already acceptable. But in the endgame it is extremely weak:( If there are no tactical threats the program has no plan what to do :(

Now I have a very general question. How can i teach the computer that he must press the enemy king to the baseline?

Are there somewhere HOWTOs at the Internet? Or is there someone who can give me a basic Idea?

In my evaluation function I created different field variables, so that the opposing king is given a penalty when he is on the outer lines, but it works somehow not good enough.

Code: Select all
  fieldmalus: array [0..9,0..9] of Integer = ((50,47,45,42,40,40,42,45,47,50), / / Column 0
                                                  (47,45,42,40,0,0,40,42,45,47)                     / / etc. / /to try the opponent
                                                  (45,42,40,0,0,0,0,40,42,45),                       / /King to push to the edge
                                                  (42,40,0,0,0,0,0,0,40,42)
                                                  (40,18,0,0, -10 -10,0,0,18,40)
                                                  (40,18,0,0, -10, -10,0,0,18,40)
                                                  (42,40,0,0,0,0,0,0,40,42)
                                                  (45,42,40,0,0,0,0,40,42,45)
                                                  (47,45,42,40,0,0,40,42,45,47)
                                                  (50,47,45,42,40,40,42,45,47,50)
                                                  );

AdditionalColumnRowMalus: array [0..9] of Integer = (57,50,45,10,0,0,10,45,50,57) / / In order to push the King to the outside


Any other strategy ideas?
JoelH
 
Posts: 3
Joined: 24 Jun 2010, 09:35
Location: Germany

Re: How to teach a program to press the King to the baseline

Postby Dann Corbit » 26 Jun 2010, 13:08

Make an evaluation rule to limit the space of the king.

Assuming you have a rook or a queen, always move the rook or the queen so that the enemy king has less space than before, or in the worst case the same space. Since the enemy king is going to try to stay centralized, move your king along the ray until opposed by the enemy king and then advance the slider piece. You always want to make his box as small as possible.

You can also solve the problem with tablebase, but most people do not find that very satisfying.

Consider this position:
[d]8/8/4k3/R7/3K4/8/8/8 b - -
The black king has a rectangle from b6 to h6 to h8 to b8 to b6.
Special rule:
If the king moves to d6 then we move the rook to a6 because the kings will be opposed.
Otherwise we shrink his rectagle as follows:
if the king moves to d7, e7, or f7 we move the rook to d6 so that now the king can travel only two rows instead of 1.
If the king moves to f6 we will move the rook to e5 because now the king has a tiny rectangle from f6 to h6 to h8 to f8 to f6.
We will always want to miniumize either ranks or files available to the enemy king, and if all other things are equal then minimize them both like the above example.
It is the same as if you were playing against an opponent.

It is similar for two bishops, except that we push diagonally and it is harder to change direction.

The simple exercise to solve this endgame is simply to count the enemy kings total squares that he can reach without crossing the ray of a slider. The smaller the number, the more trouble he is in.
Dann Corbit
 

Re: How to teach a program to press the King to the baseline

Postby JoelH » 26 Jun 2010, 14:20

Wow, thanks for this Idea.

Looks simple, but seems to be really good. I'll try to implement it.
JoelH
 
Posts: 3
Joined: 24 Jun 2010, 09:35
Location: Germany

Re: How to teach a program to press the King to the baseline

Postby H.G.Muller » 28 Jun 2010, 13:42

Normally a Piece-Square table like you are showing for the Kings should be enough to have easy checkmating both in KQK and KRK, even at low search depth. Can you show us a game (from the position 8/8/8/4k3/8/8/8/6KR w - - 0 1 , say) where your program fails to checkmate?
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: How to teach a program to press the King to the baseline

Postby JoelH » 29 Jun 2010, 12:43

I made some more tests.

It was an error with the Stalemate identification in the search :(
JoelH
 
Posts: 3
Joined: 24 Jun 2010, 09:35
Location: Germany


Return to Programming and Technical Discussions

Who is online

Users browsing this forum: No registered users and 12 guests