Changeset View
Changeset View
Standalone View
Standalone View
ksirk/GameLogic/aiColsonPlayer.cpp
Show First 20 Lines • Show All 381 Lines • ▼ Show 20 Line(s) | 378 | // qCDebug(KSIRK_LOG) << "owner or continent of country " << country->name().toUtf8().data() << " is null..."; | |||
---|---|---|---|---|---|
382 | it = m_game->playerList()->begin(); | 382 | it = m_game->playerList()->begin(); | ||
383 | it_end = m_game->playerList()->end(); | 383 | it_end = m_game->playerList()->end(); | ||
384 | for (; it != it_end; it++) | 384 | for (; it != it_end; it++) | ||
385 | { | 385 | { | ||
386 | int min = 10000; | 386 | int min = 10000; | ||
387 | int max = 0; | 387 | int max = 0; | ||
388 | int bonus = 0; | 388 | int bonus = 0; | ||
389 | for (continentsIt = m_world->getContinents().begin(); | 389 | for (continentsIt = m_world->getContinents().begin(); | ||
390 | continentsIt!=continentsIt_end; continentsIt++) | 390 | continentsIt!=continentsIt_end; ++continentsIt) | ||
391 | { | 391 | { | ||
392 | const Continent* continent = *continentsIt; | 392 | const Continent* continent = *continentsIt; | ||
393 | if (piCount[*it][continent] > 0) | 393 | if (piCount[*it][continent] > 0) | ||
394 | { | 394 | { | ||
395 | if (min == 0) | 395 | if (min == 0) | ||
396 | { | 396 | { | ||
397 | if ( (piCount[*it][continent] == continent->getMembers().size()) | 397 | if ( (piCount[*it][continent] == continent->getMembers().size()) | ||
398 | && (continent->getBonus()>bonus)) | 398 | && (continent->getBonus()>bonus)) | ||
▲ Show 20 Lines • Show All 557 Lines • ▼ Show 20 Line(s) | 955 | { | |||
956 | qCDebug(KSIRK_LOG) << "1"; | 956 | qCDebug(KSIRK_LOG) << "1"; | ||
957 | 957 | | |||
958 | int nb; | 958 | int nb; | ||
959 | const Continent* continent = GetContinentToFortify(&nb); | 959 | const Continent* continent = GetContinentToFortify(&nb); | ||
960 | 960 | | |||
961 | qCDebug(KSIRK_LOG) << "2"; | 961 | qCDebug(KSIRK_LOG) << "2"; | ||
962 | if (nb > 0) | 962 | if (nb > 0) | ||
963 | { | 963 | { | ||
964 | nb = rand() % nb; | 964 | nb = qrand() % nb; | ||
aacid: i would prefer if you didn't change this. Changing the random generation may break stuff and… | |||||
965 | for ( int iCountry = 0; | 965 | for ( int iCountry = 0; | ||
966 | iCountry < m_world->getCountries().size(); | 966 | iCountry < m_world->getCountries().size(); | ||
967 | iCountry++) | 967 | iCountry++) | ||
968 | { | 968 | { | ||
969 | if ((RISK_GetOwnerOfCountry(iCountry) == this) && | 969 | if ((RISK_GetOwnerOfCountry(iCountry) == this) && | ||
970 | (RISK_GetContinentOfCountry(iCountry) == continent) && | 970 | (RISK_GetContinentOfCountry(iCountry) == continent) && | ||
971 | GAME_IsEnemyAdjacent(iCountry)) | 971 | GAME_IsEnemyAdjacent(iCountry)) | ||
972 | { | 972 | { | ||
▲ Show 20 Lines • Show All 217 Lines • ▼ Show 20 Line(s) | 1172 | { | |||
1190 | } | 1190 | } | ||
1191 | } | 1191 | } | ||
1192 | } | 1192 | } | ||
1193 | 1193 | | |||
1194 | qCDebug(KSIRK_LOG) << "7. Try to conquier an entire continent"; | 1194 | qCDebug(KSIRK_LOG) << "7. Try to conquier an entire continent"; | ||
1195 | /* Try to conquier an entire continent */ | 1195 | /* Try to conquier an entire continent */ | ||
1196 | for (int iCountry = 0; | 1196 | for (int iCountry = 0; | ||
1197 | iCountry < m_world->getCountries().size(); | 1197 | iCountry < m_world->getCountries().size(); | ||
1198 | iCountry++) | 1198 | ++iCountry) | ||
1199 | { | 1199 | { | ||
1200 | if ((RISK_GetOwnerOfCountry(iCountry) == this) && | 1200 | if ((RISK_GetOwnerOfCountry(iCountry) == this) && | ||
1201 | (RISK_GetContinentOfCountry(iCountry) == continent) && | 1201 | (RISK_GetContinentOfCountry(iCountry) == continent) && | ||
1202 | GAME_IsEnemyAdjacent(iCountry)) | 1202 | GAME_IsEnemyAdjacent(iCountry)) | ||
1203 | { | 1203 | { | ||
1204 | int i = 0; | 1204 | int i = 0; | ||
1205 | while ((i < 6) && (RISK_GetAdjCountryOfCountry(iCountry, i) != -1)) | 1205 | while ((i < 6) && (RISK_GetAdjCountryOfCountry(iCountry, i) != -1)) | ||
1206 | { | 1206 | { | ||
▲ Show 20 Lines • Show All 951 Lines • Show Last 20 Lines |
i would prefer if you didn't change this. Changing the random generation may break stuff and qrand is marked as deprecated in the docu nowadays so may disappear in the future