pointy chains redux (part 1)

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

Moderator: Ras

carldaman
Posts: 2287
Joined: Sat Jun 02, 2012 2:13 am

Re: extending the chain (part 3)

Post by carldaman »

Lyudmil Tsvetkov wrote:
PK wrote:OK, there is something that actually helps Rodent a bit. Chains of three pawns pointing towards king side, as specified by Lyudmil, get a bonus of 20 centipawns provided that the enemy king is there. Furthermore, that bonus climbs to 28 cp if there is an nemy pawn on the "congestion point" as defined by Carl. I have made another adjustement that makes the code a bit messy, namely the chains whose spearhead is on the 4th rank need two opposing pawns to obtain the second bonus.

To make this work, I needed to reduce speed overhead by hashing pawn chains eval. Rodent already had king and pawn hashtable that became a bit bloated as a result. Right now it keeps passer eval (midgame and endgame), pawn structure eval (ditto), king shield (midgame only) and separately chain eval (midgame only).

There are many things to tweak (increasing pawn storm bonus comes to mind, as in the KID positions with the chain in place Rodent sometimes attacks with the "g" pawn, sometimes not), but I'm glad that the basic formula finally brought some benefit.
Long live congestion points and Carl! :D

Please, provide further info, Pawel: results of SPRT test, TC, elo increase, etc.
+1 Long live open-mindedness! :D

Cheers,
CL 8-)
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: extending the chain (part 3)

Post by Lyudmil Tsvetkov »

carldaman wrote:
PK wrote:OK, there is something that actually helps Rodent a bit. Chains of three pawns pointing towards king side, as specified by Lyudmil, get a bonus of 20 centipawns provided that the enemy king is there. Furthermore, that bonus climbs to 28 cp if there is an nemy pawn on the "congestion point" as defined by Carl. I have made another adjustement that makes the code a bit messy, namely the chains whose spearhead is on the 4th rank need two opposing pawns to obtain the second bonus.

To make this work, I needed to reduce speed overhead by hashing pawn chains eval. Rodent already had king and pawn hashtable that became a bit bloated as a result. Right now it keeps passer eval (midgame and endgame), pawn structure eval (ditto), king shield (midgame only) and separately chain eval (midgame only).

There are many things to tweak (increasing pawn storm bonus comes to mind, as in the KID positions with the chain in place Rodent sometimes attacks with the "g" pawn, sometimes not), but I'm glad that the basic formula finally brought some benefit.
Very interesting and encouraging developments, Pawel. I've always thought you'd be among the likeliest candidates to not only take on this challenge, but to also succeed. :)

My recommendation is to give an extra bonus for storming with the g and h pawns when the extended chain conditions are already in place.

Regards,
CL
You are right, Pawel is my hero, especially if he provides some further info.

From now on, I will be playing only with Rodent. :)

Do you see the Stockfish guys, Carl?

When it comes about implementing simple and mostly useless patches, they are the first to push a test, but when there is a real challenge, like the good knowledge of implementing a pointed chain eval, that would benefit positional chess analysis very much, and users would definitely like it, they all disappear into thin air.

Where are you, Ralph, Joerg, Stefan?
Rodent is already leaps and bounds in front of SF in terms of positional knowledge. :shock:

I think Rodent showed the way: it is evident now, that you can implement sound knowledge like pointed chains/triades, even when the engine search is not optimal for such eval factors, and still get some marginal value, in case you find a way to minimise the overhead, as Pawel says. In case some factors like triades are more rare to appear on the board, you might even suffer in terms of elo from such implementation, but, if you do a wise thing like hashing pawn chains, then a similar patch might also succeed as computational costs would be lower.

I really do not imagine, if SF for the time being does not even have pointed chain and longer chain eval, when they will start tackling the much more difficult concepts like closed positions (as pointed chains and closed positions are not synonymous), square control, positional compensation?

I hope Pawel says a bit more about this, but, I think no one can dispute, that if he managed to gain close to 1 elo from triades, then the pointed chain/longer chains concept promises some 49 elo more, until you get to 50, as this term is objectively worth some 50 elo points.
PK
Posts: 907
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: extending the chain (part 3)

Post by PK »

OK, I got 51,5% from 1300 games (+422,=514,-383). Not many games, but I was limited to my laptop at that time. Nevertheless, if I remember correctly, 1000 games with such advantage would mean 95% confidence that the patch is good. Time control was 30 seconds per game + 0.16 s increment, average depth 13.3 plies (yes, shame on my laptop).

As for positional knowledge, I'm sure that Stockfish still is way ahead. Its outpost code is much more refined, it evaluates pins, it generalized "rook on 7th rank" to "rook attacking pawns on their base rank" which may be a bit higher in the endgame...

Also, I do not see many chains neither in the games nor in the analysis, so the stylistic change is lesser than You might anticipate. Rodent still prefers to release tension rather than to form a chain.

I think that Rodent 1.7 (where most of the changes are in the eval) still is a couple of months away, but these gonna be really enjoyable months, especially if I will see even semi-correct play in the KID
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: extending the chain (part 3)

Post by Lyudmil Tsvetkov »

PK wrote:OK, I got 51,5% from 1300 games (+422,=514,-383). Not many games, but I was limited to my laptop at that time. Nevertheless, if I remember correctly, 1000 games with such advantage would mean 95% confidence that the patch is good. Time control was 30 seconds per game + 0.16 s increment, average depth 13.3 plies (yes, shame on my laptop).

As for positional knowledge, I'm sure that Stockfish still is way ahead. Its outpost code is much more refined, it evaluates pins, it generalized "rook on 7th rank" to "rook attacking pawns on their base rank" which may be a bit higher in the endgame...

Also, I do not see many chains neither in the games nor in the analysis, so the stylistic change is lesser than You might anticipate. Rodent still prefers to release tension rather than to form a chain.

I think that Rodent 1.7 (where most of the changes are in the eval) still is a couple of months away, but these gonna be really enjoyable months, especially if I will see even semi-correct play in the KID
Congratulations Pawel!

You got 1 elo from this.
49 more to go. :)

Seriously, big achievement, I am very glad about that.

Maybe you might post here some sample code, so that other programmers could learn and have a clue. That is the point of it all.

Yes, pointed chains/triades are relatively rare term, but if you know how to play them, they become more frequent.

Btw., I hope you ahev been using a short book, not longer than 5 moves, for otherwise many opportunities for building a chain are missed. Some books leave you with very open positions usually, others even straight into the middlegame.

So, if you really want to test this, make sure there are sufficient A and E ECO code openings in the book, which more often suppose more closed play and building of larger chains.

I would be really grateful if you post a portion of the code, just the most important things, so that people read it. Anyway, even if you are not prone to do that (everyone wants to keep their secrets), certainly the code will be freely available when you release Rodent 1.7.

I hope at least 1 person of the SF team is reading this.

Congratulations and many thanks again.
PK
Posts: 907
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: extending the chain (part 3)

Post by PK »

the code is available at the following link:

https://github.com/nescitus/rodent_rewr ... ter/eval.c

the function You might be interested in is ScoreChains(), starting at line 191. It implements the concept as a penalty for enemy chain pointing towards our king. The constant bigChainScore is 28cp, smallChainScore is 20cp, both are defined in eval.h ScoreChains() is called in score_pawns.c

As for macros, bbPc(p,sd,P) returns all the pawns of the side sd in the position p. RelSqBb(E4,sd) returns a bitboard of a single square - E4 for white, E5 for black. Chains we are talking about are encoded as black chains.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: extending the chain (part 3)

Post by Lyudmil Tsvetkov »

PK wrote:the code is available at the following link:

https://github.com/nescitus/rodent_rewr ... ter/eval.c

the function You might be interested in is ScoreChains(), starting at line 191. It implements the concept as a penalty for enemy chain pointing towards our king. The constant bigChainScore is 28cp, smallChainScore is 20cp, both are defined in eval.h ScoreChains() is called in score_pawns.c

As for macros, bbPc(p,sd,P) returns all the pawns of the side sd in the position p. RelSqBb(E4,sd) returns a bitboard of a single square - E4 for white, E5 for black. Chains we are talking about are encoded as black chains.
Thanks Pawel.
Very useful.

Programmers, especially SF programmers, take a look at Rodent's github repository, as this is the future of chess. :D
carldaman
Posts: 2287
Joined: Sat Jun 02, 2012 2:13 am

Re: extending the chain (part 3)

Post by carldaman »

Lyudmil Tsvetkov wrote:
carldaman wrote:
PK wrote:OK, there is something that actually helps Rodent a bit. Chains of three pawns pointing towards king side, as specified by Lyudmil, get a bonus of 20 centipawns provided that the enemy king is there. Furthermore, that bonus climbs to 28 cp if there is an nemy pawn on the "congestion point" as defined by Carl. I have made another adjustement that makes the code a bit messy, namely the chains whose spearhead is on the 4th rank need two opposing pawns to obtain the second bonus.

To make this work, I needed to reduce speed overhead by hashing pawn chains eval. Rodent already had king and pawn hashtable that became a bit bloated as a result. Right now it keeps passer eval (midgame and endgame), pawn structure eval (ditto), king shield (midgame only) and separately chain eval (midgame only).

There are many things to tweak (increasing pawn storm bonus comes to mind, as in the KID positions with the chain in place Rodent sometimes attacks with the "g" pawn, sometimes not), but I'm glad that the basic formula finally brought some benefit.
Very interesting and encouraging developments, Pawel. I've always thought you'd be among the likeliest candidates to not only take on this challenge, but to also succeed. :)

My recommendation is to give an extra bonus for storming with the g and h pawns when the extended chain conditions are already in place.

Regards,
CL
You are right, Pawel is my hero, especially if he provides some further info.

From now on, I will be playing only with Rodent. :)

Do you see the Stockfish guys, Carl?

When it comes about implementing simple and mostly useless patches, they are the first to push a test, but when there is a real challenge, like the good knowledge of implementing a pointed chain eval, that would benefit positional chess analysis very much, and users would definitely like it, they all disappear into thin air.

Where are you, Ralph, Joerg, Stefan?
Rodent is already leaps and bounds in front of SF in terms of positional knowledge. :shock:

I think Rodent showed the way: it is evident now, that you can implement sound knowledge like pointed chains/triades, even when the engine search is not optimal for such eval factors, and still get some marginal value, in case you find a way to minimise the overhead, as Pawel says. In case some factors like triades are more rare to appear on the board, you might even suffer in terms of elo from such implementation, but, if you do a wise thing like hashing pawn chains, then a similar patch might also succeed as computational costs would be lower.

I really do not imagine, if SF for the time being does not even have pointed chain and longer chain eval, when they will start tackling the much more difficult concepts like closed positions (as pointed chains and closed positions are not synonymous), square control, positional compensation?

I hope Pawel says a bit more about this, but, I think no one can dispute, that if he managed to gain close to 1 elo from triades, then the pointed chain/longer chains concept promises some 49 elo more, until you get to 50, as this term is objectively worth some 50 elo points.
Hi Lyudmil,
Arjun T. of the Stockfish team wrote some promising things last year, about taking the approach of tying the directional chains to king safety, but then the whole discussion fizzled out. On the whole, I do think the SF contributorship have been conditioned to only tackle the simplest changes, and avoid any 'ad hoc hacks' almost at all cost. It is a culture of 'flight from (eval term) complexity' that reigns supreme over there, coupled with some downright hostility and contempt towards us 'ignorant non-programmer types'. Well, maybe not always, but sometimes for sure...

On the other hand, if you recall, about a year ago I did bring up one name as someone who might be inclined to turn a sympathetic ear to your suggestions, and then possibly implement them, too. That individual was ... Pawel Koziol of Rodent and Glass fame. :) It turns out I was a good judge of brilliant minds. :D

Cheers,
CL
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: extending the chain (part 3)

Post by cdani »

Finally I tried this on Andscacs, but without luck :-(

Code: Select all

#define pc1 25
#define pc2 20
	//pointy chains
	if (COL(opponent_king) >= 4) {
		if (me == white) {
			if ((Pawns(white) & 0x1008040000ULL) == 0x1008040000ULL) { //c3 d4 e5
				i += ((Pawns(black) & 0x100800000000ULL) == 0x100800000000ULL) ? pc1 : pc2; //d5 e6
			}
			if ((Pawns(white) & 0x201008000000ULL) == 0x201008000000ULL) { //d4 e5 f6
				i += ((Pawns(black) & E6) == E6) ? pc1 : pc2;
			}
			if ((Pawns(white) & 0x2010080000ULL) == 0x2010080000ULL) { //d3 e4 f5
				i += ((Pawns(black) & 0x1008000000ULL) == 0x1008000000ULL) ? pc1 : pc2; //d4 e5
			}
			if ((Pawns(white) & 0x402010000000ULL) == 0x402010000000ULL) { //e4 f5 g6
				i += ((Pawns(black) & F6) == F6) ? pc1 : pc2;
			}
		}
		else {
			if ((Pawns(black) & 0x40810000000ULL) == 0x40810000000ULL) { //c6 d5 e4
				i += ((Pawns(white) & 0x8100000ULL) == 0x8100000ULL) ? pc1 : pc2; //d4 e3
			}
			if ((Pawns(black) & 0x810200000ULL) == 0x810200000ULL) { //d5 e4 f3
				i += ((Pawns(white) & E3) == E3) ? pc1 : pc2;
			}
			if ((Pawns(black) & 0x81020000000ULL) == 0x81020000000ULL) { //d6 e5 f4
				i += ((Pawns(white) & 0x810000000ULL) == 0x810000000ULL) ? pc1 : pc2; //d5 e4
			}
			if ((Pawns(black) & 0x1020400000ULL) == 0x1020400000ULL) { //e5 f4 g3
				i += ((Pawns(white) & F3) == F3) ? pc1 : pc2;
			}
		}
	}
Also tried with 15 and 10. May be I will try with even lower bonus.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: extending the chain (part 3)

Post by Lyudmil Tsvetkov »

cdani wrote:Finally I tried this on Andscacs, but without luck :-(

Code: Select all

#define pc1 25
#define pc2 20
	//pointy chains
	if (COL(opponent_king) >= 4) {
		if (me == white) {
			if ((Pawns(white) & 0x1008040000ULL) == 0x1008040000ULL) { //c3 d4 e5
				i += ((Pawns(black) & 0x100800000000ULL) == 0x100800000000ULL) ? pc1 : pc2; //d5 e6
			}
			if ((Pawns(white) & 0x201008000000ULL) == 0x201008000000ULL) { //d4 e5 f6
				i += ((Pawns(black) & E6) == E6) ? pc1 : pc2;
			}
			if ((Pawns(white) & 0x2010080000ULL) == 0x2010080000ULL) { //d3 e4 f5
				i += ((Pawns(black) & 0x1008000000ULL) == 0x1008000000ULL) ? pc1 : pc2; //d4 e5
			}
			if ((Pawns(white) & 0x402010000000ULL) == 0x402010000000ULL) { //e4 f5 g6
				i += ((Pawns(black) & F6) == F6) ? pc1 : pc2;
			}
		}
		else {
			if ((Pawns(black) & 0x40810000000ULL) == 0x40810000000ULL) { //c6 d5 e4
				i += ((Pawns(white) & 0x8100000ULL) == 0x8100000ULL) ? pc1 : pc2; //d4 e3
			}
			if ((Pawns(black) & 0x810200000ULL) == 0x810200000ULL) { //d5 e4 f3
				i += ((Pawns(white) & E3) == E3) ? pc1 : pc2;
			}
			if ((Pawns(black) & 0x81020000000ULL) == 0x81020000000ULL) { //d6 e5 f4
				i += ((Pawns(white) & 0x810000000ULL) == 0x810000000ULL) ? pc1 : pc2; //d5 e4
			}
			if ((Pawns(black) & 0x1020400000ULL) == 0x1020400000ULL) { //e5 f4 g3
				i += ((Pawns(white) & F3) == F3) ? pc1 : pc2;
			}
		}
	}
Also tried with 15 and 10. May be I will try with even lower bonus.
Thanks Daniel.

No way to succeed that quickly. You should have started one month ago, when Pawel started to fiddle with the idea. :D

Pawel was splitting eval to pointed chains with some pawns blocked and pointed chains with a single/no pawns blocked, something like that.
Maybe he could be so kind to explain again.
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: extending the chain (part 3)

Post by cdani »

Lyudmil Tsvetkov wrote: Pawel was splitting eval to pointed chains with some pawns blocked and pointed chains with a single/no pawns blocked, something like that.
Yes, it's exactly what I have done :-)

Code: Select all

 if ((Pawns(white) & 0x1008040000ULL) == 0x1008040000ULL) { //c3 d4 e5 
means "if there are white pawns at c3, d4 and e5",

Code: Select all

i += ((Pawns(black) & 0x100800000000ULL) == 0x100800000000ULL) ? pc1 : pc2; //d5 e6 
then add pc1 (25) if there are also black pawns at d5 and e6, or pc2 (20) if not.