📄 arspolicedirect.cpp
字号:
#include "StdAfx.h"
#include "ARSPoliceDirect.h"
ARSAction* ARSPlDirect::CreateAction()
{
ARSPlDirect * tmp = new ARSPlDirect;
return tmp;
}
bool ARSPlDirect::ExecuteAction(const ARSSTUATION & stSituation, MOVEDIRECTION & nextDirection)
{
int iPoliceID = stSituation.iID-1;
ARSPOINT ptPoliceSelf = stSituation.ptPloice[iPoliceID];
ARSPOINT ptThief = stSituation.ptThief;
int dx = abs(ptThief.x - ptPoliceSelf.x);
int dy = abs(ptThief.y - ptPoliceSelf.y);
if (ptThief.x - ptPoliceSelf.x >=0)
{
if (ptThief.y - ptPoliceSelf.y == 0||dx>dy)
{
nextDirection = RIGHT;
return true;
}
if (ptThief.y - ptPoliceSelf.y > 0)
nextDirection = UP;
else
nextDirection = DOWN;
}
else
{
if (ptThief.y - ptPoliceSelf.y == 0||dx>dy)
{
nextDirection = LEFT;
return true;
}
if (ptThief.y - ptPoliceSelf.y > 0)
nextDirection = UP;
else
nextDirection = DOWN;
}
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -