1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-13 11:40:38 +02:00
Michał W. Urbańczyk 94e7fa5b3c Logging battle activites. Replaying battles with client.
Added an AI for answer validation (it returns junk action packets).
Minor fixes.
2011-10-06 20:55:19 +00:00

44 lines
857 B
C++

#include <cstring>
#include "../../AI_Base.h"
const char *g_cszAiName = "Mad AI";
class CMadAI : public CBattleGameInterface
{
CBattleCallback *cb;
virtual void init(CBattleCallback * CB)
{
cb = CB;
}
virtual BattleAction activeStack(const CStack * stack)
{
srand(time(NULL));
BattleAction ba;
ba.actionType = rand() % 14;
ba.additionalInfo = rand() % BFIELD_SIZE + 5;
ba.side = rand() % 7;
ba.destinationTile = rand() % BFIELD_SIZE + 5;
ba.stackNumber = rand() % 500;
return ba;
}
};
extern "C" DLL_F_EXPORT void GetAiName(char* name)
{
strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName);
}
extern "C" DLL_F_EXPORT CBattleGameInterface* GetNewBattleAI()
{
return new CMadAI();
}
extern "C" DLL_F_EXPORT void ReleaseBattleAI(CBattleGameInterface* i)
{
delete (CMadAI*)i;
}