La simu multi-agents qui repeint une image, mais en c++ Boilerplate pompé ici : https://github.com/andrew-r-king/sfml-vscode-boilerplate
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

PictureEnvironment.hpp 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef PICTURE_ENVIRONMENT_H
  2. #define PICTURE_ENVIRONMENT_H
  3. #include "Platform/Platform.hpp"
  4. #include <Agents/Perception/Perception.hpp>
  5. #include <Control/EnvInputs.hpp>
  6. class Agent;
  7. class PictureEnvironment
  8. { // The class
  9. public: // Access specifier
  10. std::string fFilePath;
  11. sf::RenderWindow* fWindow;
  12. util::Platform* fPlatform;
  13. const sf::Vector2f fSize;
  14. sf::Vector2f fInitialSize;
  15. sf::Event fEvent;
  16. sf::RectangleShape fShape;
  17. EnvInputs fInputs;
  18. sf::Texture fTextureImage;
  19. sf::Image fImage;
  20. sf::Image fOriginalImage;
  21. std::vector<std::unique_ptr<Agent>> fAgents;
  22. std::list<Agent>::iterator fAgentsIterator;
  23. PictureEnvironment(std::string& iFilePath, sf::RenderWindow* iWindow, util::Platform* iPlatform, bool iDisplayOriginal);
  24. void getPerception(Perception* ioPercept, int iX, int iY);
  25. void makeAgents(int iNumber, int iDotSize, int iMoveSize);
  26. void makeRepaintAgents(int iNumber, int iDotSize, int iMoveSize, int iTolerance);
  27. void makePullPaintAgents(int iNumber, int iDotSize, int iMoveSize);
  28. void makeStraightRepaintAgents(int iNumber, int iDotSize, int iMoveSize, int iTolerance);
  29. bool paint(int iX, int iY, const sf::Color Color);
  30. sf::Uint32 getCell(int iX, int iY);
  31. sf::Uint32 getCellOriginal(int iX, int iY);
  32. int getWidth();
  33. int getHeight();
  34. bool loop();
  35. void displayLockInput();
  36. private:
  37. bool fDisplayOriginal;
  38. PictureEnvironment();
  39. };
  40. #endif // PICTURE_ENVIRONMENT_H