00001
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 Position from;
00021 explicit OrderSpecifiedPiece(Position f) : from(f)
00022 {
00023 }
00024 bool operator()(Move l, Move r) const
00025 {
00026 const Position from_l = l.from();
00027 if (from_l == from)
00028 return true;
00029 const Position from_r = r.from();
00030 if (from_r == from)
00031 return false;
00032
00033 return move_order::CheapPtype()(l, r);
00034 }
00035 };
00036 }
00037 }
00038
00039 void osl::search::SortCaptureMoves::
00040 sortBySpecifiedPiece(MoveVector& moves, Position 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
00054
00055
00056