1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00
Commit Graph

174 Commits

Author SHA1 Message Date
Xilmi
fac18d953e Fixed and improved disband-logic
The score for buying army now scales with the cost of that army.
The cost of the units that need to be disbanded in order to hire the new units is subtracted from the army-hiring-score so the AI will prefer hiring armies where the amount of troops to disband is low or non-existent.
Fixed a bug that also disbanded troops when there still were free slots available.
2024-12-13 00:09:10 +01:00
Xilmi
34b8123fba Hero hiring adjustments
The AI is now a lot more likely to buy a hero early on when that hero's army is worth more than half the cost of the hero, regardless of other circumstances.
2024-12-02 15:11:39 +01:00
Xilmi
2df9861076 Update DefenceBehavior.cpp
Stop iterating over tasks when the curent hero has been found in one.
2024-12-01 23:05:56 +01:00
Xilmi
1d79946825 Fix for AI not defending in some cases
Instead of skipping the defense of other towns entirely when hiring a hero was considered as a way of defending, now only hiring the same hero twice will be avoided.
2024-12-01 23:00:35 +01:00
Ivan Savenko
b25702f15e expose safeAttackRatio to AI config 2024-11-28 11:53:51 +00:00
Xilmi
cd65e69c91 Update GatherArmyBehavior.cpp
Fixed an issue that made AI consider unpurchased troops as reinforcements for their armies which caused AI to visit cities over and over without actually doing anything there.
Buying units is handled by BuyArmyBehavior.
2024-11-26 15:15:08 +01:00
Xilmi
9d2fc1b1c9 Update DefenceBehavior.cpp
Fixed an issue that caused the AI to try buying the same hero in two different towns.
2024-10-31 00:41:51 +01:00
Xilmi
3a8a67407b Update RecruitHeroBehavior.cpp
AI's willingness to hire hero now depends more on the availability of treasure again.
2024-10-20 16:37:03 +02:00
Xilmi
11980e0f97 Garrisoning behavior improvement
AI will now also garrison a hero as defender if the town to be defended has troops as long as the hero can merge their own troops with the town.

AI will no longer just dismiss existing troops in a town if a hero trying to garrison there can merge with it.
2024-10-20 15:49:23 +02:00
Xilmi
f04e110e2c Update RecruitHeroBehavior.cpp
Removed inclusion of no longer existing and also not needed header.
2024-10-20 12:59:08 +02:00
Xilmi
da32b8b58f Restore compatibility with removal of getFaction() 2024-10-10 17:33:54 +02:00
Xilmi
68e264d990 Prune paths involving enemy heroes
Capture objects and gather army will now skip paths that involve foreign heroes.
2024-10-03 15:06:34 +02:00
Xilmi
f2b8b40925 Being less dismissive
Reduced the amount of circumstances under which the AI dismisses heroes. Among others to prevent a loop through all passes where it repeatedly hires and dismisses heroes.
2024-10-01 17:20:54 +02:00
Xilmi
cfe4d7592a Update DefenceBehavior.cpp
Heroes will no longer rush to defend towns that have a standing garrison that they can't merge their armies with.
2024-09-29 03:13:21 +02:00
Xilmi
0b016b9b14 Update RecruitHeroBehavior.cpp
If the AI is very rich it will buy more heroes even if it doesn't have a capitol.
2024-09-27 23:02:40 +02:00
Xilmi
71504a3140 Hire despite hero present
Only if both the garrison and the outside of a town are blocked are hires of heros being blocked.
2024-09-23 17:25:17 +02:00
Xilmi
5ed888b284 Update BuyArmyBehavior.cpp
Accomplish the same but with simpler code.
2024-09-12 20:07:22 +02:00
Xilmi
aefe2fda36 Update BuildingBehavior.cpp
No longer rush a fort in a threatened town.
2024-09-10 23:42:51 +02:00
Xilmi
37f9f93948 Update RecruitHeroBehavior.cpp
Modified how to score what hero to hire to make it more likely to rehire fled heroes with high levels when the army-gain from the hero would be rather insignificant.
2024-09-09 23:38:28 +02:00
Xilmi
faa5a02659 Update RecruitHeroBehavior.cpp
Fix potential division by zero.
2024-09-09 23:25:09 +02:00
Xilmi
e7e3f6dcbe Update DefenceBehavior.cpp
Only hire heroes for defence if the enemy is already really close. (Otherwise AI hired too many heroes from defensebehavior)
2024-09-09 19:55:03 +02:00
Xilmi
8c3f6fc1e2 Update RecruitHeroBehavior.cpp
Fixed crash caused by mistakenly assuming that "pos" is the position of a hero on the map and not its bottom-right-corner that can be outside of the map.
2024-09-08 02:19:19 +02:00
Xilmi
0edc17b7d8 Going to town when nothing to do.
The StayAtTown-behavior now always creates tasks for all heroes to go and stay at a town. It will be treated differently than going to a town for mana in the sense that it is only considered at the lowest priority-tier. So it will only happen when the AI doesn't find anything else to do. It should resolve one of the two main-reasons for losing weak heros.

The hunter-gather-priority-tier now goes strictly by distance for all taks that are considered above 0 in value.
2024-09-06 22:14:59 +02:00
Xilmi
d9fe8d7fa0 Update BuyArmyBehavior.cpp
Removed pointless check for hero-army being more valuable than buying army directly as it was never the case anyways.
2024-09-05 16:50:22 +02:00
Xilmi
b3115f65c5 Update BuildingBehavior.cpp
Use std::numeric_limits<uint8_t>::max(); instead of  UINT8_MAX; and remove some leftover-trace-messages from debugging.
2024-09-05 16:45:45 +02:00
Xilmi
c186de2d52
Update AI/Nullkiller/Behaviors/RecruitHeroBehavior.cpp
Avoid checking float against an exact value.

Co-authored-by: Ivan Savenko <saven.ivan@gmail.com>
2024-09-05 16:36:07 +02:00
Xilmi
751f3b0e7d Update BuildingBehavior.cpp
Fixed an issue that prevented generating more building-tasks when there already were tasks.
2024-09-01 13:46:44 +02:00
Xilmi
72597b549b hero spread
Prefer hiring heroes at towns that don't have heroes nearby.
2024-08-31 23:00:27 +02:00
Xilmi
8cf99616d0 Update BuildingBehavior.cpp
Fixed a warning which, in this case, was actually also a logical error! :o
2024-08-19 21:21:56 +02:00
Xilmi
e86ca49c37 Update BuildingBehavior.cpp
Fixed warning
2024-08-19 21:15:25 +02:00
Xilmi
e6d907af55 Merge remote-tracking branch 'upstream/develop' into develop 2024-08-18 09:52:59 +02:00
Xilmi
af7d5c7f7f Update RecruitHeroBehavior.cpp
Don't hire a hero in a town where another hero is currently defending against a threat. This would mean one of them has to stay outside and be exposed.
2024-08-18 09:50:32 +02:00
Xilmi
bdbb9d02fc Update DefenceBehavior.cpp
Fixed an issue where heroes that were leaving towns were still considered as defending the town.
2024-08-18 09:49:38 +02:00
Xilmi
65b8576687 Update BuyArmyBehavior.cpp
Allow building army in threatened town even when it wants to save for a building.
2024-08-18 09:49:02 +02:00
Xilmi
ea5ee039ca Update BuildingBehavior.cpp
Prioritize defensive buildings in threatened towns.
2024-08-18 09:48:16 +02:00
Ivan Savenko
97f1a310df Fix miscellaneous issues discovered by Sonar 2024-08-12 18:26:30 +00:00
Xilmi
fba34a743e Update DefenceBehavior.cpp
Reverted previous change to defense-behavior.

Both approaches have pros and cons and neither really works as I want. This still needs work.
2024-08-11 18:23:52 +02:00
Xilmi
b0e4551dbf Update BuyArmyBehavior.cpp
No longer saving money for city-halls when city-halls cannot be built.
2024-08-07 01:35:17 +02:00
Xilmi
38da53135b Update DefenceBehavior.cpp
A town will no longer communitcate that it doesn't need defenses, when it currently has a garrisioned hero. Because otherwise the garrisoned hero would just leave and let the town undefended.
2024-07-25 21:47:56 +02:00
Xilmi
bbb5157f74 Update RecruitHeroBehavior.cpp
Reworked recruit-behavior to be a bit more conservative and avoid recruiting-sprees. Stuff like buying several heros in a row because the next one is always slightly better than the last but using up the whole starting-bank for that.
2024-07-24 21:17:04 +02:00
Xilmi
69b64a3241 Update ExplorationBehavior.cpp
Added missing bracked and changed indenting to make it less confusing.
2024-07-24 15:40:20 +02:00
Xilmi
34e4ab45ee Fixed what merge-conflict-handling had broken.
Restored exploration-without relying on memory but with included whirlpool
2024-07-24 15:21:17 +02:00
Xilmi
b83a214763 Merge remote-tracking branch 'upstream/develop' into develop 2024-07-24 14:59:24 +02:00
Andrii Danylchenko
683c363946 NKAI: whirlpool 2024-07-21 17:20:54 +03:00
Xilmi
945de7c369 More warnings
Removed unused code
2024-07-20 21:12:43 +02:00
Xilmi
9c6d8762c5 Lowered restrictions from hero-hiring.
Removed two restrictions from hero-hiring, that prevented AI from hiring heros in certain scenarios.
2024-07-19 15:18:02 +02:00
Xilmi
455ad648ae More warning fixes
heroRole is no longer needed here.
2024-07-15 20:09:11 +02:00
Xilmi
fbe1e171fe Merge remote-tracking branch 'upstream/develop' into develop 2024-07-15 18:36:19 +02:00
Andrii Danylchenko
6f5710e809
Merge pull request #4110 from vcmi/rewardables
NKAI: rewardables
2024-07-14 09:02:37 +03:00
Xilmi
a821978d4e Merge remote-tracking branch 'upstream/develop' into develop 2024-07-12 17:43:04 +02:00