Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vector<Direction> direction(cleaner_status.size(), Direction::Up);//各ユニットの移動状態を記述する
- auto first_not_max_it = direction.end();
- while (true){
- //補数制限・バック禁止以外のケースで皆が移動できない場合は弾く//インクリするもの
- bool can_move_flg = true;
- // (...)
- for (auto &d : direction) {
- cout << d << ".";//itという名前はiteratorを想起し良くないので改名
- }
- /*
- */
- //インクリメント処理
- if (direction[0] != Direction::Max) {
- direction[0] = static_cast<Direction>(direction[0] + 1);
- }
- else if(direction.end() != (first_not_max_it = std::find_if_not(direction.begin() + 1, direction.end(), [](Direction d) { return d == Direction::Max; })){
- break;
- }
- }
- if(direction.end() != first_not_max_it){
- std::fill(direction.begin(), first_not_max_it, Direction::Up);
- *first_not_max_it = static_cast<Direction>(static_cast<int>(*first_not_max_it) + 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement