Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First deliverable GP agent V 0.0.1 #15

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions source/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
*.swp
*.swo
game



.idea
simple
71 changes: 71 additions & 0 deletions source/Group7_GP_Agent/agent.hpp
Original file line number Diff line number Diff line change
@@ -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 <cassert>
#include <map>
#include <string>
#include <iostream>

#include <random>

#include "../core/AgentBase.hpp"

/**
* @brief yeeeeeeeehaaaaaaaaa
*/
namespace cowboys
{


class GPAgent : public cse491::AgentBase
{
protected:
const std::vector<std::string> 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<int> 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;
}
};

}
20 changes: 13 additions & 7 deletions source/simple_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@
#include "Interfaces/TrashInterface.hpp"
#include "Worlds/MazeWorld.hpp"

int main()
{
cse491::MazeWorld world;
world.AddAgent<cse491::PacingAgent>("Pacer 1").SetPosition(3,1);
world.AddAgent<cse491::PacingAgent>("Pacer 2").SetPosition(6,1);
world.AddAgent<cse491::TrashInterface>("Interface").SetProperty("char", '@');
#include "Group7_GP_Agent/agent.hpp"

world.Run();
int main() {
cse491::MazeWorld world;
world.AddAgent<cse491::PacingAgent>("Pacer 1").SetPosition(3, 1);

//GP agent
world.AddAgent<cowboys::GPAgent>("GP 1").SetPosition(1, 0).SetProperty("char", 'G');

// Human agent
world.AddAgent<cse491::TrashInterface>("Interface").SetProperty("char", '@');


world.Run();
}