Progress on Blunder

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

Moderator: Ras

Chessqueen
Posts: 5685
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: Blunder now has a logo

Post by Chessqueen »

algerbrex wrote: Mon Jun 13, 2022 4:59 pm
mvanthoor wrote: Mon Jun 13, 2022 4:26 pm As I said, the kerning problem on my logo is tiny, and indicative of the font I used. The "u" is a bit too far to the right; because the bend curves inward, the spacing between the bottom right foot of the "R" and the curve on the left of the "u" is a bit too large. Same problem on the bottom foot of the "i" and the curve of the "c". The U and C maybe need to move over by only 10 pixels or so to fix it.
Ah, I see a bit more of what you mean.
mvanthoor wrote: Mon Jun 13, 2022 4:26 pm When I did that LaTeX tutorial, it pointed out some notable differences between LaTeX kerning / typography and the lack thereof in Word (at the time). Because of that I looked into typography some more. I know just enough to be dangerous and see some common or obvious imperfections here and there. Don't ask me to design a font though.
Well if I do end up going down an applied math right like I am right now, I'm sure I'll be encountering a lot more LaTex, and I'll get an eye for these sorts of these things :lol:

By the way, I noticed you hadn't had an opportunity to release Rustic 4 yet.
It will take a few years for Blunder to make no more Blunders and you will have to change the name to NoBlunder :lol: :roll: :mrgreen:
User avatar
algerbrex
Posts: 608
Joined: Sun May 30, 2021 5:03 am
Location: United States
Full name: Christian Dean

Re: Blunder now has a logo

Post by algerbrex »

Chessqueen wrote: Mon Jun 13, 2022 5:30 pm It will take a few years for Blunder to make no more Blunders and you will have to change the name to NoBlunder :lol: :roll: :mrgreen:
Haha, I suppose so. Although I did envision the name being comically ironic in the future when Blunder was quite strong!
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Blunder now has a logo

Post by mvanthoor »

algerbrex wrote: Mon Jun 13, 2022 4:59 pm Well if I do end up going down an applied math right like I am right now, I'm sure I'll be encountering a lot more LaTex, and I'll get an eye for these sorts of these things :lol:
I'm sure you will; if you get to work with LaTeX and see the beautiful (someone else could say "old-fashioned") pages it puts out, you'll come to loath Microsoft Word's default output. It _can_ be made better with better fonts, ligature support and a load of settings, but it still can't keep up with what LaTeX can do. Not even mentioning the horrible way of formatting documents in Word, with styles and such...

LaTeX is much more akin to a somewhat more complicated version of HTML + CSS. If you understand HTML and CSS, you understand how LaTeX (= "HTML") and its templates (= "CSS") works. I wish someone would actually combine Markdown and CSS in an editor as a less complicated / web-ready counterpart of Latex/templates.
By the way, I noticed you hadn't had an opportunity to release Rustic 4 yet.
You may also have noticed that I barely posted on the forums in the last few months. I haven't written anything for Rustic for months because of a lack of free time. I spent the bit time I had outside of work on other things but chess programming. Let's just say; life happened. Nothing bad though; just lots of work, and lots of other things to do that take a more important priority than the hobby of chess programming. One of those things was getting back in the gym for 4-6 hours a week after the pandemic, like I used to. No exercise + Same Eating Habits = Weight Gain and that has to be undone. (One of the reasons why I could write Rustic in 2020 and part of 2021 was because of the pandemic: the lockdowns and working from home "gave" me about 16 hours a week I otherwise would have spent in the gym or commuting.)

Rustic is still alive though, XBoard has been implemented for 80%, maybe 90% and that part has been tested. Only GameTime to go. Also, a massive refactoring has been done in preparation to, some day, split large parts of the engine off into a chess library so that library can be used as the backend of a user interface and in a new replacement for PicoChess to drive electronic (mainly DGT) chess boards.

This stuff (Rustic, GUI / database, PicoChess replacement) is going to keep me busy in my spare time for the next 15 years or so. I recommend not holding your breath. But that's why it's a hobby, and I primarily do it for me, myself and I. Someone else may find it useful though.
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
User avatar
algerbrex
Posts: 608
Joined: Sun May 30, 2021 5:03 am
Location: United States
Full name: Christian Dean

Re: Blunder now has a logo

Post by algerbrex »

mvanthoor wrote: Mon Jun 13, 2022 11:34 pm I'm sure you will; if you get to work with LaTeX and see the beautiful (someone else could say "old-fashioned") pages it puts out, you'll come to loath Microsoft Word's default output. It _can_ be made better with better fonts, ligature support and a load of settings, but it still can't keep up with what LaTeX can do. Not even mentioning the horrible way of formatting documents in Word, with styles and such...

LaTeX is much more akin to a somewhat more complicated version of HTML + CSS. If you understand HTML and CSS, you understand how LaTeX (= "HTML") and its templates (= "CSS") works. I wish someone would actually combine Markdown and CSS in an editor as a less complicated / web-ready counterpart of Latex/templates.
That's interesting. I had no clue there was any connection between the two. I'm not experienced in either HTML or CSS, but I'm quite familiar with both, so I may spend some time getting comfortable with LaTex this summer as well.
mvanthoor wrote: Mon Jun 13, 2022 11:34 pm You may also have noticed that I barely posted on the forums in the last few months. I haven't written anything for Rustic for months because of a lack of free time. I spent the bit time I had outside of work on other things but chess programming. Let's just say; life happened. Nothing bad though; just lots of work, and lots of other things to do that take a more important priority than the hobby of chess programming. Rustic is still alive though, XBoard has been implemented for 80%, maybe 90% and that part has been tested. Only GameTime to go. Also, a massive refactoring has been done in preparation to, some day, split large parts of the engine off into a chess library so that library can be used as the backend of a user interface and in a new replacement for PicoChess to drive electronic (mainly DGT) chess boards.

This stuff (Rustic, GUI / database, PicoChess replacement) is going to keep me busy in my spare time for the next 15 years or so. I recommend not holding your breath. But that's why it's a hobby, and I primarily do it for me, myself and I. Someone else may find it useful though.
Of course.

I only started back seriously working on Blunder this past month, and even less recently coming back to these forums to poke around. Between sports, studies, job training, relationships, and socializing, Blunder had to go to the back burner for a good 5-6 months. Actually, I wasn't sure I was going to even start working on it again before the summer was out, which would mean it would've been a good year and half or so before I came back to it. Just started up again because I found the time and got into chess again.

It's definitely nice to have a long-term project to come back to and work on, and I suspect Blunder will be that for me for the next couple of years, depending on how much time I get during the school year and the summer. It's a nice contrast to most of the old projects I have lying around on various thumbdrives that haven't and likely won't be touched again for the foreseeable future.
Chessqueen
Posts: 5685
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: Blunder now has a logo

Post by Chessqueen »

algerbrex wrote: Mon Jun 13, 2022 7:07 pm
Chessqueen wrote: Mon Jun 13, 2022 5:30 pm It will take a few years for Blunder to make no more Blunders and you will have to change the name to NoBlunder :lol: :roll: :mrgreen:
Haha, I suppose so. Although I did envision the name being comically ironic in the future when Blunder was quite strong!
https://github.com/algerbrex/blunder#:~ ... %20project.

Thanks for releasing it I will test it against Shredder8 Next
Chessqueen
Posts: 5685
Joined: Wed Sep 05, 2018 2:16 am
Location: Moving
Full name: Jorge Picado

Re: Blunder now has a logo

Post by Chessqueen »

algerbrex wrote: Mon Jun 13, 2022 7:07 pm
Chessqueen wrote: Mon Jun 13, 2022 5:30 pm It will take a few years for Blunder to make no more Blunders and you will have to change the name to NoBlunder :lol: :roll: :mrgreen:
Haha, I suppose so. Although I did envision the name being comically ironic in the future when Blunder was quite strong!
Just wonder which of these two bad movers will blunder the most :roll:
[pgn][Event "Computer chess game"]
[Site "DESKTOP-OFQ3C0P"]
[Date "2022.06.13"]
[Round "?"]
[White "Buggy-win64"]
[Black "Blunder-windows"]
[Result "?"]
[BlackElo "2630"]
[ECO "D97"]
[Opening "Grünfeld"]
[Time "18:13:54"]
[Variation "Russian, Alekhine, 8.e5 b5 9.Qb3"]
[WhiteElo "2650"]
[TimeControl "900+10"]
[Termination "unterminated"]
[PlyCount "16"]
[WhiteType "program"]
[BlackType "program"]

1. Nf3 (1. d4 Nf6 2. c4 g6 3. Nc3 d5 4. Nf3 Bg7 5. Qb3 dxc4 6. Qxc4 O-O 7.
e4 a6 8. e5 b5 9. Qb3 {(c4b3 c8e6 b3a3 f6d5) +0.55/17 41} Be6 {(Bc8-e6
Qb3-a3 Nf6-d5 Bf1xb5 c7-c5 d4xc5 Nd5xc3 b2xc3 a6xb5 Qa3xa8 Be6-d5 Qa8-a3
Nb8-c6 c3-c4 Bd5xf3 Qa3xf3 Nc6xe5 Qf3-d5 Ne5-d3+ Ke1-e2 Bg7xa1 Qd5xd3 b5xc4
Qd3xc4) -0.17/20 29} 10. Qa3 {(b3a3 f6d5 f1b5 c7c5 d4c5) +0.55/18 40} Nd5
{(Nf6-d5 Bf1xb5 c7-c5 d4xc5 Nd5xc3 b2xc3 Qd8-d5 Bb5-e2 Nb8-c6 O-O Nc6xe5
Nf3-g5 Be6-f5 Rf1-d1 Qd5-c6 Bc1-e3 Rf8-e8 Ng5-f3 Ne5xf3+ Be2xf3 Bf5-e4
Bf3xe4 Qc6xe4) -0.45/21 37} 11. Bxb5 {(f1b5 c7c5 b5a4 b8d7 a4d7 d8d7)
+0.70/17 46} c5 {(c7-c5) -0.25/20 28}) 1. .. d5 2. c4 e6 3. g3 Nf6 4. d4
dxc4 5. Bg2 a6 6. Ne5 c5 7. Na3 cxd4 8. Naxc4 Bc5 *[/pgn]
User avatar
algerbrex
Posts: 608
Joined: Sun May 30, 2021 5:03 am
Location: United States
Full name: Christian Dean

Re: Blunder now has a logo

Post by algerbrex »

Chessqueen wrote: Tue Jun 14, 2022 12:36 am
algerbrex wrote: Mon Jun 13, 2022 7:07 pm
Chessqueen wrote: Mon Jun 13, 2022 5:30 pm It will take a few years for Blunder to make no more Blunders and you will have to change the name to NoBlunder :lol: :roll: :mrgreen:
Haha, I suppose so. Although I did envision the name being comically ironic in the future when Blunder was quite strong!
https://github.com/algerbrex/blunder#:~ ... %20project.

Thanks for releasing it I will test it against Shredder8 Next
Cool, thanks :) I'm not familiar with Shredder8's strength, but hopefully, it'll be a good set of matches.
User avatar
algerbrex
Posts: 608
Joined: Sun May 30, 2021 5:03 am
Location: United States
Full name: Christian Dean

Tuning King Safety with Gradient Descent

Post by algerbrex »

As some of you might know, I recently upgraded my tuner to utilize gradient descent. This new tuner worked quite well, and found material and PSQT evaluation terms that were 60 Elo stronger than the ones I used back in Blunder 7.2.0. I also went ahead and upgraded it to use AdaGrad, which proved to be useful as it kept the error rate from oscillating so much during tuning.

With this, I decided to take the plunge and see if I could get king safety working with the tuner, and surprisingly I was able to get it working fairly quickly, and the addition of the king safety evaluation terms was worth about 50 Elo.

Firstly, I had to decide what approach I wanted to use to add king safety knowledge to the evaluation since there were several options. I ultimately opted for starting out as simple as possible and using the approach of collecting attack points for white and black, which would then be used to calculate a final score depending on the severity of the attack. This is of course one of the approaches outlined in the CPW, and the original one I used in Blunder 7.6.0.

The model I ultimately decided on was:

Code: Select all

attackScore = (attackPoints^2) / 4
The attack points are computed incrementally along with the mobility. The amount of squares a piece attacks around the enemy king is weighted against certain values depending on the piece (bigger values for major pieces, smaller values for minors), and then they're incrementally summed together and then plugged into the formula above.

I then had to re-compute my formula for partial derivatives for each evaluation weight, based on that model. The addition of king safety meant that the evaluation could no longer be written as strictly the dot product between a single vector of weights and coefficients. I had to break my weights into two different types, normal weights, and safety weights. The normal weights could be computed using the old formula for partial derivatives, but the safety weight partials were slightly different. The math is a little hard to type out in any sensible way in plain text, so I'm currently working on a little LaTex document that'll be added to the Blunder repository soon that outlines all the math and the idea behind things. None of this is particularly novel of course, but hopefully, this document will be useful for those who were in the position I was in a couple of weeks ago.

Not quite sure when the release date for Blunder 8.0.0 is, although things are looking good and I'm happy with the progress I'm making. Blunder 8.0.0 is currently still weaker than 7.6.0 as I'm intentionally building from the ground up and don't yet have certain features in the dev version that I do in 7.6.0. The gap is closing however, and it's looking like Blunder 8.0.0 will be a pretty nice strength increase over the latest version.
User avatar
lithander
Posts: 918
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Progress on Blunder

Post by lithander »

Sounds like you're making great progress! I'm really curious how strong Blunder 8 will end up being. Is it going to have feature parity with 7.6?

Maybe King Safety is especially complicated (Leorik doesn't use it yet) or maybe it's because I didn't take a calculus course recently but I don't understand why you can't just use the same simple tuner that basically only multiplies a vector of features with a vector of weights and optimizes those weights to minimize the MSE. I just add "pawn structure" features to the vector and "mobility" features and as the size of the feature-vector increases I also get more weights that I then use to guide my actual implementation that's used in the engine. It reminds me of the saying: "when you have a hammer, everything looks like a nail" but so far it seems to work well enough.
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
User avatar
algerbrex
Posts: 608
Joined: Sun May 30, 2021 5:03 am
Location: United States
Full name: Christian Dean

Re: Progress on Blunder

Post by algerbrex »

lithander wrote: Sat Jun 18, 2022 3:53 am Sounds like you're making great progress! I'm really curious how strong Blunder 8 will end up being. Is it going to have feature parity with 7.6?
Thanks! The plan is that it will have feature parity, plus IID. But I don't expect IID to contribute much, since it only got about ~13 Elo in self-play.
lithander wrote: Sat Jun 18, 2022 3:53 am Maybe King Safety is especially complicated (Leorik doesn't use it yet) or maybe it's because I didn't take a calculus course recently but I don't understand why you can't just use the same simple tuner that basically only multiplies a vector of features with a vector of weights and optimizes those weights to minimize the MSE. I just add "pawn structure" features to the vector and "mobility" features and as the size of the feature-vector increases I also get more weights that I then use to guide my actual implementation that's used in the engine. It reminds me of the saying: "when you have a hammer, everything looks like a nail" but so far it seems to work well enough.
Well, you technically could, depending on the approach you wanted to take for calculating king safety. But for most of the approaches I've seen, modeling the evaluation as just the dot product between a weight and feature vector wouldn't quite work.

The reason why is because, unlike the normal weights, the weights I have that are related to king safety are not directly taken and folded into the middle and endgame score. Instead, they're first plugged into the formula I showed above, and then added to the total evaluation score. This seems like it shouldn't make things that much more complicated, but as far as I could think of, I couldn't find a clever way to model this using only the dot product between the weights and the features vector. Because what corresponding entries would go in the feature vector?

To explain a little more, the extra weights I added were these:

Code: Select all

var OuterRingAttackPoints = [5]int16{0, 1, 0, 1, 1}
var InnerRingAttackPoints = [5]int16{0, 3, 4, 5, 3}
Which are the bonuses multiplied by the number of squares a piece attacks around the king, indexed by piece type. For example, the queen:

Code: Select all

outerRingAttacks := moves & eval.KingZones[color^1].OuterRing
innerRingAttacks := moves & eval.KingZones[color^1].InnerRing

if outerRingAttacks != 0 || innerRingAttacks != 0 {
	eval.KingAttackers[color]++
	eval.KingAttackPoints[color] += uint16(outerRingAttacks.CountBits()) * uint16(OuterRingAttackPoints[Queen])
	eval.KingAttackPoints[color] += uint16(innerRingAttacks.CountBits()) * uint16(InnerRingAttackPoints[Queen])
}
And for each king:

Code: Select all

evalKing(pos, White, pos.Pieces[White][King].Msb(), &eval)
evalKing(pos, Black, pos.Pieces[Black][King].Msb(), &eval)
The king safety penalty is computed:

Code: Select all

// Evaluate the score of a king.
func evalKing(pos *Position, color, sq uint8, eval *Eval) {
	// Take all the king saftey points collected for the enemy,
	// and see what kind of penatly we should get.
	enemyPoints := eval.KingAttackPoints[color^1]
	penatly := int16((enemyPoints * enemyPoints) / 4)
	if eval.KingAttackers[color^1] >= 2 && pos.Pieces[color^1][Queen] != 0 {
		eval.MGScores[color] -= penatly
	}
}
Now suppose we took the normal approach and computed the difference between the total number of squares a white knight is attacking in the outer ring, minus the total number of squares a black knight is attacking, the difference between the total numbers of squares a white bishop is attacking, minus the total number of squares a black bishop is attacking, etc. And suppose we got a feature vector where part of it looked like this:

Code: Select all

[. . . -1 2 -2 5 4 2 1 1 . . .]
Which means there's one total black knight outer ring attack, 2 total white bishop outer ring attacks, etc. Now if we're doing things normally, we'd just compute the dot product between the above section of the features vector times the corresponding weights in the weight vector:

Code: Select all

[. . . 1 0 1 1 3 4 5 3 . . .]
Which gives 30. Now, 30 isn't the right answer. If we're following the above formula we'd need to square 30 and then divide it by 4. But as soon as we do this, we're no longer strictly computing the dot product. We're computing the dot product plus the dot product of those specific parts of the weight and feature vectors, squared. But that means our evaluation function model is now different, and so the partial derivative will be different as well. And there's no way to "fold" the squaring into each individual feature so we can keep using only the dot product since the operation of taking the square doesn't distribute like addition or multiplication, or division.

Let me know if that helps at all since I know it was a lot. Also let me know if I'm missing something obvious here since I had to spend the better part of yesterday evening working on this, so I might have some tunnel vision.

It'd be interesting to try to come up with a king safety evaluation that's only linear. I'm not aware of a current approach that strictly is, and any approach I tried to come up with didn't capture the notation of king safety being a non-linear score, where the score inflates exponentially. This was an approach to the problem I didn't spend as much time on, since I better knew how to tackle the problem of computing new partials. Perhaps following the spirit of Leorik you could come up with something a bit more novel and keep the evaluation strictly linear. :)