Because they have some advantage Engine it Strong if you can Block it first
Engine will understand more Draw first and it Good if opponent move mistake
it will calculation advance more or see the line of success Winning
Program. I mean Pawn strong instruction in hard to beat even good player
maybe only find Draw for Engine can Win the games. I test with Stockfish
fairy it Good in opening Games and Middle Games but Endgame sometime it
need more advance I hope it will work better more than that. I include some
endgame to you to see I think it work better I mean for Makruk Maybe next
code more strong many thank to read my request.

On Thu, Dec 5, 2019 at 7:37 PM Fabian Fichter <notifications@github.com>
wrote:

> So you mean it should better recognize that blocked pawn structures are
> drawish and avoid them if it is at an advantage?
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/thaichessswinboard/Makruk-Stockfish/commit/fd802e8d0c7cd5abb0a0b94bf9bde82e29fe757c?email_source=notifications&email_token=AJ6EZFFUMNQRUGNHIATOE4DQXFKARA5CNFSM4JTOLEZKYY3PNVWWK3TUL52HS4DFVVBW63LNNF2EG33NNVSW45FKMNXW23LFNZ2F62LEZYBCTQXD#commitcomment-36291299>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AJ6EZFEFREQVR5PQPQUK3WLQXFKARANCNFSM4JTOLEZA>
> .
>

/*
  Stockfish, a UCI chess playing engine derived from Glaurung 2.1
  Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
  Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
  Copyright (C) 2015-2019 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad

  Stockfish is free software: you can redistribute it and/or modify
  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/>.
*/

#include <cassert>

#include "bitboard.h"
#include "endgame.h"
#include "movegen.h"
#include "position.h"
#include "syzygy/tbprobe.h"

using std::string;

namespace {

  // Table used to drive the king towards the edge of the board
  // in KX vs K and KQ vs KR endgames.
  constexpr int PushToEdges[SQUARE_NB] = {
    100, 90, 80, 70, 70, 80, 90, 100,
     90, 70, 60, 50, 50, 60, 70,  90,
     80, 60, 40, 30, 30, 40, 60,  80,
     70, 50, 30, 20, 20, 30, 50,  70,
     70, 50, 30, 20, 20, 30, 50,  70,
     80, 60, 40, 30, 30, 40, 60,  80,
     90, 70, 60, 50, 50, 60, 70,  90,
    100, 90, 80, 70, 70, 80, 90, 100
  };

  // Table used to drive the king towards a corner square of the
  // right color in KBN vs K endgames.
  constexpr int PushToCorners[SQUARE_NB] = {
     6400, 6080, 5760, 5440, 5120, 4800, 4480, 4160,
     6080, 5760, 5440, 5120, 4800, 4480, 4160, 4480,
     5760, 5440, 4960, 4480, 4480, 4000, 4480, 4800,
     5440, 5120, 4480, 3840, 3520, 4480, 4800, 5120,
     5120, 4800, 4480, 3520, 3840, 4480, 5120, 5440,
     4800, 4480, 4000, 4480, 4480, 4960, 5440, 5760,
     4480, 4160, 4480, 4800, 5120, 5440, 5760, 6080,
     4160, 4480, 4800, 5120, 5440, 5760, 6080, 6400
  };

  // Table used to drive the king towards the edge of the board
  // in KSF vs K.
  constexpr int PushToOpposingSideEdges[SQUARE_NB] = {
     30, 10,  5,  0,  0,  5, 10,  30,
     40, 20,  5,  0,  0,  5, 20,  40,
     50, 30, 10,  0,  0, 10, 30,  50,
     60, 40, 20, 10, 10, 20, 40,  60,
     70, 50, 30, 20, 20, 30, 50,  70,
     80, 60, 40, 30, 30, 40, 60,  80,
     90, 70, 60, 50, 50, 60, 70,  90,
    100, 90, 80, 70, 70, 80, 90, 100
  };

  // Tables used to drive a piece towards or away from another piece
  constexpr int PushClose[FILE_NB] = { 0, 0, 100, 80, 60, 40, 20, 10 };
  constexpr int PushAway [FILE_NB] = { 0, 5, 20, 40, 60, 80, 90, 100 };

  // Pawn Rank based scaling factors used in KRPPKRP endgame
  constexpr int KRPPKRPScaleFactors[RANK_NB] = { 0, 9, 10, 14, 21, 44, 0, 0 };

#ifndef NDEBUG
  bool verify_material(const Position& pos, Color c, Value npm, int pawnsCnt) {
    return pos.non_pawn_material(c) == npm && pos.count<PAWN>(c) == pawnsCnt;
  }
#endif

  // Map the square as if strongSide is white and strongSide's only pawn
  // is on the left half of the board.
  Square normalize(const Position& pos, Color strongSide, Square sq) {

    assert(pos.count<PAWN>(strongSide) == 1);

    if (file_of(pos.square<PAWN>(strongSide)) >= FILE_E)
        sq = Square(sq ^ 7); // Mirror SQ_H1 -> SQ_A1

    return strongSide == WHITE ? sq : ~sq;
  }

} // namespace

namespace Endgames {

  std::pair<Map<Value>, Map<ScaleFactor>> maps;

  void init() {

    add<KPK>("KPK");
    add<KNNK>("KNNK");
    add<KBNK>("KBNK");
    add<KRKP>("KRKP");
    add<KRKB>("KRKB");
    add<KRKN>("KRKN");
    add<KQKP>("KQKP");
    add<KQKR>("KQKR");
    add<KNNKP>("KNNKP");

    // Fairy piece endgames
    add<KNSK>("KNSK");
    add<KNFK>("KNFK");
    add<KNSFKR>("KNSFKR");
    add<KSFK>("KSFK");

    add<KNPK>("KNPK");
    add<KNPKB>("KNPKB");
    add<KRPKR>("KRPKR");
    add<KRPKB>("KRPKB");
    add<KBPKB>("KBPKB");
    add<KBPKN>("KBPKN");
    add<KBPPKB>("KBPPKB");
    add<KRPPKRP>("KRPPKRP");
  }
}

/// Mate with KX vs K. This function is used to evaluate positions with
/// king and plenty of material vs a lone king. It simply gives the
/// attacking side a bonus for driving the defending king towards the edge
/// of the board, and for keeping the distance between the two kings small.
template<>
Value Endgame<KXK>::operator()(const Position& pos) const {

  assert(verify_material(pos, weakSide, VALUE_ZERO, 0));
  assert(!pos.checkers()); // Eval is never called when in check

  // Stalemate detection with lone king
  if (pos.side_to_move() == weakSide && !MoveList<LEGAL>(pos).size())
      return VALUE_DRAW;

  Square winnerKSq = pos.square<KING>(strongSide);
  Square loserKSq = pos.square<KING>(weakSide);

  Value result =  pos.non_pawn_material(strongSide)
                + pos.count<PAWN>(strongSide) * PawnValueEg
                + PushToEdges[loserKSq]
                + PushClose[distance(winnerKSq, loserKSq)];

  if (   pos.count<QUEEN>(strongSide)
      || pos.count<ROOK>(strongSide)
      ||(pos.count<BISHOP>(strongSide) && pos.count<KNIGHT>(strongSide))
      || (   (pos.pieces(strongSide, BISHOP) & ~DarkSquares)
          && (pos.pieces(strongSide, BISHOP) &  DarkSquares))
      || pos.count<SILVER>(strongSide) >= 2
      ||(pos.count<SILVER>(strongSide) && pos.count<KNIGHT>(strongSide))
      ||(pos.count<SILVER>(strongSide) && pos.count<FERS>(strongSide))
      ||(pos.count<KNIGHT>(strongSide) && pos.count<FERS>(strongSide) >= 2)
      ||(pos.count<FERS>(strongSide) >= 3
          && ( DarkSquares & pos.pieces(strongSide, FERS))
          && (~DarkSquares & pos.pieces(strongSide, FERS))))
      result = std::min(result + VALUE_KNOWN_WIN, VALUE_MATE_IN_MAX_PLY - 1);

  return strongSide == pos.side_to_move() ? result : -result;

}

/// Mate with KX vs KX. This function is used to evaluate positions with
/// king and plenty of material vs a lone king. It simply gives the
/// attacking side a bonus for driving the defending king towards the edge
/// of the board, and for keeping the distance between the two kings small.
template<>
Value Endgame<KXKX>::operator()(const Position& pos) const {

  assert(verify_material(pos, weakSide, VALUE_ZERO, 0));
  assert(!pos.checkers()); // Eval is never called when in check

  // Stalemate detection with lone king
  if (pos.side_to_move() == weakSide && !MoveList<LEGAL>(pos).size())
      return VALUE_DRAW;

  Square winnerKSq = pos.square<KING>(strongSide);
  Square loserKSq = pos.square<KING>(weakSide);

  Value result =  pos.non_pawn_material(strongSide)
                + pos.count<PAWN>(strongSide) * PawnValueEg
                + PushToEdges[loserKSq]
                + PushClose[distance(winnerKSq, loserKSq)];

  if (   pos.count<QUEEN>(strongSide)
      || pos.count<ROOK>(strongSide)
      ||(pos.count<BISHOP>(strongSide) && pos.count<KNIGHT>(strongSide))
      || (   (pos.pieces(strongSide, BISHOP) & ~DarkSquares)
          && (pos.pieces(strongSide, BISHOP) &  DarkSquares))
      || pos.count<SILVER>(strongSide) >= 2
      ||(pos.count<SILVER>(strongSide) && pos.count<KNIGHT>(strongSide))
      ||(pos.count<SILVER>(strongSide) && pos.count<FERS>(strongSide))
      ||(pos.count<KNIGHT>(strongSide) && pos.count<FERS>(strongSide) >= 2)
      ||(pos.count<FERS>(strongSide) >= 3
          && ( DarkSquares & pos.pieces(strongSide, FERS))
          && (~DarkSquares & pos.pieces(strongSide, FERS))))
      result = std::min(result + VALUE_KNOWN_WIN, VALUE_MATE_IN_MAX_PLY - 1);

  return strongSide == pos.side_to_move() ? result : -result;

  //Conditions for win
  if (pos.count<ROOK>(strongSide) >=1
      || pos.count<SILVER>(strongSide) > 1
      ||(pos.count<SILVER>(strongSide)     && pos.count<KNIGHT>(strongSide))
      ||(pos.count<SILVER>(strongSide)     && (pos.count<PAWN>(strongSide)>=1))
      ||(pos.count<SILVER>(strongSide)     && (pos.count<FERS>(strongSide)>=1))
      ||(pos.count<KNIGHT>(strongSide)     && (pos.count<FERS>(strongSide)>1))
      ||((pos.count<KNIGHT>(strongSide)>1) && pos.count<FERS>(strongSide))
      ||((pos.count<ROOK>(strongSide)     && ((pos.count< FERS>(strongSide) && pos.count<KNIGHT>(strongSide)))  || ( pos.count<ROOK>(weakSide) && pos.count<FERS>(weakSide)))
     ||((pos.count<ROOK>(strongSide)     && ((pos.count< FERS>(strongSide)>1 )&& ( DarkSquares & pos.pieces(strongSide, FERS)+(~DarkSquares & pos.pieces(strongSide, FERS)  ||  pos.count<ROOK>(weakSide)) )))
     || ((pos.count<ROOK>(strongSide)     && ((pos.count< FERS>(strongSide)>1 ) && ( DarkSquares & pos.pieces(strongSide, FERS)+(~DarkSquares & pos.pieces(strongSide, FERS) || pos.count<ROOK>(weakSide)))))
      || (pos.count< FERS>(strongSide) >= 3 && (DarkSquares & pos.pieces(strongSide, FERS) >=2) +  (~DarkSquares & pos.pieces(strongSide, FERS) ==1)
       || (pos.count< FERS>(strongSide) >= 3) &&  (~DarkSquares & pos.pieces(strongSide, FERS)>=2) + (DarkSquares & pos.pieces(strongSide, FERS) ==1) )))))

    result = std::min(result + VALUE_KNOWN_WIN, VALUE_MATE_IN_MAX_PLY - 1);

  return strongSide == pos.side_to_move() ? result : -result;

}

/// Mate with KBN vs K. This is similar to KX vs K, but we have to drive the
/// defending king towards a corner square that our bishop attacks.
template<>
Value Endgame<KBNK>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, KnightValueMg + BishopValueMg, 0));
  assert(verify_material(pos, weakSide, VALUE_ZERO, 0));

  Square winnerKSq = pos.square<KING>(strongSide);
  Square loserKSq = pos.square<KING>(weakSide);
  Square bishopSq = pos.square<BISHOP>(strongSide);

  // If our Bishop does not attack A1/H8, we flip the enemy king square
  // to drive to opposite corners (A8/H1).

  Value result =  VALUE_KNOWN_WIN
                + PushClose[distance(winnerKSq, loserKSq)]
                + PushToCorners[opposite_colors(bishopSq, SQ_A1) ? ~loserKSq : loserKSq];

  assert(abs(result) < VALUE_MATE_IN_MAX_PLY);
  return strongSide == pos.side_to_move() ? result : -result;
}

/// KP vs K. This endgame is evaluated with the help of a bitbase.
template<>
Value Endgame<KPK>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, VALUE_ZERO, 1));
  assert(verify_material(pos, weakSide, VALUE_ZERO, 0));

  // Assume strongSide is white and the pawn is on files A-D
  Square wksq = normalize(pos, strongSide, pos.square<KING>(strongSide));
  Square bksq = normalize(pos, strongSide, pos.square<KING>(weakSide));
  Square psq  = normalize(pos, strongSide, pos.square<PAWN>(strongSide));

  Color us = strongSide == pos.side_to_move() ? WHITE : BLACK;

  Value result;
  if (   pos.promotion_rank() == RANK_8
      && RANK_MAX == RANK_8
      && pos.promotion_piece_types().find(QUEEN) != pos.promotion_piece_types().end())
  {
      if (!Bitbases::probe(wksq, psq, bksq, us))
          return VALUE_DRAW;

      result = VALUE_KNOWN_WIN + PawnValueEg + Value(rank_of(psq));
  }
  else
  {
      // Non-standard promotion, evaluation unclear
      result = PawnValueEg + Value(rank_of(psq));
  }

  return strongSide == pos.side_to_move() ? result : -result;
}

/// KR vs KP. This is a somewhat tricky endgame to evaluate precisely without
/// a bitbase. The function below returns drawish scores when the pawn is
/// far advanced with support of the king, while the attacking king is far
/// away.
template<>
Value Endgame<KRKP>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, RookValueMg, 0));
  assert(verify_material(pos, weakSide, VALUE_ZERO, 1));

  Square wksq = relative_square(strongSide, pos.square<KING>(strongSide));
  Square bksq = relative_square(strongSide, pos.square<KING>(weakSide));
  Square rsq  = relative_square(strongSide, pos.square<ROOK>(strongSide));
  Square psq  = relative_square(strongSide, pos.square<PAWN>(weakSide));

  Square queeningSq = make_square(file_of(psq), RANK_1);
  Value result;

  // If the stronger side's king is in front of the pawn, it's a win
  if (forward_file_bb(WHITE, wksq) & psq)
      result = RookValueEg - distance(wksq, psq);

  // If the weaker side's king is too far from the pawn and the rook,
  // it's a win.
  else if (   distance(bksq, psq) >= 3 + (pos.side_to_move() == weakSide)
           && distance(bksq, rsq) >= 3)
      result = RookValueEg - distance(wksq, psq);

  // If the pawn is far advanced and supported by the defending king,
  // the position is drawish
  else if (   rank_of(bksq) <= RANK_3
           && distance(bksq, psq) == 1
           && rank_of(wksq) >= RANK_4
           && distance(wksq, psq) > 2 + (pos.side_to_move() == strongSide))
      result = Value(80) - 8 * distance(wksq, psq);

  else
      result =  Value(200) - 8 * (  distance(wksq, psq + SOUTH)
                                  - distance(bksq, psq + SOUTH)
                                  - distance(psq, queeningSq));

  return strongSide == pos.side_to_move() ? result : -result;
}

/// KR vs KB. This is very simple, and always returns drawish scores. The
/// score is slightly bigger when the defending king is close to the edge.
template<>
Value Endgame<KRKB>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, RookValueMg, 0));
  assert(verify_material(pos, weakSide, BishopValueMg, 0));

  Value result = Value(PushToEdges[pos.square<KING>(weakSide)]);
  return strongSide == pos.side_to_move() ? result : -result;
}

/// KR vs KN. The attacking side has slightly better winning chances than
/// in KR vs KB, particularly if the king and the knight are far apart.
template<>
Value Endgame<KRKN>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, RookValueMg, 0));
  assert(verify_material(pos, weakSide, KnightValueMg, 0));

  Square bksq = pos.square<KING>(weakSide);
  Square bnsq = pos.square<KNIGHT>(weakSide);
  Value result = Value(PushToEdges[bksq] + PushAway[distance(bksq, bnsq)]);
  return strongSide == pos.side_to_move() ? result : -result;
}

/// KQ vs KP. In general, this is a win for the stronger side, but there are a
/// few important exceptions. A pawn on 7th rank and on the A,C,F or H files
/// with a king positioned next to it can be a draw, so in that case, we only
/// use the distance between the kings.
template<>
Value Endgame<KQKP>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, QueenValueMg, 0));
  assert(verify_material(pos, weakSide, VALUE_ZERO, 1));

  Square winnerKSq = pos.square<KING>(strongSide);
  Square loserKSq = pos.square<KING>(weakSide);
  Square pawnSq = pos.square<PAWN>(weakSide);

  Value result = Value(PushClose[distance(winnerKSq, loserKSq)]);

  if (   relative_rank(weakSide, pawnSq) != RANK_7
      || distance(loserKSq, pawnSq) != 1
      || !((FileABB | FileCBB | FileFBB | FileHBB) & pawnSq))
      result += QueenValueEg - PawnValueEg;

  return strongSide == pos.side_to_move() ? result : -result;
}

/// KQ vs KR.  This is almost identical to KX vs K:  We give the attacking
/// king a bonus for having the kings close together, and for forcing the
/// defending king towards the edge. If we also take care to avoid null move for
/// the defending side in the search, this is usually sufficient to win KQ vs KR.
template<>
Value Endgame<KQKR>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, QueenValueMg, 0));
  assert(verify_material(pos, weakSide, RookValueMg, 0));

  Square winnerKSq = pos.square<KING>(strongSide);
  Square loserKSq = pos.square<KING>(weakSide);

  Value result =  QueenValueEg
                - RookValueEg
                + PushToEdges[loserKSq]
                + PushClose[distance(winnerKSq, loserKSq)];

  return strongSide == pos.side_to_move() ? result : -result;
}

/// KNN vs KP. Simply push the opposing king to the corner
template<>
Value Endgame<KNNKP>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, 2 * KnightValueMg, 0));
  assert(verify_material(pos, weakSide, VALUE_ZERO, 1));

  Value result =  2 * KnightValueEg
                - PawnValueEg
                + PushToEdges[pos.square<KING>(weakSide)];

  return strongSide == pos.side_to_move() ? result : -result;
}

/// Some cases of trivial draws
template<> Value Endgame<KNNK>::operator()(const Position&) const { return VALUE_DRAW; }

/// KFsPs vs K.
template<>
Value Endgame<KFsPsK>::operator()(const Position& pos) const {

  assert(verify_material(pos, weakSide, VALUE_ZERO, 0));

  Square winnerKSq = pos.square<KING>(strongSide);
  Square loserKSq = pos.square<KING>(weakSide);

  Value result =  pos.non_pawn_material(strongSide)
                + pos.count<PAWN>(strongSide) * PawnValueEg
                + PushToEdges[loserKSq]
                + PushClose[distance(winnerKSq, loserKSq)];

  if (   pos.count<FERS>(strongSide) >= 3
      && ( DarkSquares & pos.pieces(strongSide, FERS))
      && (~DarkSquares & pos.pieces(strongSide, FERS)))
      result = std::min(result + VALUE_KNOWN_WIN, VALUE_MATE_IN_MAX_PLY - 1);
  else if (pos.count<FERS>(strongSide) + pos.count<PAWN>(strongSide) < 3)
      return VALUE_DRAW;
  else
  {
      bool dark  =  DarkSquares & pos.pieces(strongSide, FERS);
      bool light = ~DarkSquares & pos.pieces(strongSide, FERS);

      // Determine the color of ferzes from promoting pawns
      Bitboard b = pos.pieces(strongSide, PAWN);
      while (b && (!dark || !light))
      {
          if (file_of(pop_lsb(&b)) % 2 == relative_rank(strongSide, pos.promotion_rank(), pos.max_rank()) % 2)
              light = true;
          else
              dark = true;
      }
      if (!dark || !light)
          return VALUE_DRAW; // we can not checkmate with same colored ferzes
  }

  return strongSide == pos.side_to_move() ? result : -result;
}

/// Mate with KNS vs K.
template<>
Value Endgame<KNSK>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, KnightValueMg + SilverValueMg, 0));
  assert(verify_material(pos, weakSide, VALUE_ZERO, 0));

  Square winnerKSq = pos.square<KING>(strongSide);
  Square loserKSq = pos.square<KING>(weakSide);

  Value result =  VALUE_KNOWN_WIN
                + PushClose[distance(winnerKSq, loserKSq)]
                + PushToOpposingSideEdges[strongSide == WHITE ? loserKSq : ~loserKSq];

  return strongSide == pos.side_to_move() ? result : -result;
}

/// KNF vs K. Can only be won if the weaker side's king
/// is close to a corner of the same color as the fers.
template<>
Value Endgame<KNFK>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, KnightValueMg + FersValueMg, 0));
  assert(verify_material(pos, weakSide, VALUE_ZERO, 0));

  Square winnerKSq = pos.square<KING>(strongSide);
  Square loserKSq = pos.square<KING>(weakSide);
  Square fersSq = pos.square<FERS>(strongSide);

  // tries to drive toward corners A1 or H8. If we have a
  // fers that cannot reach the above squares, we flip the kings in order
  // to drive the enemy toward corners A8 or H1.
  if (opposite_colors(fersSq, SQ_A1))
  {
      winnerKSq = ~winnerKSq;
      loserKSq  = ~loserKSq;
  }

  Value result =  Value(PushClose[distance(winnerKSq, loserKSq)])
                + PushToCorners[loserKSq];

  return strongSide == pos.side_to_move() ? result : -result;
}

/// KNSFKR vs K.
template<>
Value Endgame<KNSFKR>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, KnightValueMg + SilverValueMg + FersValueMg, 0));
  assert(verify_material(pos, weakSide, RookValueMg, 0));

  Square winnerKSq = pos.square<KING>(strongSide);
  Square loserKSq = pos.square<KING>(weakSide);

  Value result =  KnightValueEg + SilverValueEg + FersValueEg - RookValueEg
                + PushClose[distance(winnerKSq, loserKSq)]
                + PushToOpposingSideEdges[strongSide == WHITE ? loserKSq : ~loserKSq];

  return strongSide == pos.side_to_move() ? result : -result;

}

/// Mate with KSF vs K.
template<>
Value Endgame<KSFK>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, SilverValueMg + FersValueMg, 0));
  assert(verify_material(pos, weakSide, VALUE_ZERO, 0));

  Square winnerKSq = pos.square<KING>(strongSide);
  Square loserKSq = pos.square<KING>(weakSide);

  Value result =  VALUE_KNOWN_WIN
                + PushClose[distance(winnerKSq, loserKSq)]
                + PushToOpposingSideEdges[strongSide == WHITE ? loserKSq : ~loserKSq];

  return strongSide == pos.side_to_move() ? result : -result;
}

/// KB and one or more pawns vs K. It checks for draws with rook pawns and
/// a bishop of the wrong color. If such a draw is detected, SCALE_FACTOR_DRAW
/// is returned. If not, the return value is SCALE_FACTOR_NONE, i.e. no scaling
/// will be used.
template<>
ScaleFactor Endgame<KBPsK>::operator()(const Position& pos) const {

  assert(pos.non_pawn_material(strongSide) == BishopValueMg);
  assert(pos.count<PAWN>(strongSide) >= 1);

  // No assertions about the material of weakSide, because we want draws to
  // be detected even when the weaker side has some pawns.

  Bitboard pawns = pos.pieces(strongSide, PAWN);
  File pawnsFile = file_of(lsb(pawns));

  // All pawns are on a single rook file?
  if (    (pawnsFile == FILE_A || pawnsFile == FILE_H)
      && !(pawns & ~file_bb(pawnsFile)))
  {
      Square bishopSq = pos.square<BISHOP>(strongSide);
      Square queeningSq = relative_square(strongSide, make_square(pawnsFile, RANK_8));
      Square kingSq = pos.square<KING>(weakSide);

      if (   opposite_colors(queeningSq, bishopSq)
          && distance(queeningSq, kingSq) <= 1)
          return SCALE_FACTOR_DRAW;
  }

  // If all the pawns are on the same B or G file, then it's potentially a draw
  if (    (pawnsFile == FILE_B || pawnsFile == FILE_G)
      && !(pos.pieces(PAWN) & ~file_bb(pawnsFile))
      && pos.non_pawn_material(weakSide) == 0
      && pos.count<PAWN>(weakSide) >= 1)
  {
      // Get weakSide pawn that is closest to the home rank
      Square weakPawnSq = frontmost_sq(strongSide, pos.pieces(weakSide, PAWN));

      Square strongKingSq = pos.square<KING>(strongSide);
      Square weakKingSq = pos.square<KING>(weakSide);
      Square bishopSq = pos.square<BISHOP>(strongSide);

      // There's potential for a draw if our pawn is blocked on the 7th rank,
      // the bishop cannot attack it or they only have one pawn left
      if (   relative_rank(strongSide, weakPawnSq) == RANK_7
          && (pos.pieces(strongSide, PAWN) & (weakPawnSq + pawn_push(weakSide)))
          && (opposite_colors(bishopSq, weakPawnSq) || pos.count<PAWN>(strongSide) == 1))
      {
          int strongKingDist = distance(weakPawnSq, strongKingSq);
          int weakKingDist = distance(weakPawnSq, weakKingSq);

          // It's a draw if the weak king is on its back two ranks, within 2
          // squares of the blocking pawn and the strong king is not
          // closer. (I think this rule only fails in practically
          // unreachable positions such as 5k1K/6p1/6P1/8/8/3B4/8/8 w
          // and positions where qsearch will immediately correct the
          // problem such as 8/4k1p1/6P1/1K6/3B4/8/8/8 w)
          if (   relative_rank(strongSide, weakKingSq) >= RANK_7
              && weakKingDist <= 2
              && weakKingDist <= strongKingDist)
              return SCALE_FACTOR_DRAW;
      }
  }

  return SCALE_FACTOR_NONE;
}

/// KQ vs KR and one or more pawns. It tests for fortress draws with a rook on
/// the third rank defended by a pawn.
template<>
ScaleFactor Endgame<KQKRPs>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, QueenValueMg, 0));
  assert(pos.count<ROOK>(weakSide) == 1);
  assert(pos.count<PAWN>(weakSide) >= 1);

  Square kingSq = pos.square<KING>(weakSide);
  Square rsq = pos.square<ROOK>(weakSide);

  if (    relative_rank(weakSide, kingSq) <= RANK_2
      &&  relative_rank(weakSide, pos.square<KING>(strongSide)) >= RANK_4
      &&  relative_rank(weakSide, rsq) == RANK_3
      && (  pos.pieces(weakSide, PAWN)
          & pos.attacks_from<KING>(weakSide, kingSq)
          & pos.attacks_from<PAWN>(strongSide, rsq)))
          return SCALE_FACTOR_DRAW;

  return SCALE_FACTOR_NONE;
}

/// KRP vs KR. This function knows a handful of the most important classes of
/// drawn positions, but is far from perfect. It would probably be a good idea
/// to add more knowledge in the future.
///
/// It would also be nice to rewrite the actual code for this function,
/// which is mostly copied from Glaurung 1.x, and isn't very pretty.
template<>
ScaleFactor Endgame<KRPKR>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, RookValueMg, 1));
  assert(verify_material(pos, weakSide,   RookValueMg, 0));

  // Assume strongSide is white and the pawn is on files A-D
  Square wksq = normalize(pos, strongSide, pos.square<KING>(strongSide));
  Square bksq = normalize(pos, strongSide, pos.square<KING>(weakSide));
  Square wrsq = normalize(pos, strongSide, pos.square<ROOK>(strongSide));
  Square wpsq = normalize(pos, strongSide, pos.square<PAWN>(strongSide));
  Square brsq = normalize(pos, strongSide, pos.square<ROOK>(weakSide));

  File f = file_of(wpsq);
  Rank r = rank_of(wpsq);
  Square queeningSq = make_square(f, RANK_8);
  int tempo = (pos.side_to_move() == strongSide);

  // If the pawn is not too far advanced and the defending king defends the
  // queening square, use the third-rank defence.
  if (   r <= RANK_5
      && distance(bksq, queeningSq) <= 1
      && wksq <= SQ_H5
      && (rank_of(brsq) == RANK_6 || (r <= RANK_3 && rank_of(wrsq) != RANK_6)))
      return SCALE_FACTOR_DRAW;

  // The defending side saves a draw by checking from behind in case the pawn
  // has advanced to the 6th rank with the king behind.
  if (   r == RANK_6
      && distance(bksq, queeningSq) <= 1
      && rank_of(wksq) + tempo <= RANK_6
      && (rank_of(brsq) == RANK_1 || (!tempo && distance<File>(brsq, wpsq) >= 3)))
      return SCALE_FACTOR_DRAW;

  if (   r >= RANK_6
      && bksq == queeningSq
      && rank_of(brsq) == RANK_1
      && (!tempo || distance(wksq, wpsq) >= 2))
      return SCALE_FACTOR_DRAW;

  // White pawn on a7 and rook on a8 is a draw if black's king is on g7 or h7
  // and the black rook is behind the pawn.
  if (   wpsq == SQ_A7
      && wrsq == SQ_A8
      && (bksq == SQ_H7 || bksq == SQ_G7)
      && file_of(brsq) == FILE_A
      && (rank_of(brsq) <= RANK_3 || file_of(wksq) >= FILE_D || rank_of(wksq) <= RANK_5))
      return SCALE_FACTOR_DRAW;

  // If the defending king blocks the pawn and the attacking king is too far
  // away, it's a draw.
  if (   r <= RANK_5
      && bksq == wpsq + NORTH
      && distance(wksq, wpsq) - tempo >= 2
      && distance(wksq, brsq) - tempo >= 2)
      return SCALE_FACTOR_DRAW;

  // Pawn on the 7th rank supported by the rook from behind usually wins if the
  // attacking king is closer to the queening square than the defending king,
  // and the defending king cannot gain tempi by threatening the attacking rook.
  if (   r == RANK_7
      && f != FILE_A
      && file_of(wrsq) == f
      && wrsq != queeningSq
      && (distance(wksq, queeningSq) < distance(bksq, queeningSq) - 2 + tempo)
      && (distance(wksq, queeningSq) < distance(bksq, wrsq) + tempo))
      return ScaleFactor(SCALE_FACTOR_MAX - 2 * distance(wksq, queeningSq));

  // Similar to the above, but with the pawn further back
  if (   f != FILE_A
      && file_of(wrsq) == f
      && wrsq < wpsq
      && (distance(wksq, queeningSq) < distance(bksq, queeningSq) - 2 + tempo)
      && (distance(wksq, wpsq + NORTH) < distance(bksq, wpsq + NORTH) - 2 + tempo)
      && (  distance(bksq, wrsq) + tempo >= 3
          || (    distance(wksq, queeningSq) < distance(bksq, wrsq) + tempo
              && (distance(wksq, wpsq + NORTH) < distance(bksq, wrsq) + tempo))))
      return ScaleFactor(  SCALE_FACTOR_MAX
                         - 8 * distance(wpsq, queeningSq)
                         - 2 * distance(wksq, queeningSq));

  // If the pawn is not far advanced and the defending king is somewhere in
  // the pawn's path, it's probably a draw.
  if (r <= RANK_4 && bksq > wpsq)
  {
      if (file_of(bksq) == file_of(wpsq))
          return ScaleFactor(10);
      if (   distance<File>(bksq, wpsq) == 1
          && distance(wksq, bksq) > 2)
          return ScaleFactor(24 - 2 * distance(wksq, bksq));
  }
  return SCALE_FACTOR_NONE;
}

template<>
ScaleFactor Endgame<KRPKB>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, RookValueMg, 1));
  assert(verify_material(pos, weakSide, BishopValueMg, 0));

  // Test for a rook pawn
  if (pos.pieces(PAWN) & (FileABB | FileHBB))
  {
      Square ksq = pos.square<KING>(weakSide);
      Square bsq = pos.square<BISHOP>(weakSide);
      Square psq = pos.square<PAWN>(strongSide);
      Rank rk = relative_rank(strongSide, psq);
      Direction push = pawn_push(strongSide);

      // If the pawn is on the 5th rank and the pawn (currently) is on
      // the same color square as the bishop then there is a chance of
      // a fortress. Depending on the king position give a moderate
      // reduction or a stronger one if the defending king is near the
      // corner but not trapped there.
      if (rk == RANK_5 && !opposite_colors(bsq, psq))
      {
          int d = distance(psq + 3 * push, ksq);

          if (d <= 2 && !(d == 0 && ksq == pos.square<KING>(strongSide) + 2 * push))
              return ScaleFactor(24);
          else
              return ScaleFactor(48);
      }

      // When the pawn has moved to the 6th rank we can be fairly sure
      // it's drawn if the bishop attacks the square in front of the
      // pawn from a reasonable distance and the defending king is near
      // the corner
      if (   rk == RANK_6
          && distance(psq + 2 * push, ksq) <= 1
          && (PseudoAttacks[strongSide][BISHOP][bsq] & (psq + push))
          && distance<File>(bsq, psq) >= 2)
          return ScaleFactor(8);
  }

  return SCALE_FACTOR_NONE;
}

/// KRPP vs KRP. There is just a single rule: if the stronger side has no passed
/// pawns and the defending king is actively placed, the position is drawish.
template<>
ScaleFactor Endgame<KRPPKRP>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, RookValueMg, 2));
  assert(verify_material(pos, weakSide,   RookValueMg, 1));

  Square wpsq1 = pos.squares<PAWN>(strongSide)[0];
  Square wpsq2 = pos.squares<PAWN>(strongSide)[1];
  Square bksq = pos.square<KING>(weakSide);

  // Does the stronger side have a passed pawn?
  if (pos.pawn_passed(strongSide, wpsq1) || pos.pawn_passed(strongSide, wpsq2))
      return SCALE_FACTOR_NONE;

  Rank r = std::max(relative_rank(strongSide, wpsq1), relative_rank(strongSide, wpsq2));

  if (   distance<File>(bksq, wpsq1) <= 1
      && distance<File>(bksq, wpsq2) <= 1
      && relative_rank(strongSide, bksq) > r)
  {
      assert(r > RANK_1 && r < RANK_7);
      return ScaleFactor(KRPPKRPScaleFactors[r]);
  }
  return SCALE_FACTOR_NONE;
}

/// K and two or more pawns vs K. There is just a single rule here: If all pawns
/// are on the same rook file and are blocked by the defending king, it's a draw.
template<>
ScaleFactor Endgame<KPsK>::operator()(const Position& pos) const {

  assert(pos.non_pawn_material(strongSide) == VALUE_ZERO);
  assert(pos.count<PAWN>(strongSide) >= 2);
  assert(verify_material(pos, weakSide, VALUE_ZERO, 0));

  Square ksq = pos.square<KING>(weakSide);
  Bitboard pawns = pos.pieces(strongSide, PAWN);

  // If all pawns are ahead of the king, on a single rook file and
  // the king is within one file of the pawns, it's a draw.
  if (   !(pawns & ~forward_ranks_bb(weakSide, ksq))
      && !((pawns & ~FileABB) && (pawns & ~FileHBB))
      &&  distance<File>(ksq, lsb(pawns)) <= 1)
      return SCALE_FACTOR_DRAW;

  return SCALE_FACTOR_NONE;
}

/// KBP vs KB. There are two rules: if the defending king is somewhere along the
/// path of the pawn, and the square of the king is not of the same color as the
/// stronger side's bishop, it's a draw. If the two bishops have opposite color,
/// it's almost always a draw.
template<>
ScaleFactor Endgame<KBPKB>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, BishopValueMg, 1));
  assert(verify_material(pos, weakSide,   BishopValueMg, 0));

  Square pawnSq = pos.square<PAWN>(strongSide);
  Square strongBishopSq = pos.square<BISHOP>(strongSide);
  Square weakBishopSq = pos.square<BISHOP>(weakSide);
  Square weakKingSq = pos.square<KING>(weakSide);

  // Case 1: Defending king blocks the pawn, and cannot be driven away
  if (   file_of(weakKingSq) == file_of(pawnSq)
      && relative_rank(strongSide, pawnSq) < relative_rank(strongSide, weakKingSq)
      && (   opposite_colors(weakKingSq, strongBishopSq)
          || relative_rank(strongSide, weakKingSq) <= RANK_6))
      return SCALE_FACTOR_DRAW;

  // Case 2: Opposite colored bishops
  if (opposite_colors(strongBishopSq, weakBishopSq))
      return SCALE_FACTOR_DRAW;

  return SCALE_FACTOR_NONE;
}

/// KBPP vs KB. It detects a few basic draws with opposite-colored bishops
template<>
ScaleFactor Endgame<KBPPKB>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, BishopValueMg, 2));
  assert(verify_material(pos, weakSide,   BishopValueMg, 0));

  Square wbsq = pos.square<BISHOP>(strongSide);
  Square bbsq = pos.square<BISHOP>(weakSide);

  if (!opposite_colors(wbsq, bbsq))
      return SCALE_FACTOR_NONE;

  Square ksq = pos.square<KING>(weakSide);
  Square psq1 = pos.squares<PAWN>(strongSide)[0];
  Square psq2 = pos.squares<PAWN>(strongSide)[1];
  Square blockSq1, blockSq2;

  if (relative_rank(strongSide, psq1) > relative_rank(strongSide, psq2))
  {
      blockSq1 = psq1 + pawn_push(strongSide);
      blockSq2 = make_square(file_of(psq2), rank_of(psq1));
  }
  else
  {
      blockSq1 = psq2 + pawn_push(strongSide);
      blockSq2 = make_square(file_of(psq1), rank_of(psq2));
  }

  switch (distance<File>(psq1, psq2))
  {
  case 0:
    // Both pawns are on the same file. It's an easy draw if the defender firmly
    // controls some square in the frontmost pawn's path.
    if (   file_of(ksq) == file_of(blockSq1)
        && relative_rank(strongSide, ksq) >= relative_rank(strongSide, blockSq1)
        && opposite_colors(ksq, wbsq))
        return SCALE_FACTOR_DRAW;
    else
        return SCALE_FACTOR_NONE;

  case 1:
    // Pawns on adjacent files. It's a draw if the defender firmly controls the
    // square in front of the frontmost pawn's path, and the square diagonally
    // behind this square on the file of the other pawn.
    if (   ksq == blockSq1
        && opposite_colors(ksq, wbsq)
        && (   bbsq == blockSq2
            || (pos.attacks_from<BISHOP>(weakSide, blockSq2) & pos.pieces(weakSide, BISHOP))
            || distance<Rank>(psq1, psq2) >= 2))
        return SCALE_FACTOR_DRAW;

    else if (   ksq == blockSq2
             && opposite_colors(ksq, wbsq)
             && (   bbsq == blockSq1
                 || (pos.attacks_from<BISHOP>(weakSide, blockSq1) & pos.pieces(weakSide, BISHOP))))
        return SCALE_FACTOR_DRAW;
    else
        return SCALE_FACTOR_NONE;

  default:
    // The pawns are not on the same file or adjacent files. No scaling.
    return SCALE_FACTOR_NONE;
  }
}

/// KBP vs KN. There is a single rule: If the defending king is somewhere along
/// the path of the pawn, and the square of the king is not of the same color as
/// the stronger side's bishop, it's a draw.
template<>
ScaleFactor Endgame<KBPKN>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, BishopValueMg, 1));
  assert(verify_material(pos, weakSide, KnightValueMg, 0));

  Square pawnSq = pos.square<PAWN>(strongSide);
  Square strongBishopSq = pos.square<BISHOP>(strongSide);
  Square weakKingSq = pos.square<KING>(weakSide);

  if (   file_of(weakKingSq) == file_of(pawnSq)
      && relative_rank(strongSide, pawnSq) < relative_rank(strongSide, weakKingSq)
      && (   opposite_colors(weakKingSq, strongBishopSq)
          || relative_rank(strongSide, weakKingSq) <= RANK_6))
      return SCALE_FACTOR_DRAW;

  return SCALE_FACTOR_NONE;
}

/// KNP vs K. There is a single rule: if the pawn is a rook pawn on the 7th rank
/// and the defending king prevents the pawn from advancing, the position is drawn.
template<>
ScaleFactor Endgame<KNPK>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, KnightValueMg, 1));
  assert(verify_material(pos, weakSide, VALUE_ZERO, 0));

  // Assume strongSide is white and the pawn is on files A-D
  Square pawnSq     = normalize(pos, strongSide, pos.square<PAWN>(strongSide));
  Square weakKingSq = normalize(pos, strongSide, pos.square<KING>(weakSide));

  if (pawnSq == SQ_A7 && distance(SQ_A8, weakKingSq) <= 1)
      return SCALE_FACTOR_DRAW;

  return SCALE_FACTOR_NONE;
}

/// KNP vs KB. If knight can block bishop from taking pawn, it's a win.
/// Otherwise the position is drawn.
template<>
ScaleFactor Endgame<KNPKB>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, KnightValueMg, 1));
  assert(verify_material(pos, weakSide, BishopValueMg, 0));

  Square pawnSq = pos.square<PAWN>(strongSide);
  Square bishopSq = pos.square<BISHOP>(weakSide);
  Square weakKingSq = pos.square<KING>(weakSide);

  // King needs to get close to promoting pawn to prevent knight from blocking.
  // Rules for this are very tricky, so just approximate.
  if (forward_file_bb(strongSide, pawnSq) & pos.attacks_from<BISHOP>(weakSide, bishopSq))
      return ScaleFactor(distance(weakKingSq, pawnSq));

  return SCALE_FACTOR_NONE;
}

/// KP vs KP. This is done by removing the weakest side's pawn and probing the
/// KP vs K bitbase: If the weakest side has a draw without the pawn, it probably
/// has at least a draw with the pawn as well. The exception is when the stronger
/// side's pawn is far advanced and not on a rook file; in this case it is often
/// possible to win (e.g. 8/4k3/3p4/3P4/6K1/8/8/8 w - - 0 1).
template<>
ScaleFactor Endgame<KPKP>::operator()(const Position& pos) const {

  assert(verify_material(pos, strongSide, VALUE_ZERO, 1));
  assert(verify_material(pos, weakSide,   VALUE_ZERO, 1));

  // Assume strongSide is white and the pawn is on files A-D
  Square wksq = normalize(pos, strongSide, pos.square<KING>(strongSide));
  Square bksq = normalize(pos, strongSide, pos.square<KING>(weakSide));
  Square psq  = normalize(pos, strongSide, pos.square<PAWN>(strongSide));

  Color us = strongSide == pos.side_to_move() ? WHITE : BLACK;

  // If the pawn has advanced to the fifth rank or further, and is not a
  // rook pawn, it's too dangerous to assume that it's at least a draw.
  if (rank_of(psq) >= RANK_5 && file_of(psq) != FILE_A)
      return SCALE_FACTOR_NONE;

  // Probe the KPK bitbase with the weakest side's pawn removed. If it's a draw,
  // it's probably at least a draw even with the pawn.
  if (   pos.promotion_rank() == RANK_8
      && RANK_MAX == RANK_8
      && pos.promotion_piece_types().find(QUEEN) != pos.promotion_piece_types().end())
      return Bitbases::probe(wksq, psq, bksq, us) ? SCALE_FACTOR_NONE : SCALE_FACTOR_DRAW;
  else
      return SCALE_FACTOR_NONE;
}

/*
  Stockfish, a UCI chess playing engine derived from Glaurung 2.1
  Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
  Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
  Copyright (C) 2015-2019 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad

  Stockfish is free software: you can redistribute it and/or modify
  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/>.
*/

#ifndef ENDGAME_H_INCLUDED
#define ENDGAME_H_INCLUDED

#include <unordered_map>
#include <memory>
#include <string>
#include <type_traits>
#include <utility>

#include "position.h"
#include "types.h"

/// EndgameCode lists all supported endgame functions by corresponding codes

enum EndgameCode {

  EVALUATION_FUNCTIONS,
//  KNNK,  // KNN vs K
  KNNKP, // KNN vs KP
  KXK,   // Generic "mate lone king" eval
  KXKX,   // Generic "mate king and Pieces" eval
  KBNK,  // KBN vs K
  KPK,   // KP vs K
  KRKP,  // KR vs KP
  KRKB,  // KR vs KB
//  KRKN,  // KR vs KN
  KQKP,  // KQ vs KP
  KQKR,  // KQ vs KR

  // Fairy piece endgames
  KFsPsK, // KFsPsK vs K
  KNSK,  // KNS vs K
  KNFK,  // KNF vs K
  KNSFKR,  // KNSFKR vs K
  KSFK,  // KSF vs K
KNNK,
  KNK,
  KBK,
  KRKN,
  KNQQKB,
  KNBQKN,
  KNBQKB,
  KNQQQK,
  KNQQK,
  KBQK,
  KBBK,
  KNBK,
  KNNQK,
  KNBQK,
  KBBQK,
  KBQQK,
  KRNBQKR,
  KRBQKR,
  KRBBKR,
  KRNQKR,
  KRNNQKR,
  KRQQQKR,
  KQQQKQ,
  KQQQQKQ,
  KBQQQKQ,
  KNQQQKQ,

  SCALING_FUNCTIONS,
  KBPsK,   // KB and pawns vs K
  KQKRPs,  // KQ vs KR and pawns
  KRPKR,   // KRP vs KR
  KRPKB,   // KRP vs KB
  KRPPKRP, // KRPP vs KRP
  KPsK,    // K and pawns vs K
  KBPKB,   // KBP vs KB
  KBPPKB,  // KBPP vs KB
  KBPKN,   // KBP vs KN
  KNPK,    // KNP vs K
  KNPKB,   // KNP vs KB
  KPKP     // KP vs KP
};

/// Endgame functions can be of two types depending on whether they return a
/// Value or a ScaleFactor.

template<EndgameCode E> using
eg_type = typename std::conditional<(E < SCALING_FUNCTIONS), Value, ScaleFactor>::type;

/// Base and derived functors for endgame evaluation and scaling functions

template<typename T>
struct EndgameBase {

  explicit EndgameBase(Color c) : strongSide(c), weakSide(~c) {}
  virtual ~EndgameBase() = default;
  virtual T operator()(const Position&) const = 0;

  const Color strongSide, weakSide;
};

template<EndgameCode E, typename T = eg_type<E>>
struct Endgame : public EndgameBase<T> {

  explicit Endgame(Color c) : EndgameBase<T>(c) {}
  T operator()(const Position&) const override;
};

/// The Endgames namespace handles the pointers to endgame evaluation and scaling
/// base objects in two std::map. We use polymorphism to invoke the actual
/// endgame function by calling its virtual operator().

namespace Endgames {

  template<typename T> using Ptr = std::unique_ptr<EndgameBase<T>>;
  template<typename T> using Map = std::unordered_map<Key, Ptr<T>>;

  extern std::pair<Map<Value>, Map<ScaleFactor>> maps;

  void init();

  template<typename T>
  Map<T>& map() {
    return std::get<std::is_same<T, ScaleFactor>::value>(maps);
  }

  template<EndgameCode E, typename T = eg_type<E>>
  void add(const std::string& code) {

    StateInfo st;
    map<T>()[Position().set(code, WHITE, &st).material_key()] = Ptr<T>(new Endgame<E>(WHITE));
    map<T>()[Position().set(code, BLACK, &st).material_key()] = Ptr<T>(new Endgame<E>(BLACK));
  }

  template<typename T>
  const EndgameBase<T>* probe(Key key) {
    auto it = map<T>().find(key);
    return it != map<T>().end() ? it->second.get() : nullptr;
  }
}

#endif // #ifndef ENDGAME_H_INCLUDED

/*
  Stockfish, a UCI chess playing engine derived from Glaurung 2.1
  Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
  Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
  Copyright (C) 2015-2019 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad

  Stockfish is free software: you can redistribute it and/or modify
  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/>.
*/

#include <algorithm>
#include <cassert>
#include <cstring>   // For std::memset
#include <iomanip>
#include <sstream>

#include "bitboard.h"
#include "evaluate.h"
#include "material.h"
#include "pawns.h"
#include "thread.h"
#include "uci.h"
#include "position.h"
#include "syzygy/tbprobe.h"

namespace Trace {

  enum Tracing { NO_TRACE, TRACE };

  enum Term { // The first PIECE_TYPE_NB entries are reserved for PieceType
    MATERIAL = PIECE_TYPE_NB, IMBALANCE, MOBILITY, THREAT, PASSED, SPACE, INITIATIVE, VARIANT, TOTAL, TERM_NB
  };

  Score scores[TERM_NB][COLOR_NB];

  double to_cp(Value v) { return double(v) / PawnValueEg; }

  void add(int idx, Color c, Score s) {
    scores[idx][c] = s;
  }

  void add(int idx, Score w, Score b = SCORE_ZERO) {
    scores[idx][WHITE] = w;
    scores[idx][BLACK] = b;
  }

  std::ostream& operator<<(std::ostream& os, Score s) {
    os << std::setw(5) << to_cp(mg_value(s)) << " "
       << std::setw(5) << to_cp(eg_value(s));
    return os;
  }

  std::ostream& operator<<(std::ostream& os, Term t) {

    if (t == MATERIAL || t == IMBALANCE || t == INITIATIVE || t == TOTAL)
        os << " ----  ----"    << " | " << " ----  ----";
    else
        os << scores[t][WHITE] << " | " << scores[t][BLACK];

    os << " | " << scores[t][WHITE] - scores[t][BLACK] << "\n";
    return os;
  }
}

using namespace Trace;

namespace {

  // Threshold for lazy and space evaluation
  constexpr Value LazyThreshold  = Value(1400);
  constexpr Value SpaceThreshold = Value(12222);

  // KingAttackWeights[PieceType] contains king attack weights by piece type
  constexpr int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 77, 55, 44, 10, 40 };

  // Penalties for enemy's safe checks
  constexpr int QueenSafeCheck  = 780;
  constexpr int RookSafeCheck   = 1080;
  constexpr int BishopSafeCheck = 635;
  constexpr int KnightSafeCheck = 790;
  constexpr int OtherSafeCheck  = 600;

#define S(mg, eg) make_score(mg, eg)

  // MobilityBonus[PieceType-2][attacked] contains bonuses for middle and end game,
  // indexed by piece type and number of attacked squares in the mobility area.
#ifdef LARGEBOARDS
  constexpr Score MobilityBonus[][38] = {
#else
  constexpr Score MobilityBonus[][32] = {
#endif
    { S(-62,-81), S(-53,-56), S(-12,-30), S( -4,-14), S(  3,  8), S( 13, 15), // Knights
      S( 22, 23), S( 28, 27), S( 33, 33) },
    { S(-48,-59), S(-20,-23), S( 16, -3), S( 26, 13), S( 38, 24), S( 51, 42), // Bishops
      S( 55, 54), S( 63, 57), S( 63, 65), S( 68, 73), S( 81, 78), S( 81, 86),
      S( 91, 88), S( 98, 97) },
    { S(-58,-76), S(-27,-18), S(-15, 28), S(-10, 55), S( -5, 69), S( -2, 82), // Rooks
      S(  9,112), S( 16,118), S( 30,132), S( 29,142), S( 32,155), S( 38,165),
      S( 46,166), S( 48,169), S( 58,171) },
    { S(-39,-36), S(-21,-15), S(  3,  8), S(  3, 18), S( 14, 34), S( 22, 54), // Queens
      S( 28, 61), S( 41, 73), S( 43, 79), S( 48, 92), S( 56, 94), S( 60,104),
      S( 60,113), S( 66,120), S( 67,123), S( 70,126), S( 71,133), S( 73,136),
      S( 79,140), S( 88,143), S( 88,148), S( 99,166), S(102,170), S(102,175),
      S(106,184), S(109,191), S(113,206), S(116,212) }
  };
  constexpr Score MaxMobility  = S(250, 250);
  constexpr Score DropMobility = S(10, 10);

  // RookOnFile[semiopen/open] contains bonuses for each rook when there is
  // no (friendly) pawn on the rook file.
  constexpr Score RookOnFile[] = { S(18, 7), S(44, 20) };

  // ThreatByMinor/ByRook[attacked PieceType] contains bonuses according to
  // which piece type attacks which one. Attacks on lesser pieces which are
  // pawn-defended are not considered.
  constexpr Score ThreatByMinor[PIECE_TYPE_NB] = {
    S(0, 0), S(0, 31), S(39, 42), S(57, 44), S(68, 112), S(62, 120)
  };

  constexpr Score ThreatByRook[PIECE_TYPE_NB] = {
    S(0, 0), S(0, 24), S(38, 71), S(38, 61), S(0, 38), S(51, 38)
  };

  // PassedRank[Rank] contains a bonus according to the rank of a passed pawn
  constexpr Score PassedRank[RANK_NB] = {
    S(0, 0), S(10, 28), S(17, 33), S(15, 41), S(62, 72), S(168, 177), S(276, 260)
  };

  // KingProximity contains a penalty according to distance from king
  constexpr Score KingProximity = S(1, 3);

  // Assorted bonuses and penalties
  constexpr Score BishopPawns        = S(  3,  7);
  constexpr Score CorneredBishop     = S( 50, 50);
  constexpr Score FlankAttacks       = S(  8,  0);
  constexpr Score Hanging            = S( 69, 36);
  constexpr Score KingProtector      = S(  7,  8);
  constexpr Score KnightOnQueen      = S( 16, 12);
  constexpr Score LongDiagonalBishop = S( 45,  0);
  constexpr Score MinorBehindPawn    = S( 18,  3);
  constexpr Score Outpost            = S( 18,  6);
  constexpr Score PassedFile         = S( 11,  8);
  constexpr Score PawnlessFlank      = S( 17, 95);
  constexpr Score RestrictedPiece    = S(  7,  7);
  constexpr Score RookOnPawn         = S( 10, 32);
  constexpr Score RookOnQueenFile    = S( 11,  4);
  constexpr Score SliderOnQueen      = S( 59, 18);
  constexpr Score ThreatByKing       = S( 24, 89);
  constexpr Score ThreatByPawnPush   = S( 48, 39);
  constexpr Score ThreatByRank       = S( 13,  0);
  constexpr Score ThreatBySafePawn   = S(173, 94);
  constexpr Score TrappedRook        = S( 47,  4);
  constexpr Score WeakQueen          = S( 49, 15);

#undef S

  // Evaluation class computes and stores attacks tables and other working data
  template<Tracing T>
  class Evaluation {

  public:
    Evaluation() = delete;
    explicit Evaluation(const Position& p) : pos(p) {}
    Evaluation& operator=(const Evaluation&) = delete;
    Value value();

  private:
    template<Color Us> void initialize();
    template<Color Us> Score pieces(PieceType Pt);
    template<Color Us> Score hand(PieceType pt);
    template<Color Us> Score king() const;
    template<Color Us> Score threats() const;
    template<Color Us> Score passed() const;
    template<Color Us> Score space() const;
    template<Color Us> Score variant() const;
    ScaleFactor scale_factor(Value eg) const;
    Score initiative(Score score) const;

    const Position& pos;
    Material::Entry* me;
    Pawns::Entry* pe;
    Bitboard mobilityArea[COLOR_NB];
    Score mobility[COLOR_NB] = { SCORE_ZERO, SCORE_ZERO };

    // attackedBy[color][piece type] is a bitboard representing all squares
    // attacked by a given color and piece type. Special "piece types" which
    // is also calculated is ALL_PIECES.
    Bitboard attackedBy[COLOR_NB][PIECE_TYPE_NB];

    // attackedBy2[color] are the squares attacked by at least 2 units of a given
    // color, including x-rays. But diagonal x-rays through pawns are not computed.
    Bitboard attackedBy2[COLOR_NB];

    // kingRing[color] are the squares adjacent to the king plus some other
    // very near squares, depending on king position.
    Bitboard kingRing[COLOR_NB];

    // kingAttackersCount[color] is the number of pieces of the given color
    // which attack a square in the kingRing of the enemy king.
    int kingAttackersCount[COLOR_NB];

    // kingAttackersWeight[color] is the sum of the "weights" of the pieces of
    // the given color which attack a square in the kingRing of the enemy king.
    // The weights of the individual piece types are given by the elements in
    // the KingAttackWeights array.
    int kingAttackersWeight[COLOR_NB];

    // kingAttacksCount[color] is the number of attacks by the given color to
    // squares directly adjacent to the enemy king. Pieces which attack more
    // than one square are counted multiple times. For instance, if there is
    // a white knight on g5 and black's king is on g8, this white knight adds 2
    // to kingAttacksCount[WHITE].
    int kingAttacksCount[COLOR_NB];
  };

  // Evaluation::initialize() computes king and pawn attacks, and the king ring
  // bitboard for a given color. This is done at the beginning of the evaluation.
  template<Tracing T> template<Color Us>
  void Evaluation<T>::initialize() {

    constexpr Color     Them = (Us == WHITE ? BLACK : WHITE);
    constexpr Direction Up   = (Us == WHITE ? NORTH : SOUTH);
    constexpr Direction Down = (Us == WHITE ? SOUTH : NORTH);
    Bitboard LowRanks = rank_bb(relative_rank(Us, RANK_2, pos.max_rank())) | rank_bb(relative_rank(Us, RANK_3, pos.max_rank()));

    const Square ksq = pos.count<KING>(Us) ? pos.square<KING>(Us) : SQ_NONE;

    Bitboard dblAttackByPawn = pawn_double_attacks_bb<Us>(pos.pieces(Us, PAWN));

    // Find our pawns that are blocked or on the first two ranks
    Bitboard b = pos.pieces(Us, PAWN) & (shift<Down>(pos.pieces()) | LowRanks);

    // Squares occupied by those pawns, by our king or queen or controlled by
    // enemy pawns are excluded from the mobility area.
    if (pos.must_capture())
        mobilityArea[Us] = AllSquares;
    else
        mobilityArea[Us] = ~(b | pos.pieces(Us, KING, QUEEN) | pe->pawn_attacks(Them) | shift<Down>(pos.pieces(Them, SHOGI_PAWN)));

    // Initialize attackedBy[] for king and pawns
    attackedBy[Us][KING] = pos.count<KING>(Us) ? pos.attacks_from<KING>(Us, ksq) : Bitboard(0);
    attackedBy[Us][PAWN] = pe->pawn_attacks(Us);
    attackedBy[Us][SHOGI_PAWN] = shift<Up>(pos.pieces(Us, SHOGI_PAWN));
    attackedBy[Us][ALL_PIECES] = attackedBy[Us][KING] | attackedBy[Us][PAWN] | attackedBy[Us][SHOGI_PAWN];
    attackedBy2[Us]            =  (attackedBy[Us][KING] & attackedBy[Us][PAWN])
                                | (attackedBy[Us][KING] & attackedBy[Us][SHOGI_PAWN])
                                | (attackedBy[Us][PAWN] & attackedBy[Us][SHOGI_PAWN])
                                | dblAttackByPawn;

    // Init our king safety tables
    kingRing[Us] = attackedBy[Us][KING];
    if (pos.count<KING>(Us) && relative_rank(Us, ksq) == RANK_1)
        kingRing[Us] |= shift<Up>(kingRing[Us]);

    if (pos.count<KING>(Us) && file_of(ksq) == pos.max_file())
        kingRing[Us] |= shift<WEST>(kingRing[Us]);

    else if (pos.count<KING>(Us) && file_of(ksq) == FILE_A)
        kingRing[Us] |= shift<EAST>(kingRing[Us]);

    kingAttackersCount[Them] = popcount(kingRing[Us] & pe->pawn_attacks(Them));
    kingAttacksCount[Them] = kingAttackersWeight[Them] = 0;

    // Remove from kingRing[] the squares defended by two pawns
    kingRing[Us] &= ~dblAttackByPawn;

    kingRing[Us] &= pos.board_bb();
  }

  // Evaluation::pieces() scores pieces of a given color and type
  template<Tracing T> template<Color Us>
  Score Evaluation<T>::pieces(PieceType Pt) {

    constexpr Color     Them = (Us == WHITE ? BLACK : WHITE);
    constexpr Direction Down = (Us == WHITE ? SOUTH : NORTH);
    constexpr Bitboard OutpostRanks = (Us == WHITE ? Rank4BB | Rank5BB | Rank6BB
                                                   : Rank5BB | Rank4BB | Rank3BB);
    const Square* pl = pos.squares(Us, Pt);

    Bitboard b, bb;
    Score score = SCORE_ZERO;

    attackedBy[Us][Pt] = 0;

    for (Square s = *pl; s != SQ_NONE; s = *++pl)
    {
        // Find attacked squares, including x-ray attacks for bishops and rooks
        b = Pt == BISHOP ? attacks_bb<BISHOP>(s, pos.pieces() ^ pos.pieces(QUEEN))
          : Pt ==   ROOK ? attacks_bb<  ROOK>(s, pos.pieces() ^ pos.pieces(QUEEN) ^ pos.pieces(Us, ROOK))
                         : pos.attacks_from(Us, Pt, s);

        // Restrict mobility to actual squares of board
        b &= pos.board_bb();

        if (pos.blockers_for_king(Us) & s)
            b &= LineBB[pos.square<KING>(Us)][s];

        attackedBy2[Us] |= attackedBy[Us][ALL_PIECES] & b;
        attackedBy[Us][Pt] |= b;
        attackedBy[Us][ALL_PIECES] |= b;

        if (b & kingRing[Them])
        {
            kingAttackersCount[Us]++;
            kingAttackersWeight[Us] += KingAttackWeights[std::min(int(Pt), QUEEN + 1)];
            kingAttacksCount[Us] += popcount(b & attackedBy[Them][KING]);
        }

        if (Pt > QUEEN)
             b = (b & pos.pieces()) | (pos.moves_from(Us, Pt, s) & ~pos.pieces() & pos.board_bb());

        int mob = popcount(b & mobilityArea[Us]);

        if (Pt <= QUEEN)
            mobility[Us] += MobilityBonus[Pt - 2][mob];
        else
            mobility[Us] += MaxMobility * (mob - 1) / (8 + mob);

        // Piece promotion bonus
        if (pos.promoted_piece_type(Pt) != NO_PIECE_TYPE)
        {
            if (promotion_zone_bb(Us, pos.promotion_rank(), pos.max_rank()) & (b | s))
                score += make_score(PieceValue[MG][pos.promoted_piece_type(Pt)] - PieceValue[MG][Pt],
                                    PieceValue[EG][pos.promoted_piece_type(Pt)] - PieceValue[EG][Pt]) / 10;
        }
        else if (pos.captures_to_hand() && pos.unpromoted_piece_on(s))
            score += make_score(PieceValue[MG][Pt] - PieceValue[MG][pos.unpromoted_piece_on(s)],
                                PieceValue[EG][Pt] - PieceValue[EG][pos.unpromoted_piece_on(s)]) / 8;

        // Penalty if the piece is far from the kings in drop variants
        if (pos.captures_to_hand() && pos.count<KING>(Them) && pos.count<KING>(Us))
            score -= KingProximity * distance(s, pos.square<KING>(Us)) * distance(s, pos.square<KING>(Them));

        if (Pt == BISHOP || Pt == KNIGHT)
        {
            // Bonus if piece is on an outpost square or can reach one
            bb = OutpostRanks & attackedBy[Us][PAWN] & ~pe->pawn_attacks_span(Them);
            if (bb & s)
                score += Outpost * (Pt == KNIGHT ? 4 : 2);

            else if (bb & b & ~pos.pieces(Us))
                score += Outpost * (Pt == KNIGHT ? 2 : 1);

            // Knight and Bishop bonus for being right behind a pawn
            if (shift<Down>(pos.pieces(PAWN)) & s)
                score += MinorBehindPawn;

            // Penalty if the piece is far from the king
            if (pos.count<KING>(Us))
            score -= KingProtector * distance(s, pos.square<KING>(Us));

            if (Pt == BISHOP)
            {
                // Penalty according to number of pawns on the same color square as the
                // bishop, bigger when the center files are blocked with pawns.
                Bitboard blocked = pos.pieces(Us, PAWN) & shift<Down>(pos.pieces());

                score -= BishopPawns * pos.pawns_on_same_color_squares(Us, s)
                                     * (1 + popcount(blocked & CenterFiles));

                // Bonus for bishop on a long diagonal which can "see" both center squares
                if (more_than_one(attacks_bb<BISHOP>(s, pos.pieces(PAWN)) & Center))
                    score += LongDiagonalBishop;
            }

            // An important Chess960 pattern: A cornered bishop blocked by a friendly
            // pawn diagonally in front of it is a very serious problem, especially
            // when that pawn is also blocked.
            if (   Pt == BISHOP
                && pos.is_chess960()
                && (s == relative_square(Us, SQ_A1) || s == relative_square(Us, SQ_H1)))
            {
                Direction d = pawn_push(Us) + (file_of(s) == FILE_A ? EAST : WEST);
                if (pos.piece_on(s + d) == make_piece(Us, PAWN))
                    score -= !pos.empty(s + d + pawn_push(Us))                ? CorneredBishop * 4
                            : pos.piece_on(s + d + d) == make_piece(Us, PAWN) ? CorneredBishop * 2
                                                                              : CorneredBishop;
            }
        }

        if (Pt == ROOK)
        {
            // Bonus for aligning rook with enemy pawns on the same rank/file
            if (relative_rank(Us, s, pos.max_rank()) >= RANK_5)
                score += RookOnPawn * popcount(pos.pieces(Them, PAWN) & PseudoAttacks[Us][ROOK][s]);

            // Bonus for rook on the same file as a queen
            if (file_bb(s) & pos.pieces(QUEEN))
                score += RookOnQueenFile;

            // Bonus for rook on an open or semi-open file
            if (pos.is_on_semiopen_file(Us, s))
                score += RookOnFile[bool(pos.is_on_semiopen_file(Them, s))];

            // Penalty when trapped by the king, even more if the king cannot castle
            else if (mob <= 3 && pos.count<KING>(Us))
            {
                File kf = file_of(pos.square<KING>(Us));
                if ((kf < FILE_E) == (file_of(s) < kf))
                    score -= TrappedRook * (1 + !pos.castling_rights(Us));
            }
        }

        if (Pt == QUEEN)
        {
            // Penalty if any relative pin or discovered attack against the queen
            Bitboard queenPinners;
            if (pos.slider_blockers(pos.pieces(Them, ROOK, BISHOP), s, queenPinners, Them))
                score -= WeakQueen;
        }
    }
    if (T)
        Trace::add(Pt, Us, score);

    return score;
  }

  // Evaluation::hand() scores pieces of a given color and type in hand
  template<Tracing T> template<Color Us>
  Score Evaluation<T>::hand(PieceType pt) {

    constexpr Color Them = (Us == WHITE ? BLACK : WHITE);

    Score score = SCORE_ZERO;

    if (pos.count_in_hand(Us, pt))
    {
        Bitboard b = pos.drop_region(Us, pt) & ~pos.pieces() & (~attackedBy2[Them] | attackedBy[Us][ALL_PIECES]);
        if ((b & kingRing[Them]) && pt != SHOGI_PAWN)
        {
            kingAttackersCount[Us] += pos.count_in_hand(Us, pt);
            kingAttackersWeight[Us] += KingAttackWeights[std::min(int(pt), QUEEN + 1)] * pos.count_in_hand(Us, pt);
            kingAttacksCount[Us] += popcount(b & attackedBy[Them][KING]);
        }
        Bitboard theirHalf = pos.board_bb() & ~forward_ranks_bb(Them, relative_rank(Them, Rank((pos.max_rank() - 1) / 2), pos.max_rank()));
        mobility[Us] += DropMobility * popcount(b & theirHalf & ~attackedBy[Them][ALL_PIECES]);
    }

    return score;
  }

  // Evaluation::king() assigns bonuses and penalties to a king of a given color
  template<Tracing T> template<Color Us>
  Score Evaluation<T>::king() const {

    constexpr Color    Them = (Us == WHITE ? BLACK : WHITE);
    Rank r = relative_rank(Us, std::min(Rank((pos.max_rank() - 1) / 2 + 1), pos.max_rank()), pos.max_rank());


It will be an uphill battle


Successfully deployed to following URLs:

* https://gatsby-themes-92jv3zjrd.now.sh
* https://gatsby-themes.undataforum.now.sh
* https://gatsby-themes-git-master.undataforum.now.sh


Successfully deployed to following URLs:

* https://crypto-copyright-kxbj0q1l6.now.sh
* https://crypto-copyright.now.sh
* https://crypto-copyright.benjamin852.now.sh
* https://crypto-copyright-git-master.benjamin852.now.sh


ten test przejdzie, ale nie dlatego, ze metoda getTotalBalance zsumuje te wartosci, tylko w tej metodzie wywolanie:
 cashMachines[i].getBalance();
zawsze bedzie zwracac 0, bo zaden obiekt nie ma jakiejkolwiek transakcji


/me secretly wished it was a TeX style Serif font :)


Successfully deployed to following URLs:

* https://devoctopus-2egdokl55.now.sh
* https://devoctopus.helloalex.now.sh
* https://devoctopus-git-master.helloalex.now.sh


test sfailuje


Successfully deployed to following URLs:

* https://tableautim-6adiijv8r.now.sh
* https://tableautim.now.sh
* https://tableautim.com
* https://tableautim.ngwena.now.sh
* https://tableautim-git-master.ngwena.now.sh


Successfully deployed to following URLs:

* https://oh-my-beer-pyqffb3qe.now.sh
* https://oh-my-beer.rogermenezes.now.sh
* https://oh-my-beer-git-master.rogermenezes.now.sh


This commit has been mentioned on **Discourse Meta**. There might be relevant details there:

https://meta.discourse.org/t/over-encoding-of-titles-on-about-page/135193/3


powód, patrz 1 linijka kodu w metodzie getAverageOfPayment


powód, patrz 1 linijka kodu w metodzie getAverageOfWithdrawal


@DanVanAtta You missed removing the put operation a couple of lines above, the computeIfAbsent automatically puts the value.


owód, patrz 1 linijka kodu w metodzie countNumberOfPayments


Successfully deployed to following URLs:

* https://opal-g1slgguig.now.sh
* https://opal-git-dev.cesiuminho.now.sh


I was wrong. There definitely will be at least one more `reddit` PR for 7.0.


test 2


Hi,

When I compiled 0719fe7a2b2ac147b31dbfcd8399fba4ed4a8004 under "Linux linux 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:11 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux", I get this at the end of the compile:
/usr/bin/ld: softfloat_roundingMode: TLS definition in ./.libs/libherc.so section .tbss mismatches non-TLS reference in .libs/herculesS.o
./.libs/libherc.so: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:2156: recipe for target 'hercules' failed
make[2]: *** [hercules] Error 1
make[2]: Leaving directory '/mnt/u/Hercules/R4.2/hyperion-0719fe7a2b2ac147b31dbfcd8399fba4ed4a8004'
Makefile:2450: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/mnt/u/Hercules/R4.2/hyperion-0719fe7a2b2ac147b31dbfcd8399fba4ed4a8004'
Makefile:1798: recipe for target 'all' failed
make: *** [all] Error 2

There were various warnings along the way.


Copy of this build can be found at
https://www.mewbuilds.com/build/880fb4e2179362e375e175f3bbda341fd62b5006/index.html
                       https://www.cloudflare-ipfs.com/ipfs/Qmf6GDpYN2ovod1RE4xFXMES4YZdB7rrwqPXHmdLb1dFWJ
                       Virus Total analysis
                       https://www.virustotal.com/file/7d53446c80dacf31d38bb8a8e924a8a23745f1ee12c649c6436e536367f524ba/analysis/1575585754/


Successfully deployed to following URLs:

* https://nine-to-five-14qdobg5a.now.sh
* https://ninetofive.tech
* https://nine-to-five.conscience.now.sh
* https://nine-to-five-git-master.conscience.now.sh


Currently, you can cause a crash by specifying channel: 512 and double_channel: true.  My suggestion is:
cv.Any(
  {cv.Required(CONF_CHANNEL): cv.int_range(min=1, max=512)},
  {cv.Required(CONF_DOUBLE_CHANNEL): cv.int_range(min=1, max=511)}
)
and then corresponding code changes elsewhere.


Successfully deployed to following URLs:

* https://wj-h6nhwxvee.now.sh
* https://wj-sepia-three.now.sh
* https://jw.wj9.ca
* https://wj.wj9.now.sh
* https://wj-git-master.wj9.now.sh


Successfully deployed to following URLs:

* https://learningthreejs-nj2bbpgj2.now.sh
* https://learningthreejs.algninja.now.sh
* https://learningthreejs-git-master.algninja.now.sh


Fix PanelStack

Previews: documentation | landing | table


This would become:
if CONF_CHANNEL in config:
  cg.add(var.set_channel(config[CONF_CHANNEL]))
else:
  cg.add(var.set_double_channel(config[CONF_DOUBLE_CHANNEL]))


Successfully deployed to following URLs:

* https://ishakuni-frontend-ekmfkx5l1.now.sh
* https://ishakuni.com
* https://www.ishakuni.com
* https://ishakuni-frontend.caulagi.now.sh
* https://ishakuni-frontend-git-master.caulagi.now.sh


🔥 Device tests completed (Failed) on iOS32b on [Azure DevOps](https://dev.azure.com/devdiv/DevDiv/_build/index?buildId=3297453)(iOS32b): [Html Report](http://xamarin-storage/jenkins/xamarin-macios/master/b3bc04c919a00b82c67fc7157a03b353f8b75f38/3297453/device-tests/jenkins-results/tests/index.html) 🔥

# Test results

<details>
<summary>24 tests failed, 100 tests passed.</summary>

## Failed tests

 * dont link/iOS Unified 32-bits - device/Debug: BuildFailure
 * [xUnit] Mono BCL tests group 4/iOS Unified 32-bits - device/Debug: BuildFailure
 * mscorlib/iOS Unified 32-bits - device/Debug: BuildFailure
 * dont link/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug): BuildFailure
 * dont link/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (debug): BuildFailure
 * dont link/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug, profiling): BuildFailure
 * dont link/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): BuildFailure
 * dont link/iOS Unified 32-bits - device/Release: UseThumb: Crashed
 * dont link/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
 * [NUnit] Mono BCL tests group 2/iOS Unified 32-bits - device/Release: TimedOut
 * [NUnit] Mono BCL tests group 2/iOS Unified 32-bits - device/Release: UseThumb: TimedOut
 * [NUnit] Mono BCL tests group 2/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (release): TimedOut
 * [xUnit] Mono BCL tests group 4/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug): BuildFailure
 * [xUnit] Mono BCL tests group 4/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (debug): BuildFailure
 * [xUnit] Mono BCL tests group 4/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug, profiling): BuildFailure
 * [xUnit] Mono BCL tests group 4/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): BuildFailure
 * mscorlib/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug): BuildFailure
 * mscorlib/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (debug): BuildFailure
 * mscorlib/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug, profiling): BuildFailure
 * mscorlib/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): BuildFailure
 * mscorlib/iOS Unified 32-bits - device/Release: TimedOut
 * mscorlib/iOS Unified 32-bits - device/Release: UseThumb: Failed
 * mscorlib/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (release): TimedOut
 * mscorlib/iOS Unified 32-bits - device/Debug: SGenConc: BuildFailure
</details>


Added logic to detect a failure under two known conditions and retry with different body to handle Android.
Fixes #9 in regards to error 400 for Full Device Wipe.

This has been tested extensively with Legacy Android, it might produce other errors with Android Enterprise. If that is the case, please open an issue.


Successfully deployed to following URLs:

* https://dreams-8l1rehok6.now.sh
* https://dreams-kappa-sandy.now.sh
* https://dreams.wtf
* https://*.dreams.wtf
* https://dreams.participio.now.sh
* https://dreams-git-master.participio.now.sh


Thanks for pulling this (and the other recent ones) in!


versione pdf definitiva


I will comment on some code issues, but you need to send out DMX packets regularly, not just when there are updates. Otherwise, most lights will assume that the controller is gone and take some action like turning off or going full on. Usually you transmit frames as often as possible within the timing limits. If you're transmitting full frames you won't go too fast. I think the spec said maximum 1s between starts or something like that.
(Reposting after I deleted this comment because the page was showing it 3 times...)


Successfully deployed to following URLs:

* https://keindevcom-r8406uhpg.now.sh
* https://keindev.com
* https://keindevcom.keindev.now.sh
* https://keindevcom-git-master.keindev.now.sh


Stream Processing


With the config changes this would become:
```
  void set_channel(uint16_t channel) { this->channel_ = channel; }
  void set_double_channel(uint16 double_channel) { this->channel_ = double_channel; this->double_channel_ = true;}
```


The following doc(s) have been deployed to the [lighthouse](https://lighthouse-static-docs.pantheonsite.io/docs) Multidev environment:
- [.circleci/config.yml](https://github.com/pantheon-systems/documentation/commit/97ba83622f31ab1221a70464db54d68c7f43ea93/.circleci/config.yml)
- [.circleci/tests/lighthouse/run](https://github.com/pantheon-systems/documentation/commit/97ba83622f31ab1221a70464db54d68c7f43ea93/.circleci/tests/lighthouse/run)


Successfully deployed to following URLs:

* https://svelte-gravatar-2lghcg646.now.sh
* https://svelte-gravatar.now.sh
* https://svelte-gravatar.jocolopes.now.sh
* https://svelte-gravatar-git-master.jocolopes.now.sh


This isn't used anywhere.


Oops, yes!


✅ Device tests passed on iOS32b on [Azure DevOps](https://dev.azure.com/devdiv/DevDiv/_build/index?buildId=3298490)(iOS32b): [Html Report](http://xamarin-storage/jenkins/xamarin-macios/device-tests-yaml/d99fb16d80d3e1d93e857cc904a8f4244b661186/3298490/device-tests/jenkins-results/tests/index.html) ✅

# No tests selected.


Хороші слова


See #917. The compiler uses some optimizations that can cause Invidious to segfault. Currently I'm not sure of the exact cause.


там же 2 элемента с таким классом, второй не рекламный


Created multidev environment [dgreat#pr-457](https://dashboard.pantheon.io/sites/41cad7fe-472d-43a9-a470-d391b9622376#pr-457).

[![Visit Site](https://raw.githubusercontent.com/pantheon-systems/ci-drops-8/0.1.0/data/img/visit-site-36.png)](https://pr-457-dgreat.pantheonsite.io/)


Successfully deployed to following URLs:

* https://cv-lxxf1p0e4.now.sh
* https://cv.michael-lloyd-lee.me.uk
* https://cv.mlk1.now.sh
* https://cv-git-master.mlk1.now.sh


Successfully deployed to following URLs:

* https://uiuchack4impactorg-6lqplvslj.now.sh
* https://uiuchack4impactorg.hack4impact1.now.sh
* https://uiuchack4impactorg-git-master.hack4impact1.now.sh


azad calisiyo furkan yatiyo abe


Successfully deployed to following URLs:

* https://convertmymoney-7jeu8akqb.now.sh
* https://convertmymoney-five-dusky.now.sh
* https://convertmymoney.duduzoeras.now.sh
* https://convertmymoney-git-master.duduzoeras.now.sh


I am clearly a master of English spelling.


Successfully deployed to following URLs:

* https://dev-frontend-c0uydx80y.now.sh
* https://dev-frontend.now.sh
* https://dev-frontend.photo-hub.now.sh
* https://dev-frontend-git-master.photo-hub.now.sh


develop (mitchute) - x86_64-Linux-Ubuntu-18.04-gcc-7.4-UnitTestsCoverage-Debug: OK (1249 of 1249 tests passed, 0 test warnings)

![Build Badge](http://img.shields.io/badge/build%20status-passing-green.png) ![Test Badge](http://img.shields.io/badge/tests%20passed-100.0%25-green.png) ![Coverage Badge](http://img.shields.io/badge/coverage%20status-43.43%25-green.png)


line 36 to line 100 was done by Asia


Successfully deployed to following URLs:

* https://dreams-aqvozyxdo.now.sh
* https://dreams-kappa-sandy.now.sh
* https://dreams.wtf
* https://*.dreams.wtf
* https://dreams.participio.now.sh
* https://dreams-git-master.participio.now.sh


TeamCity Bvcms / Build [Build 2979](https://builds.tpsdb.com/viewLog.html?buildId=10231&buildTypeId=Bvcms_Build) outcome was **FAILURE**
Summary: Tests failed: 49 (49 new), passed: 122 Build time: 00:42:26
### Failed tests
```
Database collection (1): CmsDataTests.PythonModelTests.AddContributionDetailTest(date: "2019-10-19", cDate: "10/17/2019 23:11:00", fundid: 1, amount: "60.00", checkno: "", routing: "1234567890", account: "951753", cType: 1): System.Exception : Error in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\CmsData\Migrations\20191205_Checkin-performance-improvements.sql:
Must declare the scalar variable "@orgid".
Incorrect syntax near 'END'.
   at SharedTestFixtures.DatabaseFixture.EnsureDatabaseExists() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\UnitTests\SharedTestFixtures\DatabaseFixture.cs:line 46
   at SharedTestFixtures.DatabaseFixture..ctor() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\UnitTests\SharedTestFixtures\DatabaseFixture.cs:line 15

Webapp collection (1): IntegrationTests.Areas.People.Views.Person.PersonViewsTests.Should_Hide_Giving_Tab: OpenQA.Selenium.WebDriverTimeoutException : Timed out after 30 seconds
   at OpenQA.Selenium.Support.UI.DefaultWait`1.ThrowTimeoutException(String exceptionMessage, Exception lastException)
   at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
   at IntegrationTests.Support.FeatureTestBase.WaitForElement(String css, Int32 maxWaitTimeInSeconds, Boolean visible) in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Support\FeatureTestBase.cs:line 553
   at IntegrationTests.Support.AccountTestBase.Login(String withPassword) in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Support\AccountTestBase.cs:line 29
   at IntegrationTests.Areas.People.Views.Person.PersonViewsTests.Should_Hide_Giving_Tab() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Areas\People\Views\Person\PersonViewsTests.cs:line 24

Database collection (1): CmsDataTests.CMSDataContextTests.Should_Insert_EV_Only_If_does_not_Exist(key: "PushPayKey", value: "keyXYZ", text: null, intvalue: null, bitvalue: null): System.Exception : Error in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\CmsData\Migrations\20191205_Checkin-performance-improvements.sql:
Must declare the scalar variable "@orgid".
Incorrect syntax near 'END'.
   at SharedTestFixtures.DatabaseFixture.EnsureDatabaseExists() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\UnitTests\SharedTestFixtures\DatabaseFixture.cs:line 46
   at SharedTestFixtures.DatabaseFixture..ctor() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\UnitTests\SharedTestFixtures\DatabaseFixture.cs:line 15

Database collection (1): CmsDataTests.PythonModelTests.RenderTemplateTest: System.Exception : Error in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\CmsData\Migrations\20191205_Checkin-performance-improvements.sql:
Must declare the scalar variable "@orgid".
Incorrect syntax near 'END'.
   at SharedTestFixtures.DatabaseFixture.EnsureDatabaseExists() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\UnitTests\SharedTestFixtures\DatabaseFixture.cs:line 46
   at SharedTestFixtures.DatabaseFixture..ctor() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\UnitTests\SharedTestFixtures\DatabaseFixture.cs:line 15

Webapp collection (1): IntegrationTests.Areas.Manage.AccountTests.MyData_User_ForgotPassword_Test: OpenQA.Selenium.WebDriverTimeoutException : Timed out after 30 seconds
   at OpenQA.Selenium.Support.UI.DefaultWait`1.ThrowTimeoutException(String exceptionMessage, Exception lastException)
   at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
   at IntegrationTests.Support.FeatureTestBase.WaitForElement(String css, Int32 maxWaitTimeInSeconds, Boolean visible) in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Support\FeatureTestBase.cs:line 553
   at IntegrationTests.Areas.Manage.AccountTests.MyData_User_ForgotPassword_Test() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Areas\Manage\AccountTests.cs:line 117

Database collection (1): CmsDataTests.CMSDataContextFunctionTests.GetTotalContributionsDonorTest: System.Exception : Error in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\CmsData\Migrations\20191205_Checkin-performance-improvements.sql:
Must declare the scalar variable "@orgid".
Incorrect syntax near 'END'.
   at SharedTestFixtures.DatabaseFixture.EnsureDatabaseExists() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\UnitTests\SharedTestFixtures\DatabaseFixture.cs:line 46
   at SharedTestFixtures.DatabaseFixture..ctor() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\UnitTests\SharedTestFixtures\DatabaseFixture.cs:line 15

Webapp collection (1): IntegrationTests.Areas.Manage.QueryControllerTests.TestSearchBuilderOrgsDropdownOption: OpenQA.Selenium.WebDriverTimeoutException : Timed out after 30 seconds
   at OpenQA.Selenium.Support.UI.DefaultWait`1.ThrowTimeoutException(String exceptionMessage, Exception lastException)
   at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
   at IntegrationTests.Support.FeatureTestBase.WaitForElement(String css, Int32 maxWaitTimeInSeconds, Boolean visible) in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Support\FeatureTestBase.cs:line 553
   at IntegrationTests.Support.AccountTestBase.Login(String withPassword) in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Support\AccountTestBase.cs:line 29
   at IntegrationTests.Support.AccountTestBase.LoginAsAdmin() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Support\AccountTestBase.cs:line 40
   at IntegrationTests.Areas.Manage.QueryControllerTests.TestSearchBuilderOrgsDropdownOption() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Areas\General\QueryControllerTests.cs:line 19

Webapp collection (1): IntegrationTests.Areas.Manage.SetupTests.Create_Role_Test: OpenQA.Selenium.WebDriverTimeoutException : Timed out after 30 seconds
   at OpenQA.Selenium.Support.UI.DefaultWait`1.ThrowTimeoutException(String exceptionMessage, Exception lastException)
   at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
   at IntegrationTests.Support.FeatureTestBase.WaitForElement(String css, Int32 maxWaitTimeInSeconds, Boolean visible) in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Support\FeatureTestBase.cs:line 553
   at IntegrationTests.Support.AccountTestBase.Login(String withPassword) in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Support\AccountTestBase.cs:line 29
   at IntegrationTests.Areas.Manage.SetupTests.Create_Role_Test() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Areas\Setup\SetupTests.cs:line 21

Webapp collection (1): IntegrationTests.Areas.OnlineReg.Models.OnlineRegPerson.EnrollTests.Should_Store_and_Populate_RegEmail: OpenQA.Selenium.WebDriverTimeoutException : Timed out after 30 seconds
   at OpenQA.Selenium.Support.UI.DefaultWait`1.ThrowTimeoutException(String exceptionMessage, Exception lastException)
   at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
   at IntegrationTests.Support.FeatureTestBase.WaitForElement(String css, Int32 maxWaitTimeInSeconds, Boolean visible) in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Support\FeatureTestBase.cs:line 553
   at IntegrationTests.Support.AccountTestBase.Login(String withPassword) in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Support\AccountTestBase.cs:line 29
   at IntegrationTests.Areas.OnlineReg.Models.OnlineRegPerson.EnrollTests.Should_Store_and_Populate_RegEmail() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\IntegrationTests\Areas\OnlineReg\Models\OnlineRegPerson\EnrollTests.cs:line 46

Database collection (1): CmsDataTests.PythonModelTests.AddContributionDetailTest(date: "2019-10-19", cDate: "10/17/2019 23:11:00", fundid: 1, amount: "20.00", checkno: "1596", routing: "1234567890", account: "123789", cType: 9): System.Exception : Error in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\CmsData\Migrations\20191205_Checkin-performance-improvements.sql:
Must declare the scalar variable "@orgid".
Incorrect syntax near 'END'.
   at SharedTestFixtures.DatabaseFixture.EnsureDatabaseExists() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\UnitTests\SharedTestFixtures\DatabaseFixture.cs:line 46
   at SharedTestFixtures.DatabaseFixture..ctor() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\UnitTests\SharedTestFixtures\DatabaseFixture.cs:line 15

Database collection (1): CmsDataTests.PythonModelTests.AddContributionTest(date: "2019-07-25", cDate: "7/22/2019 13:30:00", fundid: 1, amount: "50", checkno: "1080", description: "Slush Fund", peopleid: 1): System.Exception : Error in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\CmsData\Migrations\20191205_Checkin-performance-improvements.sql:
Must declare the scalar variable "@orgid".
Incorrect syntax near 'END'.
   at SharedTestFixtures.DatabaseFixture.EnsureDatabaseExists() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\UnitTests\SharedTestFixtures\DatabaseFixture.cs:line 46
   at SharedTestFixtures.DatabaseFixture..ctor() in C:\TeamCity\buildAgent\work\de2c4e6ef697cb99\UnitTests\SharedTestFixtures\DatabaseFixture.cs:line 15

##### there are 39 more failed tests, see build details
```


TeamCity Bvcms / Build [Build 2980](https://builds.tpsdb.com/viewLog.html?buildId=10232&buildTypeId=Bvcms_Build) is now running


add movie


Successfully deployed to following URLs:

* https://codigos-d9xnjwl5a.now.sh
* https://codigos.now.sh
* https://codigos.hilario2986.now.sh
* https://codigos-git-master.hilario2986.now.sh


Successfully deployed to following URLs:

* https://challangebossabox-k1gbqnqr0.now.sh
* https://challangebossabox.now.sh
* https://challangebossabox.maanolfi.now.sh
* https://challangebossabox-git-master.maanolfi.now.sh


Successfully deployed to following URLs:

* https://hackathon-static-o8ckhe0hc.now.sh
* https://hackathon-static.now.sh
* https://sparkhackathon.com
* https://hackathon-static.spark-hackathon.now.sh
* https://hackathon-static-git-master.spark-hackathon.now.sh


change get_tickets


aa


Add function to js.


Successfully deployed to following URLs:

* https://challangebossabox-azfogeeoy.now.sh
* https://challangebossabox.now.sh
* https://challangebossabox.maanolfi.now.sh
* https://challangebossabox-git-master.maanolfi.now.sh


`requires` and `ensures` will always be boolean, and `modifies` (if we end up having it) seems like it will be more restricted (e.g., its type might be `StorageLocation`). But I think `SpecExp` would make sense given that `Constant`, `StorageLocation`, and `BinOp` need not be booleans...


Successfully deployed to following URLs:

* https://markedjs-m1ripcw92.now.sh
* https://markedjs.now.sh
* https://markedjs.markedjs.now.sh
* https://markedjs-git-master.markedjs.now.sh


Successfully deployed to following URLs:

* https://markedjs-zeq46lc5h.now.sh
* https://markedjs.now.sh
* https://markedjs.markedjs.now.sh
* https://markedjs-git-master.markedjs.now.sh


Successfully deployed to following URLs:

* https://markedjs-flvv22e6k.now.sh
* https://markedjs.now.sh
* https://markedjs.markedjs.now.sh
* https://markedjs-git-master.markedjs.now.sh


Successfully deployed to following URLs:

* https://learningthreejs-lgkd42rpt.now.sh
* https://learningthreejs.algninja.now.sh
* https://learningthreejs-git-master.algninja.now.sh


Successfully deployed to following URLs:

* https://portfolio-fbgyadmm6.now.sh
* https://yuwen-li.com
* https://www.yuwen-li.com
* https://portfolio.muzlee1113.now.sh
* https://portfolio-git-master.muzlee1113.now.sh


Successfully deployed to following URLs:

* https://learningthreejs-kti749vts.now.sh
* https://learningthreejs.algninja.now.sh
* https://learningthreejs-git-master.algninja.now.sh


Successfully deployed to following URLs:

* https://thaitonesonemoregroup-1r2o-r7zn4nftn.now.sh
* https://thaitones.onemore.group
* https://thaitonesonemoregroup-1r2o.onemoregroup.now.sh
* https://thaitonesonemoregroup-1r2o-git-master.onemoregroup.now.sh


Hello だけでいいよ


Это информация о самом радаре, предоставляемая сторонней системой, я пока не уверен, что она вообще пригодится, но на всякий случай оставил.


@havatv i don't see what improvements this change brings. and i honestly less appreciate how it was done underground.


![](https://github.trello.services/images/mini-trello-icon.png) [JavaDoc for FileReader class](https://trello.com/c/SOaDg2sg/19-javadoc-for-filereader-class)


Hi @jpritikin , I'm trying to compile openmx and getting the error "'typeof' was not declared in this scope". (later in this scope curProd) is not defined either. This is where it looks like it was introduced -- AFAICT it looks like a definition for typeof really is missing (and curProd is declared in a different chunk). I'll see if I can keep digging to see what's going on, but let me know if you have insight in the meantime. Thanks!


`: document.querySelector('body').classList.remove('dark-mode')`
{/** try it without the d  on classList.remove(d)*/}


Successfully deployed to following URLs:

* https://learningthreejs-oh9lh7nq7.now.sh
* https://learningthreejs.algninja.now.sh
* https://learningthreejs-git-master.algninja.now.sh


Successfully deployed to following URLs:

* https://dreams-22qn196zn.now.sh
* https://dreams-kappa-sandy.now.sh
* https://dreams.wtf
* https://*.dreams.wtf
* https://dreams.participio.now.sh
* https://dreams-git-master.participio.now.sh


Successfully deployed to following URLs:

* https://markedjs-pdrtjku0w.now.sh
* https://markedjs.now.sh
* https://markedjs.markedjs.now.sh
* https://markedjs-git-master.markedjs.now.sh


Este


Successfully deployed to following URLs:

* https://headers-echo-83k47n7sn.now.sh
* https://headers-echo.now.sh
* https://headers-echo.dobby233liu.now.sh
* https://headers-echo-git-master.dobby233liu.now.sh


Add .md extension at the end of the filename.


The definition command is cancelled. I got it working but selfhosters would have to create an Oxford Dictionary API account and that'd be too convoluted.


Successfully deployed to following URLs:

* https://headers-echo-940j48zrq.now.sh
* https://headers-echo.now.sh
* https://headers-echo.dobby233liu.now.sh
* https://headers-echo-git-master.dobby233liu.now.sh


Another problem now , putting headgear + vest on indep side


The danger of the one line diffs :grin:

Updating in: https://github.com/triplea-game/triplea/pull/5666


Please make sure that your versions have container position to be "fixed" or else it will change size for all the pages.


Created multidev environment [sfgov#pr-423](https://dashboard.pantheon.io/sites/91d50373-c4cf-40e4-a646-cb73e16a140c#pr-423).

[![Visit Site](https://raw.githubusercontent.com/pantheon-systems/ci-drops-8/0.1.0/data/img/visit-site-36.png)](https://pr-423-sfgov.pantheonsite.io/)


Successfully deployed to following URLs:

* https://everest-io64aeccb.now.sh
* https://everest-app.now.sh
* https://everest.diazabdulm.now.sh
* https://everest-git-master.diazabdulm.now.sh


`const [someValue, setSomeValue] = useLocalStorage(`darkMode, initialValue);`

{/**the try-catch error is warning you to make sure you set the first argument's type here to be a string...that's what the setLocalStorage window method requires  to create a new key value pair on the windows localStorage. similar to a jsonWebToken*/}


Nice! That is cleaner than the way I had done it.


Ah, I figured out why my original declarative pipeline failed.  Turns out that when you have a `rtServer` like this below, without a `credentialsID` set (e.g., to the empty string), then it will fail later when looking up the server.
```groovy
                rtServer (
                    id: "ARTIFACTORY_SERVER",
                    url: "http://artifactory:8081/artifactory",
                    //credentialsId: CREDENTIALS
                )
```
It failed with with a NPE on `DeclarativePipelineUtils.java:83`, which does a lookup of the server information from the datafile in the temp directory, and calls `asText()` on the returned `JsonNode`:

```java
83:        String credentialsId = jsonNode.get("credentialsId").asText();
```

However if the field is not present, then the `get()` method will return `null`, and thus the `asText()` call oviously fail with the NPE.  I have created jfrog/jenkins-artifactory-plugin#225 to track that.

However after setting the credentialsID to either the empty string (to test anonymous) or setting it to a valid ID, deploying to a repo where only that user has deploy access still doesn't break anything.  It all still goes through successfully with any 3.4.x build I have tested.

I even tried the simple example @offa showed above, only with the addition of cloning the git repo to obtain an upload spec to use.  This also works my HAP-1219 branch, and all 3.4.x build I have testet.

```
pipeline {
    agent any
    stages {
        stage ('example') {
            steps {
                git branch: 'master', url: "https://github.com/jfrog/project-examples.git"

                rtUpload (
                    serverId: 'arti-anon', // Obtain an Artifactory server instance, defined in Jenkins --> Manage:
                    specPath: 'jenkins-examples/pipeline-examples/resources/exclude-upload.json'
                )
            }
        }
    }
}
```

I'm out of things to try differently, until someone elaborates a bit more precisely about their setup that actually fails.  Preferably including a public git repo with all the code that I can clone and test, like I have been using the example repo for easier reproducibility.
* Is any credentials being used (credentialsID or user/pass), or just anonymous?
* Is the Server definition done globally or within the pipeline.
* What type of Item is being used: Pipeline, Multibranch pipeloine, ???
* Are any folders being used in any of this?
  * All my test have been done in toplevel of Jenkins.
* What version of Jenkins and Artifactory is being used?
  * I have tested with the current LTS version of Jenkins (2.190.3) and the current Artifactory-oss docker image (6.16.0 rev 61600900)

And a more elaborate stacktrace would also be helpful.  Just 5-10 methods or so should be fine.


Successfully deployed to following URLs:

* https://challengemyself-belns2rem.now.sh
* https://challengemyself.now.sh
* https://challengemyself.jcofman1.now.sh
* https://challengemyself-git-master.jcofman1.now.sh


clear


в задаче же ответил


Successfully deployed to following URLs:

* https://ishakuni-frontend-bm7mu0yso.now.sh
* https://ishakuni.com
* https://www.ishakuni.com
* https://ishakuni-frontend.caulagi.now.sh
* https://ishakuni-frontend-git-master.caulagi.now.sh


aa


Successfully deployed to following URLs:

* https://ymca-rcb8gsfeo.now.sh
* https://ymca.now.sh
* https://ymca.hack4impact1.now.sh
* https://ymca-git-master.hack4impact1.now.sh


Created multidev environment [dgreat#pr-457](https://dashboard.pantheon.io/sites/41cad7fe-472d-43a9-a470-d391b9622376#pr-457).

[![Visit Site](https://raw.githubusercontent.com/pantheon-systems/ci-drops-8/0.1.0/data/img/visit-site-36.png)](https://pr-457-dgreat.pantheonsite.io/)


Successfully deployed to following URLs:

* https://onemoregroup-778kve065.now.sh
* https://onemore.group
* https://onemoregroup.onemoregroup.now.sh
* https://onemoregroup-git-master.onemoregroup.now.sh


pyproject.toml


`const [darkMode, setDarkMode] = useLocalStorage(darkMode, initialValue);`

{/**someValue setSomeValue works fine here... but it can be understood easier if you assign your variables to match the customhooks goal. call it darkMode and setDarkMode.... given it is hard to decipher what the original auther was trying to guide us to do for this assignment even with all the provided readme. */}


Successfully deployed to following URLs:

* https://meusite-ksyu2pbc0.now.sh
* https://meusite.now.sh
* https://meusite.loroboy546.now.sh
* https://meusite-git-master.loroboy546.now.sh


Successfully deployed to following URLs:

* https://fitfam-esqwzkzzi.now.sh
* https://fitfam.me
* https://fitfam.andykay.now.sh
* https://fitfam-git-master.andykay.now.sh


Fix PanelStack (#3879)

Previews: documentation | landing | table


The following doc(s) have been deployed to the [lighthouse](https://lighthouse-static-docs.pantheonsite.io/docs) Multidev environment:
- [.circleci/tests/lighthouse/run](https://github.com/pantheon-systems/documentation/commit/95a19fbfa443ac6d62ca1708247273723142e5c4/.circleci/tests/lighthouse/run)


Copy of this build can be found at
https://www.mewbuilds.com/build/9c826ba6846d8be30d9fc3a056f788e919f4243a/index.html
                       https://www.cloudflare-ipfs.com/ipfs/QmZpW8BPG8di9EMbqgk15dxEDvmxUNMtEp7R95b6si5XdV
                       Virus Total analysis
                       https://www.virustotal.com/file/3ba233a08de98143d4132936d0bb0662c882bf40e3f77c388ffe08d9b8e824b2/analysis/1575587911/


Successfully deployed to following URLs:

* https://meusite-r5ymzme2n.now.sh
* https://meusite.now.sh
* https://meusite.loroboy546.now.sh
* https://meusite-git-master.loroboy546.now.sh


Successfully deployed to following URLs:

* https://interface-dwsdxqnwq.now.sh
* https://interface.avantgarde-finance.now.sh
* https://interface-git-master.avantgarde-finance.now.sh


Artifacts: https://circleci.com/gh/pantheon-systems/documentation/16938/artifacts/0/


Successfully deployed to following URLs:

* https://wtfshouldicook-cs35jgd97.now.sh
* https://wtfshouldicook-brave-pen.now.sh
* https://wtfshouldicook.com
* https://www.wtfshouldicook.com
* https://wtfshouldicook.reif.now.sh
* https://wtfshouldicook-git-master.reif.now.sh


Merhaba hocam, sass ekledim ama içeriğini değiştirmedim hiç. Öylede çalışıyor. Değiştirmem gerekli mi?


You shouldn't have removed this.
Some pages have a native back to top button from steam.
This selects that, if it exists, then don't add our own.
Better put this back.


Created multidev environment [sfgov#pr-423](https://dashboard.pantheon.io/sites/91d50373-c4cf-40e4-a646-cb73e16a140c#pr-423).

[![Visit Site](https://raw.githubusercontent.com/pantheon-systems/ci-drops-8/0.1.0/data/img/visit-site-36.png)](https://pr-423-sfgov.pantheonsite.io/)


woow!!!the web please my friend???


Successfully deployed to following URLs:

* https://schichtkalender-rt-d45epo6fk.now.sh
* https://schichtkalender-rt.now.sh
* https://schichtkalender-rt.christopherastfalk.now.sh
* https://schichtkalender-rt-git-master.christopherastfalk.now.sh


bin it


Since I was not able to understand the original explanation, a fix was needed.
I thought we had agreed that the explanation could be made more clear, and since the change was trivial, I just did a direct commit.  It was not my intention to hide it from you (I was about to write something about it in our "discussion" in the other PR, but it has been delayed because I tried to fix the Export to PostgreSQL "overwrite" error).


Successfully deployed to following URLs:

* https://learningthreejs-bl3phl1p5.now.sh
* https://learningthreejs.algninja.now.sh
* https://learningthreejs-git-master.algninja.now.sh


Successfully deployed to following URLs:

* https://meusite-qi48kbcuy.now.sh
* https://meusite.now.sh
* https://meusite.loroboy546.now.sh
* https://meusite-git-master.loroboy546.now.sh


Successfully deployed to following URLs:

* https://learningthreejs-6bdkcvtz0.now.sh
* https://learningthreejs.algninja.now.sh
* https://learningthreejs-git-master.algninja.now.sh


I get `Cannot resolve method 'setUseNativeAccessor(boolean)'` error in same place


Successfully deployed to following URLs:

* https://meusite-dg6r5zl7i.now.sh
* https://meusite.now.sh
* https://meusite.loroboy546.now.sh
* https://meusite-git-master.loroboy546.now.sh


va


1.뷰에 그래픽 그리기
1단계 - 새로운 클래스를 만들고 뷰를 상속받는다
2단계 - 페인트 객체를 초기화하고 필요한 속성을 설정한다.
3단계 - onDraw() 메서드 내에 사각형을 그리는 메서드를 호출한다.
4단계 - onTouchEvent() 메서드 내에 터치 이벤트를 처리하는 코드를 넣는다
5단계 - 새로 만든 뷰를 메인 액티비티에 추가한다.