etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
Selector.h
[詳解]
1 
6 #ifndef __SELECTOR__
7 #define __SELECTOR__
8 
9 #include "Explorer.h"
10 #include <algorithm>
11 #include <cstdlib>
12 #include <deque>
13 #include <vector>
14 
113 class Selector {
114  public:
123  : blockPositionList(MAX_BLOCK_COUNT),
124  movedBlockPositionList(MAX_BLOCK_COUNT, EMPTY_ID),
125  evacuatedBlockPositionList(MAX_BLOCK_COUNT, EMPTY_ID),
126  nodePositionCostList(TOTAL_NODE_COUNT),
127  routeBeforeOne_(TOTAL_NODE_COUNT, EMPTY_ID)
128  {
129  // 各ノードにおける位置コストのリスト
130  std::vector<int> nodePositionCostList_{ { 4, 3, 3, 4, 3, 2, 2, 3, 1, 2, 2, 3, 4, 3, 3, 4 } };
131 
132  for(unsigned int i = 0; i < nodePositionCostList_.size(); i++)
133  nodePositionCostList[i] = nodePositionCostList_[i];
134 
135  explorer.createBlockArea();
136  }
137 
139 
141 
160  std::vector<int> exploreNextOperation(std::int8_t currentPosition, BlockColor color);
161 
162  std::int8_t searchBlockPosition(std::int8_t currentPosition);
163 
164  std::int8_t searchMostPoorCostShelter(std::int8_t currentPosition);
165 
166  bool isAlreadyMovedNode(std::int8_t position);
167 
168  bool isAlreadyAllBlockMoved();
169 
170  void changeBlockPosition(std::int8_t beforePosition, std::int8_t afterPosition);
171 
172  void setBlockPositionList(std::vector<std::int8_t> list);
173 
174  std::vector<std::int8_t> getBlockPositionList();
175 
176  void addMovedBlockPosition(std::int8_t position);
177 
178  void pushEvacuatedBlockPosition(std::int8_t position);
179 
180  std::int8_t popEvacuatedBlockPosition();
181 
182  bool canFindBlockInEvacuatedList(std::int8_t position);
183 
184  void prepareSearching(std::vector<std::int8_t> list);
185 
186  std::vector<int> searchRoute(std::int8_t start, std::int8_t end);
187 
189 
190  bool isEvacuatingWithNext();
191 
192  bool isMovingWithNext();
193 
194  bool isCarryingWithNext();
195 
197 
198  bool isBackstepping();
199 
201 
202  [[deprecated("memory is enlarged if this is used!!!")]] void updateRoute(std::vector<int> route);
203 
204  std::vector<int> extractRoute();
205 
206  private:
210  static const std::int8_t TOTAL_NODE_COUNT = 16;
211 
215  static const std::int8_t MAX_BLOCK_COUNT = 4;
216 
226  const std::int8_t EMPTY_ID = -1;
227 
228  bool evacuatingFlag = false;
229 
230  bool movingFlag = false;
231 
232  bool carryingFlag = false;
233 
234  bool backsteppingFlag = false;
235 
236  bool backsteppingBeforeNextOeperationFlag = false;
237 
238  bool isCarriedToShelter = false;
239 
240  bool isClearGame = false;
241 
242  std::int8_t movedCount = 0;
243 
244  std::int8_t evacuatedSize = 0;
245 
246  std::int8_t lastBlock = EMPTY_ID;
247 
248  std::vector<std::int8_t> blockPositionList;
249 
250  std::vector<std::int8_t> movedBlockPositionList;
251 
252  std::deque<std::int8_t> evacuatedBlockPositionList;
253 
254  std::vector<int> nodePositionCostList;
255 
256  std::vector<int> routeBeforeOne_;
257 
258  Explorer explorer;
259 };
260 
261 #endif // SELECTOR
bool isBackstepping()
Definition: Selector.cpp:294
std::int8_t searchMostPoorCostShelter(std::int8_t currentPosition)
Definition: Selector.cpp:147
void prepareSearching(std::vector< std::int8_t > list)
Definition: Selector.cpp:233
std::vector< int > searchRoute(std::int8_t start, std::int8_t end)
Definition: Selector.cpp:242
void createBlockArea()
Definition: Explorer.cpp:3
void updateRoute(std::vector< int > route)
Definition: Selector.cpp:334
std::vector< std::int8_t > getBlockPositionList()
Definition: Selector.cpp:203
std::int8_t getPositionOfCenterQuadirilateral(BlockColor color)
Definition: Selector.cpp:304
std::int8_t popEvacuatedBlockPosition()
Definition: Selector.cpp:220
bool isCarryingWithNext()
Definition: Selector.cpp:289
bool canFindBlockInEvacuatedList(std::int8_t position)
Definition: Selector.cpp:226
void setBlockPositionList(std::vector< std::int8_t > list)
Definition: Selector.cpp:196
bool isEvacuatingWithNext()
Definition: Selector.cpp:279
bool isAlreadyMovedNode(std::int8_t position)
Definition: Selector.cpp:177
bool isMovingWithNext()
Definition: Selector.cpp:284
std::vector< int > extractRoute()
Definition: Selector.cpp:347
void pushEvacuatedBlockPosition(std::int8_t position)
Definition: Selector.cpp:214
std::vector< int > exploreNextOperation(std::int8_t currentPosition, BlockColor color)
Definition: Selector.cpp:3
Selector()
Definition: Selector.h:122
ルート探索クラス
bool isAlreadyAllBlockMoved()
Definition: Selector.cpp:183
bool isBacksteppingBeforeNextOperation()
Definition: Selector.cpp:299
NextOperationOfSearchingRouteIs
Definition: Selector.h:138
void setNext(NextOperationOfSearchingRouteIs next)
Definition: Selector.cpp:253
void changeBlockPosition(std::int8_t beforePosition, std::int8_t afterPosition)
Definition: Selector.cpp:188
void addMovedBlockPosition(std::int8_t position)
Definition: Selector.cpp:208
ブロック選択クラス
Definition: Selector.h:113
std::int8_t searchBlockPosition(std::int8_t currentPosition)
Definition: Selector.cpp:118