hgm wrote: ↑
Tue Jan 12, 2021 9:32 pm
I was just curious how it could make so much difference. Potentially such a routine could be used for many purposes.
It does seem to me, though, that guarding against moving into check can be done more efficiently even with a mailbox engine then by calling a general IsSquareAttacked() routine for every generated move, even if the latter routine is a very fast one. I can even imagine that not checking for this at all, and just leave it for the move generation in the daughter node to detect the King capture, would be faster. On the average you would detect it after half a move generation, which is pretty expensive, but the fraction of moves that actually does expose your King to capture is quite small. And on all the other moves you would have reduced the overhead to zero. So on average per move it could still be very cheap.
But in more advanced engines I usually do detect pinned pieces before I start move generation, and then limit the generation of moves with those pieces to those along the pin ray. The pin detection is still quite fast even with mailbox, as in most cases the enemy sliders are not even positioned such that they could give check on an otherwise empty board, and in case there is a pin you gain back some time by not having to generate the moves that are doomed to be rejected later after testing. Then it is only the King moves that could potentially stumble into check. And there are few of those, and often even fewer that you actually need to search (as they are usually not very good, and thus sorted somewhere in the back, where you might never get to). And of course I defer the testing to after it is decided they should be searched. And once a move will be searched, that search (even if it is just 1 ply deep) should always require far more time than a simple IsSquareAttacked(), no matter how inefficiently the latter is programmed.
I'm deeply impressed by your microMax king capture implementation - making beta cutoff on king capture is a very bold original idea.
My engines feels a big lack of efficiency all along the way. Even if I go for your approach regarding isSquareAttacked() or ideas regarding
hashing null moves - this would be after I would be fully understanding what an I doing. You know like for me chess programming is a way
to fight my natural dumbness. When I read your ideas - I feel very impressed on the one had and very stupid on the other)
When I just started I didn't understand I don't know... around 70% of what am I doing believe it or not.
Now I finally came to the stage when I can understand 99% of my own code (still have some white spaces with understanding how collecting PV works and maybe a couple more minor things that does not affect speed/strength)
And it's already a great result for me.
I just can't learn how normal people do - like take a subject, learn essence and then consciously applying it to the subject, no
I can do things only in what I call code monkey king's way - just pick up an existing pattern and try to learn in by repeating as
many times as needed to understand it - thats the reason why I have many engines)
I tried Vive's and microMax's patterns. First is too extensive, second is too obfuscated, so as soon as I've realized all the needed
bricks to build a move generator I've started creating my own pattern and WukongJS represents the latest form of it.
Then I started looking for search/eval patterns.
The most lovely eval pattern I took from PeSTO by Ronald Friederich - he and some other guys explained to me how to implement
tapered evaluation and I'm using it since then. Also Ronald explained to me the most basic texel's tuning pattern which I'm exploring now.
Regarding search I'm getting inspired by CPW engine's pattern which is simplified Crafty pattern in essence.
As far as I'm getting my own experience I'm starting to change the search pattern on my own.
So the main issue I have while reading brilliant answers here on talkchess is that those answers go beyond patterns
which needs totally different type of consciousness to understand and make use of them.
Just an example - I've started understanding your questions partially only after working out microMax's pattern to
get an idea you you think in particular. I've made 3 engines based on microMax (better to call them move generators for
they don't even have a quiescence search) and even one movegen in NASM assembly) All this took me about half a year.
This pattern based way of learning is more eastern than western way. I'm a long term practioner of traditional Chinese martial arts
(for health, not for fight) - and they are totally build of patterns, they call it "forms". Forms brought together formulate form sets,
just like engine's parts formulate actual engine. But CHinese forms mostly work with the body ,while consciousness is left untouched.
Chess programming helps me work out my consciousness just like I do with the body)
Your recent interest to my experiments is very surprising and flattering) Thank you)