Changeset 12164
- Timestamp:
- Dec 6, 2018, 8:45:47 PM (6 years ago)
- Location:
- code/branches/wagnis_HS18/src/modules/wagnis
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
r12162 r12164 7 7 #include <cstdlib> 8 8 #include <ctime> 9 9 10 10 11 namespace orxonox … … 247 248 if (move_type == MOVE) 248 249 { 250 AlreadyChecked.clear(); 249 251 if (existPath(this->origin_province, this->target_province))//path exists, all belong to same player 250 252 { … … 294 296 bool WagnisPlayer::existPath(WagnisProvince* origin, WagnisProvince* target) 295 297 { 298 AlreadyChecked.push_back(origin->getID()); 299 296 300 if (origin->getOwner_ID() == target->getOwner_ID() && isNeighbour(origin, target)) 297 301 return true; 298 302 299 303 for (unsigned int i = 0; i < origin->neighbors.size(); ++i) 300 { 301 if ( origin->getOwner_ID() == origin->neighbors[i]->getOwner_ID())304 { 305 if ((origin->getOwner_ID() == origin->neighbors[i]->getOwner_ID()) && (!(contains(AlreadyChecked, origin->neighbors[i]->getID())))) 302 306 return existPath(origin->neighbors[i], target); 303 307 } 304 308 305 309 return false; 306 310 } … … 347 351 } 348 352 353 bool WagnisPlayer::contains(std::vector<int> a, int key) 354 { 355 if(std::count(a.begin(), a.end(), key)) 356 return true; 357 else 358 return false; 359 } 360 349 361 void WagnisPlayer::setActive(bool b){ 350 362 this->is_active = b; -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
r12160 r12164 17 17 #include <string> 18 18 #include "infos/HumanPlayer.h" 19 #include <algorithm> 20 #include <iostream> 21 19 22 20 23 … … 50 53 WagnisProvince* target_province; 51 54 int reinforcements; 55 std::vector<int> AlreadyChecked; 52 56 bool isNeighbour(WagnisProvince*, WagnisProvince*); 53 57 bool existPath(WagnisProvince*, WagnisProvince*); 58 bool contains(std::vector<int>, int); 54 59 int dice(); 55 60 int best3(int, int, int); -
code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h
r12159 r12164 15 15 #include <OgreColourValue.h> 16 16 #include "tools/ToolsPrereqs.h" 17 18 17 19 18 namespace orxonox
Note: See TracChangeset
for help on using the changeset viewer.