Skip to content

Commit

Permalink
our main has copied group6 main's functions and runs their version of…
Browse files Browse the repository at this point in the history
… RunWorld().
  • Loading branch information
captainsleepyhead committed Dec 9, 2023
1 parent f9adebe commit e84fa38
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions source/group_3_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,99 @@
#include "Worlds/BiomeGenerator.hpp"
#include "Worlds/GenerativeWorld.hpp"

void timer(group6::GenerativeWorld& world, int duration) {
std::this_thread::sleep_for(std::chrono::seconds(duration));
world.EndGame(false);
}

void runWorld(group6::BiomeType biome, int width, int height, const unsigned int SEED, int timerDuration = -1) {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<int> distribution(0, 1000000);
int random_number = distribution(gen);
group6::GenerativeWorld world(biome, width, height, random_number);
world.AddTeleporters();

if (biome == group6::BiomeType::Grasslands) {
// Using TrashInterface since MainInterface does not support Grasslands biome
world.AddAgent<i_2D::MainInterface>("Interface2").SetProperty("symbol", '@').SetName("Player");
}

else if (biome == group6::BiomeType::Maze) {
bool counter = false;
while (!counter) {
int random_x = world.GetRandom(18, 53);
int random_y = world.GetRandom(6, 18);

if (world.GetGrid().At(random_x, random_y) == 1) {
world.AddItem("Boots", "symbol", 'B').SetPosition(random_x, random_y).SetName("Boots").SetProperty("Health", 3.0);
counter = true;
}
}
counter = false;
while (!counter) {
int random_x = world.GetRandom(18, 53);
int random_y = world.GetRandom(6, 18);

if (world.GetGrid().At(random_x, random_y) == 1) {
world.AddItem("Shield", "symbol", 'S').SetPosition(random_x, random_y).SetName("Shield").SetProperty("Health", 3.0);
counter = true;
}
}

world.AddItem("Shield", "symbol", 'S').SetPosition(1, 1).SetName("Shield").SetProperty("Health", 3.0);
world.AddItem("Boots", "symbol", 'B').SetPosition(2, 2).SetName("Boots").SetProperty("Health", 3.0);
world.AddAgent<cse491::PacingAgent>("Pacer 1").SetPosition(5, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 2").SetPosition(8, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 3").SetPosition(10, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 4").SetPosition(12, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 5").SetPosition(15, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 6").SetPosition(18, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 7").SetPosition(20, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 8").SetPosition(22, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 9").SetPosition(25, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 10").SetPosition(28, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 11").SetPosition(30, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 12").SetPosition(32, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 13").SetPosition(35, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 14").SetPosition(38, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 15").SetPosition(40, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 16").SetPosition(42, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 17").SetPosition(45, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 18").SetPosition(48, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 19").SetPosition(50, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 20").SetPosition(52, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 21").SetPosition(55, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 22").SetPosition(58, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 23").SetPosition(60, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 24").SetPosition(62, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 25").SetPosition(65, int(world.GetRandom(0, height-1)));
world.AddAgent<cse491::PacingAgent>("Pacer 26").SetPosition(70, int(world.GetRandom(0, height-1)));
// auto & astar_agent = static_cast<walle::AStarAgent&>(world.AddAgent<walle::AStarAgent>("AStar1"));
// astar_agent.SetPosition(4, 4);
// astar_agent.SetGoalPosition(1, 1);
// astar_agent.RecalculatePath();

world.AddAgent<i_2D::MainInterface>("Interface2").SetProperty("symbol", '@').SetName("Player");

world.AddArmory();
}

else if (biome == group6::BiomeType::Ocean) {
world.AddAgent<cse491::TrashInterface>("Interface").SetProperty("symbol", '@');
}

// Start an optional timer
if (timerDuration != -1) {
std::thread timerThread(timer, std::ref(world), timerDuration);
world.Run();
timerThread.join();
}

else {
world.Run();
}
}
int main() {

// cse491::MazeWorld world;
Expand Down Expand Up @@ -61,6 +154,15 @@ int main() {
//
// world_2.Run();


auto biome = group6::BiomeType::Maze; // change world biome type here
int width = 70; // change world width here
int height = 24; // change world height here
static const unsigned int SEED = 19; // change world seed here
int timerDuration = -1; // an optional timer length, set to -1 for no timer

runWorld(biome, width, height, SEED, timerDuration);

cse491_team8::ManualWorld world_3;
world_3.AddItem("Axe", "Uses", 5, "symbol", 'P').SetPosition(37, 3);
world_3.AddItem("Boat", "Uses", 7, "symbol", 'U').SetPosition(18, 4);
Expand Down

0 comments on commit e84fa38

Please sign in to comment.