我目前正在用C++编程一个国际象棋程序。用于搜索的算法是alphaBeta,这就是为什么我在通过它们并评估它们之前对它们进行排序。我的主要课程是类位置,它可以完成所有搜索,并且还包含一个用于比较两个Move的函数。通过绑定返回的函子的C++类型
class Position{
private:
//This vector holds the moves of the current line, to be evaluated
vector<Move> currentSearch(4000);
// This function uses internal fields of class Position to determine, whether move1 or move2 should be searched first
bool compare(const Move& move1, const Move& move2);
int alphaBeta(int ply, int depth, int alpha, int beta);
}
我们在currentSearch的招式进行排序,我总是在的Alpha-Beta
sort(currentSearch.begin(), currentSearch.end(), bind(mem_fn(&Position::compare),this,_1,_2));
所以这产生函子与bind(mem_fn(&Position::compare),this,_1,_2));
做几次拨打一个搜索内生成相同的仿函数。
我希望有一个类位置的成员初始化为bind(mem_fn(&Position::compare),this,_1,_2));
但是该成员必须拥有什么类型,或者设计此类型的正确方法是什么?