1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00
Commit Graph

2140 Commits

Author SHA1 Message Date
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
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
82ab49495e Fixed an issue that prevented AI from building stables
Prerequisites of dwellings now also inherit the armyStrength of their respective dwelling for the purpose of their evaluation.
2025-02-09 17:33:39 +00:00
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
49d73b438b Update Nullkiller.cpp
Further warning-removal
2025-02-09 17:33:39 +00:00
3d87568349 Fix justified warning 2025-02-09 17:33:39 +00:00
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
6b55401fde Swapped order of Defend and Far-Hunter-Gather 2025-02-09 17:33:39 +00:00
b0e87f01ed Fix cluster prio
Clusters are now checked against all priority-tiers instead of just hunter-gather.
2025-02-09 17:33:39 +00:00
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
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
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
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
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
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
d3987d8456 AI should only defend with one hero, not several who won't fit into the city anyways 2025-02-09 17:33:39 +00:00
97111328a8 Made hiring heroes a bit more conditional to spam fewer of them 2025-02-09 17:33:39 +00:00
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
70cc9f7bb7 Replace locking mutex with per-thread storage 2025-02-03 17:13:48 +00:00
313fa1e80e Remove commented-out code 2025-01-30 11:31:54 +00:00
d8ec69bfaa Remove non-const iterators to BattleHexArray container
Replaced with several non-const methods to prevent modification of
internal storage without corresponding modification of internal flags
2025-01-29 23:02:51 +00:00
f858a6e04b Merge pull request #5266 from MichalZr6/battlefield
Minor fixes to BattleHexArray. BattleHex'es as const reference where possible.
2025-01-25 17:44:14 +02:00
df99645eca Merge pull request #5301 from IvanSavenko/map_loading_fix
Map loading fixes
2025-01-25 17:23:54 +02:00
5ea4014589 Merge pull request #5304 from IvanSavenko/oneway_ai
Enable one-way monoliths for AI
2025-01-25 13:42:31 +02:00
09db3e4bef Reworked resource piles loading to fix wog maps with mithril 2025-01-25 11:40:21 +00:00
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
2ee5f2df02 Merge pull request #5295 from IvanSavenko/bugfixing
[1.6.4] Bugfixing for recently reported issues
2025-01-21 15:50:02 +02:00
a1593948b7 Restore LF, use JsonKeys for logging, fix BattleHex description 2025-01-21 13:23:17 +01:00
ecdd394bb1 Use BattleHex as const ref wherever possible
Minor Fixes
Drop unused function from BattleHexArray
2025-01-21 13:23:17 +01:00
8f63a82d60 Minor changes with BattleHex and BattleHexArray 2025-01-21 13:23:17 +01:00
ff2de1661a Enable one-way monoliths for AI 2025-01-20 21:34:10 +00:00
54c86e0292 Merge pull request #5292 from IvanSavenko/nkai_artifact_score
Per-hero artifact scoring for NKAI
2025-01-20 15:47:40 +02:00
7a0e8f95b9 Add quick workaround for NKAI not constructing resource silo 2025-01-19 19:41:38 +00:00
2d6ae7859b Fixes BattleAI not selecting best hex when approaching nearest enemy 2025-01-19 16:38:50 +00:00
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
e829d723b2 Replace global bonus tree change counter with per-node counter 2025-01-12 12:23:07 +00:00
1c6fbe4200 Reduce excessive NKAI logging 2025-01-12 12:21:10 +00:00
3d1bf03a25 Fix potential concurrent access 2025-01-12 11:06:00 +00:00
5cff9af236 Reduce BattleAI logging 2025-01-10 19:45:35 +00:00
40bff74195 Use small vector for unit list 2025-01-10 18:58:46 +00:00
797b62fd46 Try to implement lazy evaluation for reachability map 2025-01-10 17:43:45 +00:00
2d5b5d94e7 Optimize computation of reachability map 2025-01-10 15:38:28 +00:00
a44bbf4527 Merge pull request #5044 from MichalZr6/battle_hex_array
New container for BattleHexes. Refactors aiming for quick-battle better performance.
2025-01-10 15:32:05 +02:00
ca21adc93f Merge pull request #5227 from kambala-decapitator/cmake-improvements
CMake improvements
2025-01-10 15:24:44 +02:00
ec9dbfd667 Remove excessive recomputations of tile owners 2025-01-08 20:07:42 +00:00
82e8db3037 Do not compute threats that are too far away to be useful 2025-01-08 20:07:42 +00:00
2ec518fdf0 [cmake] link NKAI to TBB 2025-01-08 15:37:17 +03:00
db5d77362a [fuzzylite] force C++14 standard
doesn't build under C++17 due to using removed symbols
2025-01-08 15:22:21 +03:00
dbe82b94f6 Changes following review:
- shared_ptr for destructibleEnemyTurns instead of raw pointer
- drop implicit int conversion for BattleHex class
  and implement toInt() instead
- implement necessary operators in BattleHex
- adjust code to work properly with JSON serializer
2025-01-08 07:24:43 +01:00
9f1cd69480 Fix visualization of AI object graph 2025-01-07 14:06:09 +00:00