diff --git a/source/.gitignore b/source/.gitignore index 1e336945..9418ca34 100644 --- a/source/.gitignore +++ b/source/.gitignore @@ -1,3 +1,8 @@ *.swp *.swo game + + + +.idea +simple \ No newline at end of file diff --git a/source/Group7_GP_Agent/agent.hpp b/source/Group7_GP_Agent/agent.hpp new file mode 100644 index 00000000..28a5979a --- /dev/null +++ b/source/Group7_GP_Agent/agent.hpp @@ -0,0 +1,71 @@ +/** + * @file agent.hpp + * @author Aman Dhruva Thamminana (thammina@msu.edu) + * @brief this will be our agent class can be created + * @version 0.0.1 [internal] + * @date 2023-09-25 + * + * @copyright Copyright (c) 2023 + * + */ + + +#pragma once + +#include +#include +#include +#include + +#include + +#include "../core/AgentBase.hpp" + +/** + * @brief yeeeeeeeehaaaaaaaaa + */ +namespace cowboys +{ + + + class GPAgent : public cse491::AgentBase + { + protected: + const std::vector predefinedMovement = {"down", "down","down","down", "right", "right", "up", "up", "up","up", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "right", "left", "left", "left"}; + + size_t movementIndex = 0; // current move of the agent + + public: + GPAgent(size_t id, const std::string &name) : AgentBase(id, name) { + std::random_device rd; + std::mt19937 gen(rd()); + + + std::uniform_int_distribution dist(0, 3); // size of the random set to 3 as we only have 4 actions initally + } + ~GPAgent() override = default; + + /// @brief This agent needs a specific set of actions to function. + /// @return Success. + bool Initialize() override + { + return true; + } + + + /// Choose the action to take a step in the appropriate direction. + size_t SelectAction(const cse491::WorldGrid &grid, + const cse491::type_options_t &type_options, + const cse491::item_set_t &item_set, + const cse491::agent_set_t &agent_set) override + { + if (movementIndex >= predefinedMovement.size()){ + return action_map["right"]; // do nothing if it is out of bound for defined movement + } + + auto action = action_map[predefinedMovement[movementIndex++]]; + return action; + } + }; + +} \ No newline at end of file diff --git a/source/simple_main.cpp b/source/simple_main.cpp index 12d563dc..c63e5227 100644 --- a/source/simple_main.cpp +++ b/source/simple_main.cpp @@ -9,12 +9,18 @@ #include "Interfaces/TrashInterface.hpp" #include "Worlds/MazeWorld.hpp" -int main() -{ - cse491::MazeWorld world; - world.AddAgent("Pacer 1").SetPosition(3,1); - world.AddAgent("Pacer 2").SetPosition(6,1); - world.AddAgent("Interface").SetProperty("char", '@'); +#include "Group7_GP_Agent/agent.hpp" - world.Run(); +int main() { + cse491::MazeWorld world; + world.AddAgent("Pacer 1").SetPosition(3, 1); + + //GP agent + world.AddAgent("GP 1").SetPosition(1, 0).SetProperty("char", 'G'); + + // Human agent + world.AddAgent("Interface").SetProperty("char", '@'); + + + world.Run(); }