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

237 Commits

Author SHA1 Message Date
Ivan Savenko
f238d89601 NKAI - Prefer giving fast units to scouts
Nullkiller AI will now prefer giving its scout heroes faster units to
optimize their movement points on next turns.

Unit selection logic:
- AI prefers to give 'weak' units that won't affect army strength of main
hero. Unit is considered 'weak' if its level below 4 or if its AI value
is below 1% of total army strength. So AI can give high-tier unit to
scout, but only if main hero already has massive army.

- Within weak units, if hero is moving on terrain with penalty, AI will
always prefer units that are native to this terrain. So on snow AI will
always prefer unit from Tower even if its speed is lower than unit from
another faction.

- Within remaining candidates, AI will prefer unit that will give higher
movement points limit. This also means that in case of H3 rules, all
units with 11+ speed will be viewed as equally good

- If there are multiple units with same speed, AI will prefer unit with
lowest AI value
2025-02-11 16:37:54 +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
Ivan Savenko
70cc9f7bb7 Replace locking mutex with per-thread storage 2025-02-03 17:13:48 +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
ff2de1661a Enable one-way monoliths for AI 2025-01-20 21:34:10 +00:00
Ivan Savenko
9f1cd69480 Fix visualization of AI object graph 2025-01-07 14:06:09 +00:00
Ivan Savenko
c3952b31f1
Merge pull request #5158 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
1caab5100a Try to reduce amount of time AI spends on pathfinding 2024-12-23 13:26:54 +00:00
Ivan Savenko
ab45c58e26 Use small_vector for bonus list to reduce allocations 2024-12-21 14:43:08 +00: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
Ivan Savenko
18f5d5bc70 Move pathfinder bucket parameters to nkai-settings 2024-11-26 18:58:34 +00:00
Xilmi
a70f5de8c6 Merge remote-tracking branch 'upstream/develop' into develop 2024-11-07 14:35:13 +01:00
Ivan Savenko
08fbcd5239 TerrainTile now uses identifiers instead of pointers to VLC 2024-10-30 16:22:11 +00:00
Xilmi
5d6877e06d Merge remote-tracking branch 'upstream/develop' into develop 2024-10-20 00:49:17 +02:00
Ivan Savenko
cee3521f57
Merge pull request #4770 from IvanSavenko/prison_fix
Fix for loading hero types / identities
2024-10-14 18:16:53 +03:00
Ivan Savenko
31095248ab Removed typeName and subtypeName properties from CGObjectInstance 2024-10-13 13:05:50 +00:00
Ivan Savenko
a8e84c55f6 Fix some of the new warnings from sonarcloud 2024-10-11 10:45:29 +00:00
Xilmi
da32b8b58f Restore compatibility with removal of getFaction() 2024-10-10 17:33:54 +02:00
Xilmi
5e6fefdc50 Reverted fix for not trying to moving foreign heroes
While it fixed the bug it was supposed to fix it caused another severe bug: AI wasn't generating a thread-map anymore.
Original bug needs to find another fix.
2024-10-02 23:40:51 +02:00
Xilmi
f0802c0b3c Move foreign hero fix
Fixed an issue that caused the AI to try and move heroes of other players.
2024-10-02 20:11:20 +02:00
Xilmi
73e7d3f5bb Another reason not to try to town-portal
Even if the hero blocking a town is from the own faction, the town must not become a target if the city has stashed armies because in that case the hero ontop of it won't be able to go into garrison for the TP.
2024-09-30 19:41:39 +02:00
Xilmi
74f3aedcc9 TP onto friend attempt
Fixed an issue that caused the AI to think it can townportal onto heroes of other factions, for example their allies.
2024-09-30 19:32:27 +02:00
Xilmi
769268cfe3 Eternal Garrison
Fixed an issue that caused heroes to stay garrisoned for ever when hero-cap was reached.
2024-09-29 01:15:09 +02:00
Xilmi
d87f195bc7 Update AINodeStorage.cpp
Nodes along the path are now also considered for how dangerous it is.
2024-09-23 18:39:18 +02:00
Xilmi
9ef2c6f8a0 Merge remote-tracking branch 'upstream/develop' into develop 2024-09-22 23:43:29 +02:00
Andrii Danylchenko
ce0f51672a NKAI: replace hardcoded pandora with more flexible solution 2024-09-20 16:05:57 +03:00
Xilmi
1495ec56f6 Update AINodeStorage.cpp
The node of a disembark-action can no longer be part of a hero-chain since sea-to-land-trade isn't possible and landing first eats up all movement-points.
2024-09-15 20:46:17 +02:00
Xilmi
065125e770 Merge remote-tracking branch 'upstream/develop' into develop 2024-09-10 14:57:27 +02:00
Ivan Savenko
8225eb454e Added GameSettings to gamestate, potentially allowing to define game
settings per map (or in random map template)
2024-09-05 15:16:27 +00:00
Xilmi
db16a9d234 A bit of clean-up for merge
Set back trace level to 0
Removed EvaluationContexts that weren't used
Encapsulated many debug-messages behinde trace-levels
2024-09-04 16:41:47 +02:00
Xilmi
e6d907af55 Merge remote-tracking branch 'upstream/develop' into develop 2024-08-18 09:52:59 +02:00
Ivan Savenko
97f1a310df Fix miscellaneous issues discovered by Sonar 2024-08-12 18:26:30 +00: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
f0f40660c4 reverse getTotalArmyLoss()-change
Due to a recent fix in army-loss calculations this method should now work correctly the way it was.
2024-07-19 15:59:57 +02:00
Xilmi
fa2f883361 Merge remote-tracking branch 'upstream/develop' into develop 2024-07-19 15:26:31 +02:00
Xilmi
eb26b16823 Trace level
Increased AI-trace-level because I need it for debugging.
2024-07-19 15:26:14 +02:00
Andrii Danylchenko
37dc2a38e8 NKAI: reduce double army loss cases 2024-07-18 13:38:25 +03:00
Xilmi
f8f10adb2e Take magic-capability into account for overall strength-estimation of hero-lead-armies
The magic-strength of a hero now checks if the hero has a spellbook and at least one combat-spell.
The impact of knowledge and spellpower to the hero's magic-strength is now also depending on it's current and max mana-pool-size as an empty mana-pool does not exactly contribute well to fights.

Replaced every call of getFightingStrength() with getHeroStrength() which uses both the fightingStrength and the (reworked) magicStrength to guess how much stronger a hero-lead army is.
2024-07-15 17:42:02 +02:00
Xilmi
83ffbdff2b Fix for double army-loss
Fixed that army loss was taken into account both for the path and the target-object. In certain cases, like a hero defending a town, this could lead to armyloss being twice as high as it should be.
2024-07-15 17:35:54 +02:00
Ivan Savenko
04a81fee87 Reduce size of CGPathNode and AIPathNode 2024-07-15 07:49:04 +00:00
Xilmi
a821978d4e Merge remote-tracking branch 'upstream/develop' into develop 2024-07-12 17:43:04 +02:00
Ivan Savenko
6b8f94e6e7 Merge remote-tracking branch 'vcmi/master' into develop 2024-07-11 17:43:44 +00:00
Xilmi
54c6d99de3 Using only one bucket
Nullkiller suggested that this change would help to further fix inconsistent behavior by the AI. I tested it and it did indeed fix different orders of how AI does things.

"Important to make count 1 to not relay on object addresses
They are source of random" - Nullkiller
2024-07-07 15:17:38 +02:00
Ivan Savenko
b5c36958a9 Workaround for very slow boat summon tests 2024-07-04 19:56:01 +00:00
Ivan Savenko
73fdd12581 Use optimized container without dynamic memory allocations 2024-07-03 21:15:40 +00:00
Ivan Savenko
1468abb8a0 Remove excessive copies of large objects 2024-07-03 21:14:22 +00:00
Ivan Savenko
40f17d654d Use containers with pre-allocations to improve pathfinding speed 2024-07-03 18:06:56 +00:00