main.cpp 857 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <cstring>
  2. #include "../../AI_Base.h"
  3. const char *g_cszAiName = "Mad AI";
  4. class CMadAI : public CBattleGameInterface
  5. {
  6. CBattleCallback *cb;
  7. virtual void init(CBattleCallback * CB)
  8. {
  9. cb = CB;
  10. }
  11. virtual BattleAction activeStack(const CStack * stack)
  12. {
  13. srand(time(NULL));
  14. BattleAction ba;
  15. ba.actionType = rand() % 14;
  16. ba.additionalInfo = rand() % BFIELD_SIZE + 5;
  17. ba.side = rand() % 7;
  18. ba.destinationTile = rand() % BFIELD_SIZE + 5;
  19. ba.stackNumber = rand() % 500;
  20. return ba;
  21. }
  22. };
  23. extern "C" DLL_F_EXPORT void GetAiName(char* name)
  24. {
  25. strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName);
  26. }
  27. extern "C" DLL_F_EXPORT CBattleGameInterface* GetNewBattleAI()
  28. {
  29. return new CMadAI();
  30. }
  31. extern "C" DLL_F_EXPORT void ReleaseBattleAI(CBattleGameInterface* i)
  32. {
  33. delete (CMadAI*)i;
  34. }