Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Napoleon - move.cpp

move.cpp

Caricato da: Crybot
Scarica il programma completo

  1. #include "move.h"
  2. #include "utils.h"
  3. #include "piece.h"
  4. #include "constants.h"
  5.  
  6. namespace Napoleon
  7. {
  8.     bool Move::IsNull() const
  9.     {
  10.         return (FromSquare() == ToSquare());
  11.     }
  12.  
  13.     bool Move::IsCastleOO() const
  14.     {
  15.         return ((move >> 12) == KingCastle);
  16.     }
  17.  
  18.     bool Move::IsCastleOOO() const
  19.     {
  20.         return ((move >> 12) == QueenCastle);
  21.     }
  22.  
  23.     std::string Move::ToAlgebraic() const
  24.     {
  25.         std::string algebraic;
  26.  
  27.         if (IsNull())
  28.             return "0000"; // UCI representation for NULL move
  29.  
  30.         if (IsCastle())
  31.         {
  32.             if (IsCastleOO())
  33.             {
  34.                 if (FromSquare() == Constants::Squares::IntE1)
  35.                     algebraic += "e1g1";
  36.                 else
  37.                     algebraic += "e8g8";
  38.             }
  39.  
  40.             else if (IsCastleOOO())
  41.             {
  42.                 if (FromSquare() == Constants::Squares::IntE1)
  43.                     algebraic += "e1c1";
  44.                 else
  45.                     algebraic += "e8c8";
  46.             }
  47.         }
  48.  
  49.         else
  50.         {
  51.             algebraic += Utils::Square::ToAlgebraic(FromSquare());
  52.             algebraic += Utils::Square::ToAlgebraic(ToSquare());
  53.  
  54.             if (IsPromotion())
  55.                 algebraic += Utils::Piece::GetInitial(PiecePromoted());
  56.         }
  57.         return algebraic;
  58.     }
  59.  
  60. }