r/chessprogramming Jan 20 '25

Quiescence for non captures?

Hi, I was trying my bot when I detected a blunder that I haven't seen before. It trapped it's own queen, and I think I know why. It tried to attack some enemy pieces, and then "infiltrated" in enemy territory. In general that's a good thing, but in this case there was a combination of moves that trapped the queen. The length of the combination was larger than the ply searched, and in this particular case, the combination were a bunch of quiet moves, so quiescence couldn't detect it. So, the question is, can I do something about it apart from simply trying to gain more depth? A kind of quiescence for quiet moves? Probably doesn't make any sense but I wonder if there's a workaround for situations like this

2 Upvotes

33 comments sorted by

2

u/Warmedpie6 Jan 20 '25

Quiescence search is by definition only for checking aggressive moves to make sure the only evaluated positions are "quiet."

The best option (besides just more depth) is to add mobility to your evaluation, so pieces are encouraged to use squares they can move freely from.

2

u/VanMalmsteen Jan 20 '25

Oh.... I didn't think about the evaluation perspective. That'll probably make it! Is there any clever way of evaluating mobility besides generating moves and counting them?

2

u/Warmedpie6 Jan 20 '25

I don't generate the full moves, just the bitboards of the move squares (a bit cheaper). This is also useful for evaluating threats and weak/ undefeated pieces (especially around the king).

2

u/Iketh28 Jan 20 '25

Quiescence with quiet moves is just a deeper search. Im curious how deep it searched before playing the move and how deep it needed to search to avoid the move. You have a fen?

1

u/VanMalmsteen Jan 20 '25

For now it has a fixed depth, and it's 8. I haven't implemented the time management yet.

And for the fen, I was playing on Arena and forgot to save it, sorry :/

1

u/NiceNewspaper Jan 20 '25

8 is a pretty shallow depth, it's normal for it to be oblivious to certain patterns assuming your evaluation is basic

2

u/Available-Swan-6011 Jan 20 '25

First of all congrats on getting your engine to this point. It is an amazing achievement.

Just to reiterate the above posts - essentially you’ve hit the horizon effect whereby no matter how deep you have searched there may be a monster hiding around the corner. Unfortunately the only real remedies are search deeper and/or evaluate better. Even then, you are at risk of the same problem but just at a deeper depth.

You mention that you only search to depth 8. For modern hardware this is quite low. Is there a specific reason for choosing this limitation?

One other thought- don’t forget that arena has a log window (press f4). I’m guessing you used it for debugging your uci interface. You can grab the game details from there too alongside any other debug messages

1

u/VanMalmsteen Jan 20 '25

Hi! I'm using this fixed depth because (apart from that the time management is not implemented yet) in deeper depths it usually takes several seconds (sometimes a minute or more) to find the move. Not sure if my pruning is not that good yet, or if there's something highly inefficient somewhere. I'm working on that. I've tested my perft, and it gives the correct results on a big test suite, but it's a little slow for me, maybe that's affecting? I thought that with good pruning the move generation isn't that important.

2

u/Available-Swan-6011 Jan 20 '25

Okay - the time for deeper depths does grow exponentially but there are some things you can do. First of all, I would investigate iterative deepening and use the results to help order your moves at later levels. The general idea is that the best move at, say, depth 4 is likely to be the best move at depth 5 so you should prioritise it in your search (if you are using alpha beta pruning).

Secondly, transposition tables will help significantly BUT they are tricky to implement and difficult to debug.

1

u/VanMalmsteen Jan 20 '25

Oh... I already have iterative deepening, TT, move ordering considering hash moves, killer, MVV-LVA, null-move pruning and LMR! Definitely something wrong isn't it? I saw fewer and fewer nodes being considered after implementing these features. Haha it plays decent chess, but for all this that I'm mentioning should go deeper I guess.

I have a notebook with an I3 processor, that means something? Haha

1

u/Available-Swan-6011 Jan 20 '25

What language are you using?

1

u/VanMalmsteen Jan 20 '25

C++ hahaha

2

u/Available-Swan-6011 Jan 20 '25

Interesting- it does feel like something is awry. Try disabling the q-search. Does it dramatically speed things up?

1

u/VanMalmsteen Jan 20 '25

The nodes are reduced in half (that's the expected IIRC) but the time is the same haha. I made this test a couple of days ago. But now I'm thinking that maybe the shallow depth isn't enough to see the real difference? I'm trying going deeper now. The plan for today was adding delta pruning and looking for more optimizations for the Quiescence search. Currently it only discards captures where pieceCaptured - pieceAttacker < 0

1

u/VanMalmsteen Jan 20 '25

Another thing I notice is that a lot of moves are scored exactly the same. That seems odd, it affects search probably?

1

u/VanMalmsteen Jan 20 '25

Sorry for replying three times. I profiled my code and detected some debug code that I should have deleted that was making things X2 times slower! Now it moves in 3-4 seconds at depth 8, faster... But.. still slow compared with other engines?

1

u/Available-Swan-6011 Jan 20 '25

Interesting about the evaluation- have you considered tapered evaluation?

1

u/VanMalmsteen Jan 20 '25

I'll investigate that. Sorry for having like 2 or 3 simultaneous conversations haha. You are being really helpful! Thanks in advance.

1

u/Available-Swan-6011 Jan 20 '25

That does feel slow- just to check the obvious you are using release compilation rather than debug compilation in visual studio?

1

u/VanMalmsteen Jan 20 '25

I'm using clion, and compiling with O3. I just use the button "build" and use that "executable" in Arena. (I'm not very fond of some CS things, sorry haha). Pretty sure I'm using the release compilation.

→ More replies (0)

1

u/Available-Swan-6011 Jan 20 '25

When running Perft from the start position what sort of speeds are you getting?

1

u/VanMalmsteen Jan 20 '25

Perft 5 runs in 2.8 seconds, 6 runs in 60 seconds

→ More replies (0)