2008-08-31 23:59:13 -06:00
|
|
|
/*
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
|
|
|
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
|
2016-01-02 02:43:25 -07:00
|
|
|
Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
|
2020-01-07 13:35:47 -07:00
|
|
|
Copyright (C) 2015-2020 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish is free software: you can redistribute it and/or modify
|
2008-08-31 23:59:13 -06:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2009-01-07 06:28:04 -07:00
|
|
|
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish is distributed in the hope that it will be useful,
|
2008-08-31 23:59:13 -06:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2009-01-07 06:28:04 -07:00
|
|
|
|
2008-08-31 23:59:13 -06:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2013-07-23 07:31:57 -06:00
|
|
|
#ifndef PAWNS_H_INCLUDED
|
2008-08-31 23:59:13 -06:00
|
|
|
#define PAWNS_H_INCLUDED
|
|
|
|
|
2012-03-31 05:15:57 -06:00
|
|
|
#include "misc.h"
|
2010-08-26 04:13:07 -06:00
|
|
|
#include "position.h"
|
2011-02-23 13:27:22 -07:00
|
|
|
#include "types.h"
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2012-12-22 03:21:06 -07:00
|
|
|
namespace Pawns {
|
2010-08-21 11:57:52 -06:00
|
|
|
|
2014-04-13 05:35:58 -06:00
|
|
|
/// Pawns::Entry contains various information about a pawn structure. A lookup
|
|
|
|
/// to the pawn hash table (performed by calling the probe function) returns a
|
|
|
|
/// pointer to an Entry object.
|
2011-04-11 01:54:41 -06:00
|
|
|
|
2012-12-22 03:21:06 -07:00
|
|
|
struct Entry {
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2018-02-20 09:10:37 -07:00
|
|
|
Score pawn_score(Color c) const { return scores[c]; }
|
2012-12-22 03:21:06 -07:00
|
|
|
Bitboard pawn_attacks(Color c) const { return pawnAttacks[c]; }
|
|
|
|
Bitboard passed_pawns(Color c) const { return passedPawns[c]; }
|
2015-11-14 07:30:50 -07:00
|
|
|
Bitboard pawn_attacks_span(Color c) const { return pawnAttacksSpan[c]; }
|
2019-03-31 04:02:19 -06:00
|
|
|
int passed_count() const { return popcount(passedPawns[WHITE] | passedPawns[BLACK]); }
|
Scale up space weight with number of blocked pawns
This idea is loosely based on stockfish losses in closed positions in different tournaments. Space weight symmetrically increases for both sides the more blocked position is.
passed STC
https://tests.stockfishchess.org/tests/view/5e919eefaf0a0143109dc8ce
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 16994 W: 3389 L: 3172 D: 10433
Ptnml(0-2): 277, 1931, 3918, 2040, 331
passed LTC
https://tests.stockfishchess.org/tests/view/5e91d04faf0a0143109dc8ea
LLR: 2.94 (-2.94,2.94) {0.25,1.75}
Total: 133386 W: 17316 L: 16763 D: 99307
Ptnml(0-2): 945, 12407, 39524, 12784, 1033
closes https://github.com/official-stockfish/Stockfish/pull/2626
Bench: 4966867
2020-04-12 18:48:52 -06:00
|
|
|
int blocked_count() const { return blockedCount[WHITE] + blockedCount[BLACK]; }
|
2013-05-11 01:29:02 -06:00
|
|
|
|
2010-08-26 04:13:07 -06:00
|
|
|
template<Color Us>
|
2018-11-10 20:49:13 -07:00
|
|
|
Score king_safety(const Position& pos) {
|
2018-12-11 05:47:56 -07:00
|
|
|
return kingSquares[Us] == pos.square<KING>(Us) && castlingRights[Us] == pos.castling_rights(Us)
|
2018-11-10 20:49:13 -07:00
|
|
|
? kingSafety[Us] : (kingSafety[Us] = do_king_safety<Us>(pos));
|
2012-12-22 03:21:06 -07:00
|
|
|
}
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2010-08-26 04:13:07 -06:00
|
|
|
template<Color Us>
|
2018-11-10 20:49:13 -07:00
|
|
|
Score do_king_safety(const Position& pos);
|
2012-03-28 04:44:41 -06:00
|
|
|
|
|
|
|
template<Color Us>
|
2019-08-24 00:16:20 -06:00
|
|
|
Score evaluate_shelter(const Position& pos, Square ksq);
|
2008-08-31 23:59:13 -06:00
|
|
|
|
|
|
|
Key key;
|
2018-02-20 09:10:37 -07:00
|
|
|
Score scores[COLOR_NB];
|
2012-10-21 02:41:23 -06:00
|
|
|
Bitboard passedPawns[COLOR_NB];
|
|
|
|
Bitboard pawnAttacks[COLOR_NB];
|
2015-11-14 07:30:50 -07:00
|
|
|
Bitboard pawnAttacksSpan[COLOR_NB];
|
2012-10-21 02:41:23 -06:00
|
|
|
Square kingSquares[COLOR_NB];
|
2014-04-13 05:35:58 -06:00
|
|
|
Score kingSafety[COLOR_NB];
|
2014-03-08 07:08:55 -07:00
|
|
|
int castlingRights[COLOR_NB];
|
Scale up space weight with number of blocked pawns
This idea is loosely based on stockfish losses in closed positions in different tournaments. Space weight symmetrically increases for both sides the more blocked position is.
passed STC
https://tests.stockfishchess.org/tests/view/5e919eefaf0a0143109dc8ce
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 16994 W: 3389 L: 3172 D: 10433
Ptnml(0-2): 277, 1931, 3918, 2040, 331
passed LTC
https://tests.stockfishchess.org/tests/view/5e91d04faf0a0143109dc8ea
LLR: 2.94 (-2.94,2.94) {0.25,1.75}
Total: 133386 W: 17316 L: 16763 D: 99307
Ptnml(0-2): 945, 12407, 39524, 12784, 1033
closes https://github.com/official-stockfish/Stockfish/pull/2626
Bench: 4966867
2020-04-12 18:48:52 -06:00
|
|
|
int blockedCount[COLOR_NB];
|
2008-08-31 23:59:13 -06:00
|
|
|
};
|
|
|
|
|
2019-06-13 23:36:42 -06:00
|
|
|
typedef HashTable<Entry, 131072> Table;
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2014-12-30 02:31:50 -07:00
|
|
|
Entry* probe(const Position& pos);
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2014-04-13 05:35:58 -06:00
|
|
|
} // namespace Pawns
|
2009-05-16 08:15:05 -06:00
|
|
|
|
2013-07-23 07:31:57 -06:00
|
|
|
#endif // #ifndef PAWNS_H_INCLUDED
|