1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-19 21:10:12 +02:00

320 Commits

Author SHA1 Message Date
Xilmi
6b55401fde Swapped order of Defend and Far-Hunter-Gather 2025-02-09 17:33:39 +00:00
Xilmi
8d3970c6d5 AI-adjustments
AI no longer thinks it can recharge their mana at towns without a mage-guild.
AI no longer treats neutral monsters as if  they were their enemies.
Upgrading armies no longer has it's own priority-tier. It is now handled at the same-priority as hunter-gather.
2025-02-09 17:33:39 +00:00
Xilmi
c9f669b41d Update PriorityEvaluator.cpp
If there's several valid defense-tasks use the one that takes fewer turns to get to.
2025-02-09 17:33:39 +00:00
Xilmi
b3eecf431c Anti-suicide-changes
Fixed an issue causing the AI to use evaluationContext.powerRatio as maxWillingToLose instead of evaluationContext.powerRatio * ai->settings->getMaxArmyLossTarget().

Defense-tasks no longer ignore maxWillingToLose when the target isn't a hero.
2025-02-09 17:33:39 +00:00
Xilmi
64ff6a0631 Update PriorityEvaluator.cpp
Basic dwellings get a score-boost to take into consideration that units are immediately hirerable as opposed to just being added at the beginning of next weak. This means they should win out against early Citadels more.

Handling for conditional quicker mage-guild-upgrading incase of caster-mains.
2025-02-09 17:33:39 +00:00
Xilmi
765658ec83 Various Evaluation improvements
AI-heroes are reduce their confidence for attacks based on how many of the units they currently have stacks from exist somewhere else in their empire. So for example if an AI has 2 black-drakes while 3 more are waiting in their castle, they act as if their army was only 2/5th as strong as it is. This should make them more likely to first reinforce their army before attacking.

Changed the formula of scoring dwelling-upgrades in a way that doesn't overvalue upgrading vs. producing new units so much.

AI will no longer be so overconfident when fighting enemy heroes near their own castle. This lead to a lot of horrible trades, especially between different AI which made FFAs way easier in the long run.

AI should be better at preventing their enemies finding their towns undefended due to considering enemies that are not immediately in their castle's range too.

If only gold is missing but no special-resources the AI will no longer devalue what building it wants to build next and build something cheaper instead. This should lead to AI quicker reaching their tier 7 units and skipping some unnecessary lower tiers on the way to it.
2025-02-09 17:33:39 +00:00
Xilmi
6c4996ff54 AI will now devalue the usefulness of non-flying units when attacking defensive structures in order to prevent suiciding against castles 2025-02-09 17:33:39 +00:00
Xilmi
ae6dcf4c6b Fix for going through all passes despite not doing anything
AI now checks whether it moved anything when it executed tasks. If it didn't it will not continue to further passes.
2025-02-09 17:33:39 +00:00
Ivan Savenko
df99645eca
Merge pull request #5301 from IvanSavenko/map_loading_fix
Map loading fixes
2025-01-25 17:23:54 +02:00
Ivan Savenko
5ea4014589
Merge pull request #5304 from IvanSavenko/oneway_ai
Enable one-way monoliths for AI
2025-01-25 13:42:31 +02:00
Ivan Savenko
09db3e4bef Reworked resource piles loading to fix wog maps with mithril 2025-01-25 11:40:21 +00:00
Ivan Savenko
32391dc7a9 Pathfinder cache is now stored separately per playerBlocked
- human player will now use pathfinder settings from config (as before)
- nullkiller AI will now use its own, modified settings
- added option to configure NKAI usage of monolith to config
- fixed pathfinder costs not updating on receiving levelup
2025-01-23 15:28:44 +00:00
Ivan Savenko
2ee5f2df02
Merge pull request #5295 from IvanSavenko/bugfixing
[1.6.4] Bugfixing for recently reported issues
2025-01-21 15:50:02 +02:00
Ivan Savenko
54c86e0292
Merge pull request #5292 from IvanSavenko/nkai_artifact_score
Per-hero artifact scoring for NKAI
2025-01-20 15:47:40 +02:00
Ivan Savenko
7a0e8f95b9 Add quick workaround for NKAI not constructing resource silo 2025-01-19 19:41:38 +00:00
Ivan Savenko
3479ec9651 Per-hero artifact scoring for NKAI
AI now has better (but not perfect) system for scoring artifacts.

All artifacts now have their base score, based on bonuses provided by
the artifact. For composite artifacts, AI will also consider bonuses
from its components.

When exploring, AI will now weight artifacts as min(base score, price /
5), meaning even artifacts that AI can't score will still have some
priority, if only to sell them or deny them to enemy

AI will now also consider what to equip when trading with heroes or on
the end of AI pass. When considering what to equip, hero will use base
score of an artifact, adjusted by how relevant particular bonus /
artifact for a hero. Some examples:
- Morale-bonusing artifacts have their score reduced based on percentage
of undeads in the army, all the way to 0 for undead-only troops
- Artifacts that give spells (books, hat) will have score reduced based
on how many of these spells are already known by hero
- Land movement artifacts have zero score while on water and vice versa
- Necromancy artifacts will have zero score if hero does not have
necromancy
- Archery artifacts are scaled by amount of ranged troops, and only used
if hero has archery skill

AI may still equip 'bad' artifact, however this should only happen if
hero has no other artifacts to equip into said slot.

TODO's for future PR's (although not sure if / when I will work on
these):
- avoid equipping duplicates of the same artifact. Most notably with
scrolls, but may happen with other misc artifacts or rings.

- consideration for various spell-immunity neclaces

- consideration for birectional artifacts, like Shackles of War, or some
Spheres - since these artifacts need consideration on what our expected
enemy is to correctly estimate whether

- equipping artifacts based on immediate need - for example, equipping
recovery artifacts before end of day, equipping legion pieces only in
town on day 7, preparing for strong / weak enemies (or even preparing
for specific enemy in advance)

- transferring resource-generating artifacts and such to scout heroes,
allowing main hero to focus on combat

- ensure that AI can equip combined artifacts even if non-primary slots
are in use - by considering whether score of combined artifact is higher
than score of all used slots
2025-01-18 13:14:24 +00:00
Ivan Savenko
1c6fbe4200 Reduce excessive NKAI logging 2025-01-12 12:21:10 +00:00
Ivan Savenko
ec9dbfd667 Remove excessive recomputations of tile owners 2025-01-08 20:07:42 +00:00
Ivan Savenko
82e8db3037 Do not compute threats that are too far away to be useful 2025-01-08 20:07:42 +00:00
Ivan Savenko
1caab5100a Try to reduce amount of time AI spends on pathfinding 2024-12-23 13:26:54 +00:00
Xilmi
33f5b473b3 Defender should not run off for troop-delivery
Fixed a rare case in which a town-defender could become an indirect part of a troop-delivery-task by doing a sub-task like capturing a shipyard that takes less than 1 turn but leaves him out in the open.
2024-12-13 21:50:45 +01:00
Xilmi
6536c9a18e Satisfy SonarCube 2024-12-12 14:58:29 +01:00
Xilmi
59497db428 Fixed isEnemy becoming true for things it shouldn't
Not sure whether it actually impacts behavior but better fix it either way.
2024-12-12 13:40:50 +01:00
Xilmi
32d85ce6ff Fix for retreating-behavior generally not working
Fixed that armyInvolvement was only filled in when the action involved a target to interact with rather than just a tile.
Since armyInvolvement was used for scoring actions such as retreating towards the closest town, this caused the AI to never retreat to their towns when they were supposed to.
2024-12-12 11:07:56 +01:00
Xilmi
347efa98a0 Introduced new priority-tiers for handling attacking and gathering near enemies that are really far away
So that the AI won't become too passive on giant maps.
2024-12-11 14:47:08 +01:00
Xilmi
650db73300 Ignore all ExceuteHeroChain-tasks with 0 movement-cost
These can happen when an enemy spawns ontop of an AI-hero. If the action would win, it wouldn't be executed anyways. So now AI does the next best thing instead, which likely what it wanted to do anyways.
2024-12-11 13:05:51 +01:00
Xilmi
eab6de4686 Fixed an issue that could cause the AI to skip almost their entire turn
If the best Task is to recruit a hero this now triggers pathfinding again as the newly bought hero may impair other heroe's paths.
2024-12-10 19:21:23 +01:00
Xilmi
df069bf14f Merge remote-tracking branch 'upstream/develop' into develop 2024-12-07 13:32:19 +01:00
Ivan Savenko
8c293ce156 First attempt to make per-difficulty configurations for AI 2024-12-05 15:08:04 +00:00
Xilmi
c007bbbcd8 AI improvements
AI will no longer skip turns with heroes that are waiting for a delivery that takes more than one turn. Instead they will do something until their delivery is close enough to get it at the same turn.

Fixed an issue where a bunch of heroes all tried to do the same tasks:
Tasks that involve no fighting will now always be performed by the closest eligible hero while all other heroes look for something else to do.
2024-12-03 23:09:13 +01:00
Ivan Savenko
01dd1858e4 Add option to recalculate hitmap on tile reveal 2024-12-01 21:50:28 +00:00
Ivan Savenko
7574842e93 Replace defines with constexpr 2024-11-28 15:08:15 +00:00
Ivan Savenko
40aa49acff Fix typo: Absoolute -> Absolute 2024-11-28 14:44:12 +00:00
Ivan Savenko
b25702f15e expose safeAttackRatio to AI config 2024-11-28 11:53:51 +00:00
Ivan Savenko
00492a60a7 Moved retreat decision-making constants to config 2024-11-28 11:39:36 +00:00
Ivan Savenko
71d9664295 Allow per-difficulty parameters for NKAI 2024-11-27 21:26:06 +00:00
Ivan Savenko
18f5d5bc70 Move pathfinder bucket parameters to nkai-settings 2024-11-26 18:58:34 +00:00
Xilmi
84571f1ae8 Update PriorityEvaluator.cpp
Just killing stuff even if there is no apparent reason now also is considered for the mere purpose of gaining XP.
This also helps the non-cheating AI to keep attacking enemies when they can't see anything worth exploring behind them.
2024-11-26 15:39:35 +01:00
Xilmi
2786797a4e Fixed incompatibility with latest merge
Incompatibility fix
2024-11-07 17:37:18 +01:00
Xilmi
a70f5de8c6 Merge remote-tracking branch 'upstream/develop' into develop 2024-11-07 14:35:13 +01:00
Xilmi
5979f53a26 Upgrade priority
New priority to upgrade existing armies to make it less likely to fight the AI with only part of its army.
2024-10-31 00:42:33 +01:00
Ivan Savenko
d3af9f1c67 Removed pointer to VLC entity from CStackBasicDescriptor 2024-10-30 16:47:02 +00:00
Ivan Savenko
c98ac01e7a Replaced public artType member of ArtifactInstance with getter 2024-10-30 16:47:01 +00:00
Xilmi
60084243af Update PriorityEvaluator.cpp
Fixed losing heroes while exploring.
2024-10-21 09:21:00 +02:00
Xilmi
76f5d925e6 Update PriorityEvaluator.cpp
The army loss will no longer affect the score for defensive decisions.
2024-10-21 08:59:18 +02:00
Xilmi
d93c6211da Road exploration
The non-cheating-AI on 100% and below is now smarter about exploration and will explore alongside roads with higher priority.
2024-10-20 23:32:39 +02:00
Xilmi
eb94c9f0be Update PriorityEvaluator.cpp
AI will be more aggressive when defending their territory. And more aggressive means more willing to take losses while fighting.
2024-10-10 18:53:28 +02:00
Xilmi
61fba1fedd Merge remote-tracking branch 'upstream/develop' into develop 2024-10-10 17:23:39 +02:00
Ivan Savenko
3dd4fa2528 Reduce usage of pointers to VLC entities
Final goal (of multiple PR's) is to remove all remaining pointers from
serializeable game state, and replace them with either identifiers or
with shared/unique pointers.

CGTownInstance::town and CGHeroInstance::type members have been removed.
Now this data is computed dynamically using subID member.

VLC entity of a town can now be accessed via following methods:
- getFactionID() returns ID of a faction
- getFaction() returns pointer to a faction
- getTown() returns pointer to a town

VLC entity of a hero can now be accessed via following methods:
- getHeroTypeID() returns ID of a hero
- getHeroClassID() returns ID of a hero class
- getHeroType() returns pointer to a hero
- getHeroClass() returns pointer to a hero class
2024-10-10 12:28:08 +00:00
Xilmi
0143a52755 Update PriorityEvaluator.cpp
Scores for all sorts of visitable and pickable objects are now unified in order to prevent AI from ignoring nearby valuables.
2024-10-02 20:12:47 +02:00