Created
May 3, 2018 18:23
-
-
Save 27Cobalter/b956127f2f723cb31b7bc05520e5e507 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void evalute_formation() { | |
std::cout << "\033[13;0H\e[J" << std::endl; | |
const auto visible_robots = | |
static_cast<bool>(team_color_) ? world_.robots_yellow() : world_.robots_blue(); | |
if (mode == test::formation) { | |
if (!formation_) reset_formation(); | |
auto agents = formation_->execute(); | |
for (auto agent : agents) { | |
std::string agent_name = typeid(*agent).name(); | |
auto actions = agent->execute(); | |
for (auto action : actions) { | |
std::string action_name = typeid(*action).name(); | |
auto command = action->execute(); | |
if (visible_robots.count(command.id())) driver_.update_command(command); | |
std::cout << "\033["<<(13 + command.id()*2)<< ";0H " << command.id() << " " << agent_name | |
<< std::endl; | |
std::cout << "\033["<<(14 + command.id()*2)<< ";0H " << " ╰"<<command.id() << " " << action_name | |
<< std::endl; | |
} | |
} | |
} else if (mode == test::agent) { | |
if (!agent_) reset_formation(); | |
auto actions = agent_->execute(); | |
for (auto action : actions) { | |
auto command = action->execute(); | |
if (visible_robots.count(command.id())) driver_.update_command(command); | |
} | |
} else if (mode == test::action) { | |
if (!action_) reset_formation(); | |
auto command = action_->execute(); | |
if (visible_robots.count(command.id())) driver_.update_command(command); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment