1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

793 Commits

Author SHA1 Message Date
Ivan Savenko
df99645eca
Merge pull request from IvanSavenko/map_loading_fix
Map loading fixes
2025-01-25 17:23:54 +02:00
Ivan Savenko
5ea4014589
Merge pull request 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 from IvanSavenko/bugfixing
[1.6.4] Bugfixing for recently reported issues
2025-01-21 15:50:02 +02:00
Ivan Savenko
ff2de1661a Enable one-way monoliths for AI 2025-01-20 21:34:10 +00:00
Ivan Savenko
54c86e0292
Merge pull request 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
ca21adc93f
Merge pull request from kambala-decapitator/cmake-improvements
CMake improvements
2025-01-10 15:24:44 +02: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
Andrey Filipenkov
2ec518fdf0 [cmake] link NKAI to TBB 2025-01-08 15:37:17 +03:00
Ivan Savenko
9f1cd69480 Fix visualization of AI object graph 2025-01-07 14:06:09 +00:00
Ivan Savenko
3d3dd70a11 Simplify code, fix AI not building dwelling upgrades 2025-01-06 18:59:37 +00:00
Ivan Savenko
8468469976 Fixes for AI town building logic
- Fixes AI not considering non-built dwellings
- AI will now skip evaluation of towns in which construction today is no
longer possible
2025-01-06 16:20:53 +00:00
Ivan Savenko
c3952b31f1
Merge pull request from IvanSavenko/bonus_caching
[1.6.3] Bonus caching improvements
2025-01-06 14:38:34 +02:00
Ivan Savenko
f6f99d2384 Correctly initialize graph cost in turns instead of default 255 turns 2025-01-05 18:05:28 +00:00
Ivan Savenko
dea1eba20b Rework and optimize turnInfo used by pathfinder 2025-01-04 15:09:50 +00:00
Ivan Savenko
f9ce95756f Fix potentially infinite attempts to upgrade units by AI 2024-12-31 13:27:12 +00:00
MichalZr6
4e9f052e98 Fix creature upgrades in Fort and town's dwellings 2024-12-30 01:14:57 +01:00
Ivan Savenko
1caab5100a Try to reduce amount of time AI spends on pathfinding 2024-12-23 13:26:54 +00:00
Ivan Savenko
95a07ee5cb Use bonus system cache whenever possible 2024-12-21 18:47:11 +00:00
Ivan Savenko
0e1f8f99bc Reduce excessive logging 2024-12-21 14:43:08 +00:00
Ivan Savenko
ab45c58e26 Use small_vector for bonus list to reduce allocations 2024-12-21 14:43:08 +00:00
Ivan Savenko
c401eca7c4
Merge pull request from Xilmi/develop
AI is now able to deal with Coven and Factory special building-behavior's.
2024-12-21 15:57:50 +02:00
MichalZr6
f893c80192 Move UpgradeInfo class to header and source files 2024-12-19 14:13:09 +01:00
MichalZr6
af9445c16f Fixes following review 2024-12-17 22:34:06 +01:00
MichalZr6
d8d3948ac3 Fix AI to use hillFort all available upgrades. UpgradeInfo refactor. 2024-12-17 22:34:06 +01:00
Xilmi
64ad060846 Update RecruitHeroBehavior.cpp
closestThreat was supposed to be < 1, not < 0
2024-12-17 12:03:46 +01:00
Xilmi
aff73b6e65 Be less wasteful with hiring heroes
When an enemy is near our city that currently has a hero hiding in it, we don't buy a hero without army as that one would be forced to wait outside and likely be killed.
2024-12-17 12:02:58 +01:00
Xilmi
99fcf136ec Nullkiller AI is now also capable of upgrading dwellings a second time if that's possible 2024-12-16 23:45:21 +01:00
Xilmi
9012560e38 Fix for AI not recognizing 2nd T7-building of Factory as dwelling
This lead to it being built dead-last in the build-order instead of the AI trying to go for it quite early.
2024-12-16 17:19:07 +01:00
Xilmi
5ff834aac2 Remove debug-outputs
Debug-outputs removed
2024-12-13 22:13:27 +01: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
79fb5faa2e Fixed a freeze
It was happening when all slots were full but no unit even needed disbanding because the unit to be bought is part of the units that are inside of the existing slots.

(This commit contains excessive debugging but I don't want to remove it just yet incase another issue pops up.)
2024-12-13 12:23:13 +01:00
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
2ad9038709 AI can now disband units that block slots for buying better units
When the AI cannot buy units in a city because all slots are blocked and the units in the slot are cheaper than the units it wants to buy, the AI will now get rid of the units that block that slot in order to be able to buy the better units.
2024-12-12 20:06:33 +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
7da5c08f74 Update ObjectClusterizer.cpp
Actually fix the warning now.
2024-12-04 15:07:13 +01:00
Xilmi
66bc6c0d52 Update ObjectClusterizer.cpp
Fixed warning that prevents compilation on GitHub.
2024-12-04 14:57:46 +01: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