1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Big trailing whitespace cleanup part 1

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-01-07 14:26:58 +01:00
parent 5cacefe7c6
commit c97104e854
16 changed files with 126 additions and 129 deletions

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -53,7 +53,7 @@ const std::string BenchmarkPositions[] = {
"4k2r/1pb2ppp/1p2p3/1R1p4/3P4/2r1PN2/P4PPP/1R4K1 b - 3 22",
"3q2k1/pb3p1p/4pbp1/2r5/PpN2N2/1P2P2P/5PP1/Q2R2K1 b - - 4 26"
};
////
//// Functions
@ -88,7 +88,7 @@ void benchmark(const std::string& commandLine) {
std::cerr << "The number of threads must be between 1 and " << THREAD_MAX
<< std::endl;
exit(EXIT_FAILURE);
}
}
set_option_value("Hash", ttSize);
set_option_value("Threads", threads);
set_option_value("OwnBook", "false");
@ -109,7 +109,7 @@ void benchmark(const std::string& commandLine) {
maxNodes = val;
std::vector<std::string> positions;
if (fileName != "default")
{
std::ifstream fenFile(fileName.c_str());
@ -118,7 +118,7 @@ void benchmark(const std::string& commandLine) {
std::cerr << "Unable to open positions file " << fileName
<< std::endl;
exit(EXIT_FAILURE);
}
}
std::string pos;
while (fenFile.good())
{

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -53,11 +53,11 @@ namespace {
Bitboard wk_attacks() const;
Bitboard bk_attacks() const;
Bitboard pawn_attacks() const;
Square whiteKingSquare, blackKingSquare, pawnSquare;
Color sideToMove;
};
Result *Bitbase;
const int IndexMax = 2*24*64*64;
@ -69,7 +69,7 @@ namespace {
Result classify_btm(const KPKPosition &p);
int compute_index(Square wksq, Square bksq, Square psq, Color stm);
int compress_result(Result r);
}
@ -113,7 +113,7 @@ namespace {
return compute_index(whiteKingSquare, blackKingSquare, pawnSquare,
sideToMove);
}
bool KPKPosition::is_legal() const {
if(whiteKingSquare == pawnSquare || whiteKingSquare == blackKingSquare ||
@ -137,7 +137,7 @@ namespace {
if(sideToMove == BLACK) {
Bitboard wka = this->wk_attacks();
Bitboard bka = this->bk_attacks();
// Case 1: Stalemate
if((bka & ~(wka | this->pawn_attacks())) == EmptyBoardBB)
return true;
@ -166,7 +166,7 @@ namespace {
(square_distance(blackKingSquare, pawnSquare+DELTA_N) > 1 ||
bit_is_set(this->wk_attacks(), pawnSquare+DELTA_N));
}
Bitboard KPKPosition::wk_attacks() const {
return StepAttackBB[WK][whiteKingSquare];
@ -204,7 +204,7 @@ namespace {
bool next_iteration() {
KPKPosition p;
int previousUnknownCount = UnknownCount;
for(int i = 0; i < IndexMax; i++)
if(Bitbase[i] == RESULT_UNKNOWN) {
p.from_index(i);
@ -231,7 +231,7 @@ namespace {
bool unknownFound = false;
Bitboard b;
Square s;
// King moves
b = p.wk_attacks();
while(b) {
@ -260,14 +260,14 @@ namespace {
BLACK)]) {
case RESULT_LOSS:
return RESULT_WIN;
case RESULT_UNKNOWN:
unknownFound = true;
break;
case RESULT_DRAW: case RESULT_INVALID:
break;
default:
assert(false);
}
@ -279,20 +279,20 @@ namespace {
BLACK)]) {
case RESULT_LOSS:
return RESULT_WIN;
case RESULT_UNKNOWN:
unknownFound = true;
break;
case RESULT_DRAW: case RESULT_INVALID:
break;
default:
assert(false);
}
}
}
return unknownFound? RESULT_UNKNOWN : RESULT_DRAW;
}
@ -345,5 +345,5 @@ namespace {
int compress_result(Result r) {
return (r == RESULT_WIN || r == RESULT_LOSS)? 1 : 0;
}
}
}

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -317,22 +317,22 @@ namespace {
/// Indices to the Random64[] array
const int RandomPiece = 0;
const int RandomCastle = 768;
const int RandomEnPassant = 772;
const int RandomTurn = 780;
/// Convert pieces to the range 0..1
const int PieceTo12[] = {
0, 0, 2, 4, 6, 8, 10, 0, 0, 1, 3, 5, 7, 9, 11
};
/// Prototypes
uint64_t book_key(const Position &pos);
uint64_t book_piece_key(Piece p, Square s);
uint64_t book_castle_key(const Position &pos);
@ -364,7 +364,7 @@ void Book::open(const std::string &fName) {
if (!bookFile.is_open())
return;
bookFile.seekg(0, std::ios::end);
bookFile.seekg(0, std::ios::end);
bookSize = bookFile.tellg() / 16;
bookFile.seekg(0, std::ios::beg);
@ -388,7 +388,7 @@ void Book::close() {
/// Book::is_open() tests whether a book file has been opened.
bool Book::is_open() const {
return bookFile.is_open() && bookSize != 0;
}
@ -400,7 +400,7 @@ const std::string Book::file_name() const {
return bookFile.is_open() ? fileName : "";
}
/// Book::get_move() gets a book move for a given position. Returns
/// MOVE_NONE if no book move is found.
@ -524,7 +524,7 @@ namespace {
return result;
}
uint64_t book_piece_key(Piece p, Square s) {
return Random64[RandomPiece + (PieceTo12[int(p)]^1)*64 + int(s)];
@ -545,29 +545,29 @@ namespace {
return result;
}
uint64_t book_ep_key(const Position &pos) {
return (pos.ep_square() == SQ_NONE)?
0ULL : Random64[RandomEnPassant + square_file(pos.ep_square())];
}
uint64_t book_color_key(const Position &pos) {
return (pos.side_to_move() == WHITE)? Random64[RandomTurn] : 0ULL;
}
uint16_t read_integer16(std::ifstream& file) {
uint64_t n = read_integer(file, 2);
assert(n == (uint16_t)n);
return (uint16_t)n;
return (uint16_t)n;
}
uint64_t read_integer64(std::ifstream& file) {
return read_integer(file, 8);
return read_integer(file, 8);
}

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -153,7 +153,7 @@ namespace {
const int KRKNKingKnightDistancePenalty[8] = { 0, 0, 4, 10, 20, 32, 48, 70 };
// Various inline functions for accessing the above arrays:
inline Value mate_table(Square s) {
return Value(MateTable[s]);
}
@ -174,7 +174,7 @@ namespace {
int probe_kpk(Square wksq, Square wpsq, Square bksq, Color stm);
}
////
//// Functions
@ -244,7 +244,7 @@ Value KXKEvaluationFunction::apply(const Position &pos) {
/// Mate with KBN vs K. This is similar to KX vs K, but we have to drive the
/// defending king towards a corner square of the right color.
Value KBNKEvaluationFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(weakerSide) == Value(0));
@ -280,7 +280,7 @@ Value KPKEvaluationFunction::apply(const Position &pos) {
assert(pos.non_pawn_material(weakerSide) == Value(0));
assert(pos.piece_count(strongerSide, PAWN) == 1);
assert(pos.piece_count(weakerSide, PAWN) == 0);
Square wksq, bksq, wpsq;
Color stm;
@ -421,7 +421,7 @@ Value KQKREvaluationFunction::apply(const Position &pos) {
Square winnerKSq = pos.king_square(strongerSide);
Square loserKSq = pos.king_square(weakerSide);
Value result = QueenValueEndgame - RookValueEndgame +
mate_table(loserKSq) + distance_bonus(square_distance(winnerKSq, loserKSq));
@ -764,9 +764,9 @@ ScaleFactor KBPKBScalingFunction::apply(const Position &pos) {
// Case 2: Opposite colored bishops.
if(square_color(strongerBishopSq) != square_color(weakerBishopSq)) {
// We assume that the position is drawn in the following three situations:
//
//
// a. The pawn is on rank 5 or further back.
// b. The defending king is somewhere in the pawn's path.
// c. The defending bishop attacks some square along the pawn's path,
@ -774,7 +774,7 @@ ScaleFactor KBPKBScalingFunction::apply(const Position &pos) {
//
// These rules are probably not perfect, but in practice they work
// reasonably well.
if(relative_rank(strongerSide, pawnSq) <= RANK_5)
return ScaleFactor(0);
else {
@ -807,7 +807,7 @@ ScaleFactor KBPKNScalingFunction::apply(const Position &pos) {
Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
Square strongerBishopSq = pos.piece_list(strongerSide, BISHOP, 0);
Square weakerKingSq = pos.king_square(weakerSide);
if(square_file(weakerKingSq) == square_file(pawnSq)
&& relative_rank(strongerSide, pawnSq) < relative_rank(strongerSide, weakerKingSq)
&& (square_color(weakerKingSq) != square_color(strongerBishopSq)
@ -909,9 +909,9 @@ namespace {
int probe_kpk(Square wksq, Square wpsq, Square bksq, Color stm) {
int wp = int(square_file(wpsq)) + (int(square_rank(wpsq)) - 1) * 4;
int index = int(stm) + 2*int(bksq) + 128*int(wksq) + 8192*wp;
assert(index >= 0 && index < 24576*8);
return KPKBitbase[index/8] & (1 << (index&7));
}
}

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -92,7 +92,7 @@ int History::move_ordering_score(Piece p, Move m) const {
/// History::ok_to_prune() decides whether a move has been sufficiently
/// unsuccessful that it makes sense to prune it entirely.
/// unsuccessful that it makes sense to prune it entirely.
bool History::ok_to_prune(Piece p, Move m, Depth d) const {
assert(piece_is_ok(p));

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -41,7 +41,7 @@
using std::string;
////
////
//// Functions
////

View file

@ -309,7 +309,7 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) {
/// EndgameFunctions member definitions. This class is used to store the maps
/// of end game and scaling functions that MaterialInfoTable will query for
/// of end game and scaling functions that MaterialInfoTable will query for
/// each key. The maps are constant and are populated only at construction,
/// but are per-thread instead of globals to avoid expensive locks.

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

View file

@ -310,10 +310,10 @@ void MovePicker::score_qcaptures() {
}
/// find_best_index() loops across the moves and returns index of
/// the highest scored one. There is also a second version that
/// lowers the priority of moves that attack the same square,
/// so that if the best move that attack a square fails the next
/// find_best_index() loops across the moves and returns index of
/// the highest scored one. There is also a second version that
/// lowers the priority of moves that attack the same square,
/// so that if the best move that attack a square fails the next
/// move picked attacks a different square if any, not the same one.
int MovePicker::find_best_index() {
@ -329,41 +329,41 @@ int MovePicker::find_best_index() {
return bestIndex;
}
int MovePicker::find_best_index(Bitboard* squares, int values[]) {
int hs;
Move m;
Square to;
int bestScore = -10000000, bestIndex = -1;
for (int i = movesPicked; i < numOfMoves; i++)
{
m = moves[i].move;
to = move_to(m);
if (!bit_is_set(*squares, to))
{
// Init at first use
set_bit(squares, to);
values[to] = 0;
}
hs = moves[i].score - values[to];
if (hs > bestScore)
{
bestIndex = i;
bestScore = hs;
}
}
if (bestIndex != -1)
{
// Raise value of the picked square, so next attack
// to the same square will get low priority.
to = move_to(moves[bestIndex].move);
values[to] += 0xB00;
}
return bestIndex;
int MovePicker::find_best_index(Bitboard* squares, int values[]) {
int hs;
Move m;
Square to;
int bestScore = -10000000, bestIndex = -1;
for (int i = movesPicked; i < numOfMoves; i++)
{
m = moves[i].move;
to = move_to(m);
if (!bit_is_set(*squares, to))
{
// Init at first use
set_bit(squares, to);
values[to] = 0;
}
hs = moves[i].score - values[to];
if (hs > bestScore)
{
bestIndex = i;
bestScore = hs;
}
}
if (bestIndex != -1)
{
// Raise value of the picked square, so next attack
// to the same square will get low priority.
to = move_to(moves[bestIndex].move);
values[to] += 0xB00;
}
return bestIndex;
}

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -72,13 +72,13 @@ namespace {
Value(32), Value(32), Value(32), Value(28)
};
// Pawn chain membership bonus by file, middle game.
// Pawn chain membership bonus by file, middle game.
const Value ChainMidgameBonus[8] = {
Value(14), Value(16), Value(17), Value(18),
Value(18), Value(17), Value(16), Value(14)
};
// Pawn chain membership bonus by file, endgame.
// Pawn chain membership bonus by file, endgame.
const Value ChainEndgameBonus[8] = {
Value(16), Value(16), Value(16), Value(16),
Value(16), Value(16), Value(16), Value(16)
@ -107,7 +107,7 @@ namespace {
31, 40, 40, 31, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
const int KStormTable[64] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,-4,-13,-22,-27,-27,
@ -167,7 +167,7 @@ void PawnInfoTable::clear() {
/// PawnInfoTable::get_pawn_info() takes a position object as input, computes
/// a PawnInfo object, and returns a pointer to it. The result is also
/// a PawnInfo object, and returns a pointer to it. The result is also
/// stored in a hash table, so we don't have to recompute everything when
/// the same pawn structure occurs again.
@ -179,7 +179,7 @@ PawnInfo *PawnInfoTable::get_pawn_info(const Position &pos) {
int index = int(key & (size - 1));
PawnInfo *pi = entries + index;
// If pi->key matches the position's pawn hash key, it means that we
// If pi->key matches the position's pawn hash key, it means that we
// have analysed this pawn structure before, and we can simply return the
// information we found the last time instead of recomputing it
if (pi->key == key)
@ -370,7 +370,7 @@ PawnInfo *PawnInfoTable::get_pawn_info(const Position &pos) {
mgValue[us] += mv;
egValue[us] += ev;
// If the pawn is passed, set the square of the pawn in the passedPawns
// bitboard
if (passed)

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -42,9 +42,9 @@ const SquareDelta Directions[16][16] = {
DELTA_NWW, DELTA_NEE, DELTA_NNW, DELTA_NNE, DELTA_ZERO},
{DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
{DELTA_S, DELTA_E, DELTA_W, DELTA_N, DELTA_ZERO},
{DELTA_S, DELTA_E, DELTA_W, DELTA_N,
{DELTA_S, DELTA_E, DELTA_W, DELTA_N,
DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
{DELTA_S, DELTA_E, DELTA_W, DELTA_N,
{DELTA_S, DELTA_E, DELTA_W, DELTA_N,
DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
{DELTA_ZERO},
{DELTA_ZERO},
@ -53,11 +53,11 @@ const SquareDelta Directions[16][16] = {
DELTA_NWW, DELTA_NEE, DELTA_NNW, DELTA_NNE, DELTA_ZERO},
{DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
{DELTA_S, DELTA_E, DELTA_W, DELTA_N, DELTA_ZERO},
{DELTA_S, DELTA_E, DELTA_W, DELTA_N,
{DELTA_S, DELTA_E, DELTA_W, DELTA_N,
DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
{DELTA_S, DELTA_E, DELTA_W, DELTA_N,
{DELTA_S, DELTA_E, DELTA_W, DELTA_N,
DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
};
};
const SquareDelta PawnPush[2] = {
DELTA_N, DELTA_S

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

View file

@ -208,6 +208,3 @@ TTEntry::TTEntry(Key k, Value v, ValueType t, Depth d, Move m,
int generation) :
key_ (k), data((m & 0x7FFFF) | (t << 20) | (generation << 23)),
value_(v), depth_(int16_t(d)) {}

View file

@ -7,12 +7,12 @@
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.
Stockfish is distributed in the hope that it will be useful,
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/