www.pudn.com > 1223456.rar > HistoryHeuristic.cpp
// HistoryHeuristic.cpp: implementation of the CHistoryHeuristic class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "HistoryHeuristic.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CHistoryHeuristic::CHistoryHeuristic()
{
}
CHistoryHeuristic::~CHistoryHeuristic()
{
}
void CHistoryHeuristic::ResetHistoryTable()
{
memset(m_HistoryTable,10,8100*4);
}
int CHistoryHeuristic::GetHistoryScore(CHESSMOVE *move)
{
int nFrom,nTo;
nFrom=move->From.y*9+move->From.x;//原始位置
nTo=move->To.y*9+move->To.x; //目标位置
return m_HistoryTable[nFrom][nTo];//返回历史得分
}
void CHistoryHeuristic::EnterHistoryScore(CHESSMOVE *move, int depth)
{
int nFrom,nTo;
nFrom=move->From.y*9+move->From.x;//原始位置
nTo=move->To.y*9+move->To.x; //目标位置
m_HistoryTable[nFrom][nTo]+=2<m)
for(int q=j; q<=r;q++)
target[k++]=source[q];
else
for(int q=i; q<=m;q++)
target[k++]=source[q];
}
void CHistoryHeuristic::MergePass(CHESSMOVE *source, CHESSMOVE *target, const int s, const int n, const BOOL direction)
{
int i=0;
while(i<=n-2*s)
{
//合并大小为s的相邻二段子数组
if(direction)
Merge(source,target,i,i+s-1,i+2*s-1);
else
Merge_A(source,target,i,i+s-1,i+2*s-1);
i=i+2*s;
}
if(i+s=source[j].Score)
target[k++]=source[i++];
else
target[k++]=source[j++];
if(i>m)
for(int q=j;q<=r;q++)
target[k++]=source[q];
else
for(int q=i;q<=m;q++)
target[k++]=source[q];
}