Advertisement
yumetodo

for_YSRKEN2

Mar 14th, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. vector<Direction> direction(cleaner_status.size(), Direction::Up);//各ユニットの移動状態を記述する
  2. auto first_not_max_it = direction.end();
  3. while (true){
  4.     //補数制限・バック禁止以外のケースで皆が移動できない場合は弾く//インクリするもの
  5.     bool can_move_flg = true;
  6.     // (...)
  7.     for (auto &d : direction) {
  8.         cout << d << ".";//itという名前はiteratorを想起し良くないので改名
  9.     }
  10.     /*
  11.  
  12.     */
  13.     //インクリメント処理
  14.     if (direction[0] != Direction::Max) {
  15.         direction[0] = static_cast<Direction>(direction[0] + 1);
  16.     }
  17.     else if(direction.end() != (first_not_max_it = std::find_if_not(direction.begin() + 1, direction.end(), [](Direction d) { return d == Direction::Max; })){
  18.         break;
  19.     }
  20. }
  21. if(direction.end() != first_not_max_it){
  22.     std::fill(direction.begin(), first_not_max_it, Direction::Up);
  23.     *first_not_max_it = static_cast<Direction>(static_cast<int>(*first_not_max_it) + 1);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement