Futility Pruning Issue

Code, algorithms, languages, construction...
Post Reply
osmanre263
Posts: 1
Joined: Fri Nov 24, 2017 4:13 pm
Real Name: Ozmania

Futility Pruning Issue

Post by osmanre263 » Fri Nov 24, 2017 4:40 pm

Hello all,

I've written a simple engine in Lua (yes it is definitely not fast at all) and it includes AlphaBeta, LMR, PVS, FutilityPruning, Delta Pruning, History Heuristics, etc etc... I came across a position I was testing my engine against and it horribly blundered, missing a mate in 2. In the following position it chose to capture the knight on d4 with the bishop on d6 instead of trying to protect the king from mate.

I'm sure an obvious issue is recuse of the shallow depths my engine searches but I decided to try and narrow down the problem. After commenting out pvs,lmr,delta pruning,aspiration windows and having a stripped down alpha beta search, I found out the issue was from the futility code I have.

The engine found a correct move after depth 3 to try to avoid mate after I removed futility pruning. I tried adjusting the margins and that did seem to help but I had to add atleast two full pawns for each margin which doesn't seem right. I'm not sure if the other parts of the search are affecting the evaluation of the position but any ideas are welcome! I'm sure this question is a bit too broad but I'm hoping for some insight into what I may be doing wrong! Thanks!

I have also included the pv of before and after I commented out the futility code.
Before:
https://i.imgur.com/fZC1AjN.png

After:
https://i.imgur.com/il6Dmoy.png


--Problem Code--

/*
if its not a pv node
and king is not in check
and is not a capture
and depth less than or equal to 3
*/

if not PvNode
and not InCheck()
and not ISCAP(srch_currentMove)
and depth <= 3 then
local eval = Evaluate()
local margins = {0,PieceVal[wB],PieceVal[wR],PieceVal[wQ]} --also tested margins by adding atleast 200 which somewhat helped..
if eval + margins[depth+1] <= alpha then
return eval
end
end
end

-----

My engine plays as black.

Position FEN:

6k1/1ppbQppp/1b3p2/p7/P2N3P/1P1P1PB1/2P3PK/q7 b - - 0 32

Game: https://pastebin.com/raw/9Ni9HvtJ

Post Reply