main.cpp 978 B

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