1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-17 20:58:07 +02:00

326 Commits

Author SHA1 Message Date
Xilmi
c7b875f671 Small adjustments to defensive behavior
AI will no longer leave the defense of a threatened town in order to bring the army to another hero.

AI will no longer send heroes to die outside of towns that already have a garrisioning hero inside, if there's a stronger enemy hero lurking around the town.
2025-02-09 17:33:56 +00:00
Xilmi
1b041fe09d Update PriorityEvaluator.cpp
Keymaster is no longer considered as conquest-target (which made the AI beeline for it).
2025-02-09 17:33:45 +00:00
Xilmi
cf3eee5d8a AI-adjustments
AI no longer rushes towns that don't have a citadel or better when there is a scary enemy hero around.

AI will no longer try to maximize defenses by using the strongest possible defender. Instead it will try to use the most appropriate defender. The most appropriate is considered to have roughly 75% power of the threat and the score will be lower but still above zero the bigger the deviation is.
2025-02-09 17:33:39 +00:00
Xilmi
49d73b438b Update Nullkiller.cpp
Further warning-removal
2025-02-09 17:33:39 +00:00
Xilmi
3d87568349 Fix justified warning 2025-02-09 17:33:39 +00:00
Xilmi
5bd4b6a541 Several AI-Adjustments
Dismissing StayAtTown-tasks for heroes with less than 100 movement-points in order to avoid these tasks to be creates for heroes that have no movement over and over.

Resource-silo is now evaluated by it's output rather than like a building the AI doesn't know what it is good for.

AI should now try to maximize the highest mage-guild instead of building them slowly one by one.

Drastically reducing the score of dwelling-upgrades for upgrades the AI already has.

Heroes that are currently threatened anyways will be more brave and not care about going for things that are also threatened if there is nothing safe in range.

AI will no longer waste their heroe's MPs defending cities that don't have at least a Citatdel.

Reverted prior change that caused AI to no longer push for grey towns.
2025-02-09 17:33:39 +00:00
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