1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00
Commit Graph

839 Commits

Author SHA1 Message Date
96d691b40c Fix crash on closing game during background image upscaling 2025-03-12 14:18:44 +00:00
dff37ce81f Fix freeze if AI initiates large number of async requests during turn 2025-03-11 14:58:26 +00:00
62cb5412ff CGameState::map is now a private, unique_ptr with accessors 2025-03-08 14:05:14 +00:00
a061ed04de Remove usage of ConstTransitivePtr from CTown 2025-03-08 14:04:51 +00:00
4a6a8f9496 Merge pull request #5496 from IvanSavenko/std_thread
Replace boost::thread with std::thread
2025-03-08 16:03:55 +02:00
9f713a0914 Rename int3::valid to isValid for consistency 2025-03-03 10:46:00 +00:00
0200e871c3 Code cleanup 2025-03-02 20:39:41 +00:00
a31788b874 Replace thread spawning with tbb pool for adventure AI 2025-03-02 19:24:24 +00:00
219eea86ff Better handling of AI shutdown 2025-03-02 14:33:11 +00:00
5f052165fe Fix missing names for some threads 2025-03-02 14:33:11 +00:00
948abfb04c AI now uses std::thread, added custom thread interruption logic 2025-03-02 14:33:11 +00:00
844dfb1604 Removed usage of boost::thread from vcmi, except for AI 2025-03-02 14:33:11 +00:00
a8a6be7ac1 Fix potential compatibility with C++20 / C++23 mode
This fixes several issues with compatibility with C++20. C++23 was also
tested, but apparently it does not have any additional breaking changes
compared to C++20 (or we don't have those).

VCMI still uses C++17 as before - goal is only to make potential
transition easier.

There were 2 cases that are deprecated in C++20 that we use:
- Floating point operations on enums are deprecated
- `this` can no longer be captured when using default capture by value
`[=]`

Both of those should now be replaced with code that works fine in both C+
+17 and in C++20 mode
2025-03-02 14:11:48 +00:00
0182bcd74a Revert "min_element and max_element from std"
This reverts commit ba2d8dc276.
2025-02-28 17:04:37 +01:00
a8b9ec9d67 Revert "std::sort instead of boost::sort"
This reverts commit 2f8566b63e.
2025-02-28 17:04:06 +01:00
ba2d8dc276 min_element and max_element from std 2025-02-28 16:56:20 +01:00
2f8566b63e std::sort instead of boost::sort 2025-02-28 16:47:35 +01:00
4e73f7d90f shared_mutex replace boost 2025-02-28 16:01:11 +01:00
75a95d8513 boost::lock_guard replace 2025-02-28 15:28:38 +01:00
7dfb499edf replace boost locks with std 2025-02-28 15:25:58 +01:00
8f074490a7 Merge branch 'master' into 'develop' 2025-02-27 21:15:42 +00:00
f4f89d1536 Invalidate pathfinder cache on dismissing a hero 2025-02-26 14:47:00 +00:00
645b95ba02 Renamed LibClasses * VLC to GameLibrary * LIBRARY 2025-02-21 16:54:56 +00:00
2362c6da21 Fixes for multiple new issues from Sonar 2025-02-21 15:57:39 +00:00
0548f325e4 Merge branch 'master' into 'develop' 2025-02-21 13:59:34 +00:00
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
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
ec970c7b22 Support for configuring minimal cost for moving between tiles
- Added `movementCostBase` parameter to game config that defines minimal
amount of movement points that will be spent when moving from one tile
on another while offroad (and cost of Fly / Town Portal spells)
- Added `BASE_TILE_MOVEMENT_COST` bonus type that allows modifying
`movementCostBase` on per-hero basis

Example usage for hota-like pathfinding skill
```json
"tileCostReduction" : {
	"type" : "BASE_TILE_MOVEMENT_COST",
	"val" : -15
}
```
2025-02-03 22:52:33 +00:00
70cc9f7bb7 Replace locking mutex with per-thread storage 2025-02-03 17:13:48 +00: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