Manuel Peña wrote:In Rebel programmer stuff says:
"There is another move ordering trick worth to mention. REBEL has special code to recognize mate-threats in its evaluation part (EVAL), have a look at the diagram. It's obvious with white to move white can give a checkmate with Qg7# on the next ply. "
Someone know how do this?
Someone know more good patterns?
Take the 8 squares around the king and set the squares where the king cant go because
1) an own piece is there
2) it's off the board
3) the square is attacked by the opponent.
fe a king on g8 and black pawns on f7 and g7
- Code: Select all
0 1 2 X X X
3 K 4 => O K O => 11000111 => 199
5 6 7 O X X
Now you can test for patterns fe:
- Code: Select all
if (kingTabooSquares & (bit(0)|bit(2))==(bit(0)|bit(2))) // if ((taboo & 5)==5)
{
// a queen could give checkmate on bit(6) ie g7 in this case
if ((attacker(g7)==Queen) && (anotherAttacker(g7) || QueenDeffendedFromBehindIndirectionOf(g7))
{
// checkmate
}
}
As an excercise I'll leave the sanity checks up to you ( there are quite a few cases when it's not a checkmate)
Easiest debugging is to set a bool if the function returned checkmate and fire a 2 ply search (-inf,inf) to check if a checkmate score is returned. Remember, you are giving extremely high scores here. A bug (false positive) will be horrible ( trust me, I know)
Off coarse you can mirror the checkmate square:
- Code: Select all
Taboo: bit(0,2) Queen checkmate possible (bit(6))
Taboo: bit(2,7) Queen checkmate possible (bit(3))
Taboo: bit(5,7) Queen checkmate possible (bit(1))
Taboo: bit(0,5) Queen checkmate possible (bit(4))
Diagonal is a bit more complicated:
Taboo: bit(1,4) Queen checkmate possible (bit(5)) Additional: ((Empty(bit(3)|Taboo(bit(0)) && (Empty(bit(6)|Taboo(bit(7)))
etc...
Further (in rising dificulty):Knight checkmate, Rook contacts checkmates, queen non contacts, rook non contacts (8th rank). Don't bother with bishops.
Cheers,
Tony