]> git.sesse.net Git - stockfish/commitdiff
Fix indentation in struct FromToStats
authorMarco Costalba <mcostalba@gmail.com>
Sat, 17 Sep 2016 06:19:06 +0000 (08:19 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 17 Sep 2016 07:51:20 +0000 (09:51 +0200)
And other little trivial stuff.

No functional change.

src/evaluate.cpp
src/main.cpp
src/movepick.cpp
src/movepick.h
src/position.cpp
src/position.h
src/search.cpp
src/search.h
src/thread.h
src/types.h

index dd86f35ae112777165005860adf57ec51148f8e2..3095838820632331b5f5ac805dd5ed867af83cf9 100644 (file)
@@ -419,11 +419,11 @@ namespace {
         // attacked and undefended squares around our king and the quality of
         // the pawn shelter (current 'score' value).
         kingDanger =  std::min(807, ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them])
-                     + 101 * ei.kingAdjacentZoneAttacksCount[Them]
-                     + 235 * popcount(undefended)
-                     + 134 * (popcount(b) + !!ei.pinnedPieces[Us])
-                     - 717 * !pos.count<QUEEN>(Them)
-                     -   7 * mg_value(score) / 5 - 5;
+                    + 101 * ei.kingAdjacentZoneAttacksCount[Them]
+                    + 235 * popcount(undefended)
+                    + 134 * (popcount(b) + !!ei.pinnedPieces[Us])
+                    - 717 * !pos.count<QUEEN>(Them)
+                    -   7 * mg_value(score) / 5 - 5;
 
         // Analyse the enemy's safe queen contact checks. Firstly, find the
         // undefended squares around the king reachable by the enemy queen...
index 736a3f7ae97c880054d6a2193acbe9559ab3744d..7187d30a02cbad00e5ddf8866a28818278ec001c 100644 (file)
 #include "uci.h"
 #include "syzygy/tbprobe.h"
 
+namespace PSQT {
+  void init();
+}
+
 int main(int argc, char* argv[]) {
 
   std::cout << engine_info() << std::endl;
index bbe1897e0d72920058ec11ee0a1c1664549d7538..ea5873891d517efc7036f5f4b448db284c3112f6 100644 (file)
@@ -277,7 +277,7 @@ Move MovePicker::next_move() {
   case EVASIONS_INIT:
       cur = moves;
       endMoves = generate<EVASIONS>(pos, cur);
-      if (endMoves - cur > 1)
+      if (endMoves - cur - (ttMove != MOVE_NONE) > 1)
           score<EVASIONS>();
       ++stage;
 
index 36bf58f63ac329821156ea8539a7df20488e63af..6fbd8be1387fc46ce277a03f29a1f2442171ac19 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "movegen.h"
 #include "position.h"
-#include "search.h"
 #include "types.h"
 
 
@@ -45,9 +44,7 @@ struct Stats {
   const T* operator[](Piece pc) const { return table[pc]; }
   T* operator[](Piece pc) { return table[pc]; }
   void clear() { std::memset(table, 0, sizeof(table)); }
-
   void update(Piece pc, Square to, Move m) { table[pc][to] = m; }
-
   void update(Piece pc, Square to, Value v) {
 
     if (abs(int(v)) >= 324)
@@ -68,31 +65,32 @@ typedef Stats<CounterMoveStats> CounterMoveHistoryStats;
 
 struct FromToStats {
 
-    Value get(Color c, Move m) const { return table[c][from_sq(m)][to_sq(m)]; }
-    void clear() { std::memset(table, 0, sizeof(table)); }
+  Value get(Color c, Move m) const { return table[c][from_sq(m)][to_sq(m)]; }
+  void clear() { std::memset(table, 0, sizeof(table)); }
+  void update(Color c, Move m, Value v) {
 
-    void update(Color c, Move m, Value v)
-    {
-        if (abs(int(v)) >= 324)
-            return;
+    if (abs(int(v)) >= 324)
+        return;
 
-        Square f = from_sq(m);
-        Square t = to_sq(m);
+    Square from = from_sq(m);
+    Square to = to_sq(m);
 
-        table[c][f][t] -= table[c][f][t] * abs(int(v)) / 324;
-        table[c][f][t] += int(v) * 32;
-    }
+    table[c][from][to] -= table[c][from][to] * abs(int(v)) / 324;
+    table[c][from][to] += int(v) * 32;
+  }
 
 private:
-    Value table[COLOR_NB][SQUARE_NB][SQUARE_NB];
+  Value table[COLOR_NB][SQUARE_NB][SQUARE_NB];
 };
 
+
 /// MovePicker class is used to pick one pseudo legal move at a time from the
 /// current position. The most important method is next_move(), which returns a
 /// new pseudo legal move each time it is called, until there are no moves left,
 /// when MOVE_NONE is returned. In order to improve the efficiency of the alpha
 /// beta algorithm, MovePicker attempts to return the moves which are most likely
 /// to get a cut-off first.
+namespace Search { struct Stack; }
 
 class MovePicker {
 public:
@@ -118,7 +116,7 @@ private:
   Square recaptureSquare;
   Value threshold;
   int stage;
-  ExtMovecur, *endMoves, *endBadCaptures;
+  ExtMove *cur, *endMoves, *endBadCaptures;
   ExtMove moves[MAX_MOVES];
 };
 
index 779c2640b3be24b261f77af64ae2dff30f4839cf..c193f26691660eebc00214fc9564b108b0eab3f0 100644 (file)
@@ -20,7 +20,8 @@
 
 #include <algorithm>
 #include <cassert>
-#include <cstring>   // For std::memset, std::memcmp
+#include <cstddef> // For offsetof()
+#include <cstring> // For std::memset, std::memcmp
 #include <iomanip>
 #include <sstream>
 
 
 using std::string;
 
+namespace PSQT {
+  extern Score psq[PIECE_NB][SQUARE_NB];
+}
+
 namespace Zobrist {
 
   Key psq[PIECE_NB][SQUARE_NB];
index c322ab99ac238105b4c483176db528c53ed25915..9830619eac80eb11b4c7ef7ba6131a77d4bd5247 100644 (file)
 #define POSITION_H_INCLUDED
 
 #include <cassert>
-#include <cstddef>  // For offsetof()
 #include <deque>
-#include <memory>   // For std::unique_ptr
+#include <memory> // For std::unique_ptr
 #include <string>
-#include <vector>
 
 #include "bitboard.h"
 #include "types.h"
 
-class Position;
-class Thread;
-
-namespace PSQT {
-
-  extern Score psq[PIECE_NB][SQUARE_NB];
-
-  void init();
-}
-
 
 /// StateInfo struct stores information needed to restore a Position object to
 /// its previous state when we retract a move. Whenever a move is made on the
@@ -58,7 +46,7 @@ struct StateInfo {
   Score  psq;
   Square epSquare;
 
-  // Not copied when making a move
+  // Not copied when making a move (will be recomputed anyhow)
   Key        key;
   Bitboard   checkersBB;
   Piece      capturedPiece;
@@ -76,9 +64,9 @@ typedef std::unique_ptr<std::deque<StateInfo>> StateListPtr;
 /// pieces, side to move, hash keys, castling info, etc. Important methods are
 /// do_move() and undo_move(), used by the search to update node info when
 /// traversing the search tree.
+class Thread;
 
 class Position {
-
 public:
   static void init();
 
@@ -144,7 +132,7 @@ public:
   void do_null_move(StateInfo& st);
   void undo_null_move();
 
-  // Static exchange evaluation
+  // Static Exchange Evaluation
   Value see(Move m) const;
   Value see_sign(Move m) const;
 
@@ -369,15 +357,13 @@ inline bool Position::is_chess960() const {
 }
 
 inline bool Position::capture_or_promotion(Move m) const {
-
   assert(is_ok(m));
   return type_of(m) != NORMAL ? type_of(m) != CASTLING : !empty(to_sq(m));
 }
 
 inline bool Position::capture(Move m) const {
-
-  // Castling is encoded as "king captures the rook"
   assert(is_ok(m));
+  // Castling is encoded as "king captures rook"
   return (!empty(to_sq(m)) && type_of(m) != CASTLING) || type_of(m) == ENPASSANT;
 }
 
@@ -405,7 +391,7 @@ inline void Position::remove_piece(Piece pc, Square s) {
   // WARNING: This is not a reversible operation. If we remove a piece in
   // do_move() and then replace it in undo_move() we will put it at the end of
   // the list and not in its original place, it means index[] and pieceList[]
-  // are not guaranteed to be invariant to a do_move() + undo_move() sequence.
+  // are not invariant to a do_move() + undo_move() sequence.
   byTypeBB[ALL_PIECES] ^= s;
   byTypeBB[type_of(pc)] ^= s;
   byColorBB[color_of(pc)] ^= s;
index 9eac6d5f9414f4e3a58d1c4404e1f1e3ea2f4dac..695cd7c1876cbeadae3a9f7f104f77a45c7b83a7 100644 (file)
@@ -29,6 +29,7 @@
 #include "misc.h"
 #include "movegen.h"
 #include "movepick.h"
+#include "position.h"
 #include "search.h"
 #include "timeman.h"
 #include "thread.h"
index 599d058fa7d018454ea481f30a6448f079a53e87..121ab8d12446e366bd965619cf23bdb1849e2807 100644 (file)
 #include <vector>
 
 #include "misc.h"
-#include "position.h"
+#include "movepick.h"
 #include "types.h"
 
-template<typename T, bool CM> struct Stats;
-typedef Stats<Value, true> CounterMoveStats;
+class Position;
 
 namespace Search {
 
@@ -49,6 +48,7 @@ struct Stack {
   CounterMoveStats* counterMoves;
 };
 
+
 /// RootMove struct is used for moves at the root of the tree. For each root move
 /// we store a score and a PV (really a refutation in the case of moves which
 /// fail low). Score is normally set at -VALUE_INFINITE for all non-pv moves.
@@ -68,6 +68,7 @@ struct RootMove {
 
 typedef std::vector<RootMove> RootMoves;
 
+
 /// LimitsType struct stores information sent by GUI about available time to
 /// search the current move, maximum depth/time, if we are in analysis mode or
 /// if we have to ponder while it's our opponent's turn to move.
@@ -89,8 +90,9 @@ struct LimitsType {
   TimePoint startTime;
 };
 
-/// The SignalsType struct stores atomic flags updated during the search
-/// typically in an async fashion e.g. to stop the search by the GUI.
+
+/// SignalsType struct stores atomic flags updated during the search, typically
+/// in an async fashion e.g. to stop the search by the GUI.
 
 struct SignalsType {
   std::atomic_bool stop, stopOnPonderhit;
index 969fe635fc2ee6f8b04816316a0fddff4ee63d0b..195c3b3b919e2d07afaeee3fd11be02012003550 100644 (file)
@@ -66,11 +66,11 @@ public:
   Position rootPos;
   Search::RootMoves rootMoves;
   Depth rootDepth;
-  FromToStats fromTo;
   Depth completedDepth;
   std::atomic_bool resetCalls;
   HistoryStats history;
   MoveStats counterMoves;
+  FromToStats fromTo;
   CounterMoveHistoryStats counterMoveHistory;
 };
 
index b1810fad91aa596196173ec9912c9c955f5cfe66..3aafb5c3af08083bdbdcd99567b7a22ee842ba00 100644 (file)
@@ -207,6 +207,7 @@ enum Piece {
 
 const Piece Pieces[] = { W_PAWN, W_KNIGHT, W_BISHOP, W_ROOK, W_QUEEN, W_KING,
                          B_PAWN, B_KNIGHT, B_BISHOP, B_ROOK, B_QUEEN, B_KING };
+extern Value PieceValue[PHASE_NB][PIECE_NB];
 
 enum Depth {
 
@@ -329,8 +330,6 @@ inline Score operator/(Score s, int i) {
   return make_score(mg_value(s) / i, eg_value(s) / i);
 }
 
-extern Value PieceValue[PHASE_NB][PIECE_NB];
-
 inline Color operator~(Color c) {
   return Color(c ^ BLACK); // Toggle color
 }
@@ -356,7 +355,7 @@ inline Value mated_in(int ply) {
 }
 
 inline Square make_square(File f, Rank r) {
-  return Square((r << 3) | f);
+  return Square((r << 3) + f);
 }
 
 inline Piece make_piece(Color c, PieceType pt) {
@@ -422,12 +421,12 @@ inline PieceType promotion_type(Move m) {
 }
 
 inline Move make_move(Square from, Square to) {
-  return Move(to | (from << 6));
+  return Move((from << 6) + to);
 }
 
 template<MoveType T>
 inline Move make(Square from, Square to, PieceType pt = KNIGHT) {
-  return Move(to | (from << 6) | T | ((pt - KNIGHT) << 12));
+  return Move(T + ((pt - KNIGHT) << 12) + (from << 6) + to);
 }
 
 inline bool is_ok(Move m) {