sortCaptureMoves.cc
Go to the documentation of this file.
00001 /* sortCaptureMoves.cc
00002  */
00003 #include "osl/search/sortCaptureMoves.h"
00004 #include "osl/move_order/captureEstimation.h"
00005 #include "osl/move_order/cheapPtype.h"
00006 #include "osl/container/moveVector.h"
00007 #include <algorithm>
00008 
00009 void osl::search::SortCaptureMoves::sortByMovingPiece(MoveVector& moves)
00010 {
00011   std::sort(moves.begin(), moves.end(), move_order::CheapPtype());
00012 }
00013 
00014 namespace osl
00015 {
00016   namespace search
00017   {
00018     struct OrderSpecifiedPiece
00019     {
00020       Square from;
00021       explicit OrderSpecifiedPiece(Square f) : from(f)
00022       {
00023       }
00024       bool operator()(Move l, Move r) const
00025       {
00026         const Square from_l = l.from();
00027         if (from_l == from)
00028           return true;
00029         const Square from_r = r.from();
00030         if (from_r == from)
00031           return false;
00032 
00033         return move_order::CheapPtype()(l, r);
00034       }
00035     };
00036   } // anonymous namespace
00037 } // namespace osl
00038 
00039 void osl::search::SortCaptureMoves::
00040 sortBySpecifiedPiece(MoveVector& moves, Square from)
00041 {
00042   std::sort(moves.begin(), moves.end(), OrderSpecifiedPiece(from));
00043 }
00044 
00045 void osl::search::SortCaptureMoves::
00046 sortByTakeBack(const NumEffectState& state, MoveVector& moves)
00047 {
00048   std::sort(moves.begin(), moves.end(), 
00049             move_order::CaptureEstimation(state));
00050 }
00051 
00052 /* ------------------------------------------------------------------------- */
00053 // ;;; Local Variables:
00054 // ;;; mode:c++
00055 // ;;; c-basic-offset:2
00056 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines