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

キーパーを除去 #686

Merged
merged 3 commits into from
Jan 11, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
getAvailableRobotIdsにキーパー回避設定を追加
HansRobo committed Jan 11, 2025
commit 6e87dfe07edc6b5b7a50280c3b4fe3c5e4b1c115
Original file line number Diff line number Diff line change
@@ -41,17 +41,28 @@ struct TeamInfo

uint8_t goalie_id;

[[nodiscard]] auto getAvailableRobots(uint8_t my_id = 255, bool except_goalie = false) const
-> RobotList
{
return robots | ranges::views::filter([my_id](const auto & robot) {
return robot->available && robot->id != my_id;
return robots | ranges::views::filter([&](const auto & robot) {
if (except_goalie) {
return robot->available && robot->id != my_id && robot->id != goalie_id;
} else {
return robot->available && robot->id != my_id;
}
}) |
ranges::to<std::vector>();
}

[[nodiscard]] auto getAvailableRobotIds(uint8_t my_id = 255) const -> std::vector<uint8_t>
[[nodiscard]] auto getAvailableRobotIds(uint8_t my_id = 255, bool except_goalie = false) const
-> std::vector<uint8_t>
{
return robots | ranges::views::filter([my_id](const auto & robot) {
return robot->available && robot->id != my_id;
return robots | ranges::views::filter([&](const auto & robot) {
if (except_goalie) {
return robot->available && robot->id != my_id && robot->id != goalie_id;
} else {
return robot->available && robot->id != my_id;
}
}) |
ranges::views::transform([](const auto & robot) { return robot->id; }) |
ranges::to<std::vector>();