1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-16 10:19:47 +02:00
Commit Graph

1745 Commits

Author SHA1 Message Date
Xilmi
455ad648ae More warning fixes
heroRole is no longer needed here.
2024-07-15 20:09:11 +02:00
Xilmi
d4b4a6c4db Warnings
Commented out relics from debugging that were causing warnings for unused variables.
2024-07-15 19:57:33 +02:00
Xilmi
fbe1e171fe Merge remote-tracking branch 'upstream/develop' into develop 2024-07-15 18:36:19 +02:00
Xilmi
4a552d411c Decisionmaking-changes
There's 3 new evaluation-contexts that are now taken into account:
Whether an action is building, whether an action involves sailing and the newly introduced threat.

The value-evaluation of creatures now also takes special resources into account.

No longer treating other AIs differently than players when it comes to how afraid we shall be of them.

The cost of buildings for decision-making now determines missing resources. Available resources are ignored when it comes to how they impact the cost. But missing-resources will heftily impact the assumed price by calculating their market-value. This shall encourage the AI to rather build what it currently can build instead of saving up for something that it lacking the special resources for.

AI is no longer willing to sacrifice more than 25% of their army for any attack except when it has no towns left.

Revamped the priority-tiers of AI decision-making.

Higest priority is conquering enemy towns and killing enemy heroes. However, the AI will no longer try to do so when the target is more than one turn away and protected by a nearby enemy-hero that could kill the one tasked with dealing with the target. Except when they have no towns left. Then they get desperate and try everything.

As a general rule of thumb one could say the AI will prioritize conquest over collecting freebies over investing army to get something that isn't a city. It's a bit more complex than that but this is roughly what can be expected. It will also highly value their own heroes safety during all this.
2024-07-15 18:12:52 +02:00
Xilmi
95ba57dfe2 No more Startup-behavior
Startup-behavior was messing with my intended logic. Mostly by getting excess heroes for no real purpose other than that it could.
This wasted a lot of money that could be better invested on subsequent turns.
I removed it and playing-strength actually went up.
2024-07-15 17:50:30 +02: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
Xilmi
e2e3f9e638 Take hero-stats into account for attacking hero-defended entities
Instead of using just the strength of the raw army, the hero-stats are now taking into account for the generation of the danger-map.
2024-07-15 17:30:42 +02:00
Xilmi
48ecbd4cbf Threat in DangerHitMap
Added new value threat to DangerHitMapAnalayzer. The purpose is to allow decisions to be less binary around enemy heros.
2024-07-15 17:28:10 +02:00
Xilmi
53c51b4278 Allow all buildings
Added resource-silo and special buildings to things that AI can theoretically build.
2024-07-15 17:26:06 +02:00
Andrii Danylchenko
6f5710e809
Merge pull request #4110 from vcmi/rewardables
NKAI: rewardables
2024-07-14 09:02:37 +03:00
Xilmi
d878d0ce18 Avoid being killed
Heroes with conquest-tasks will only endanger themselves to be killed when they can execute a conquest in the same turn.

Heroes with other tasks will dismiss any tasks except of defending when they'd be within one turn of an enemy hero that could kill them.
2024-07-12 23:36:41 +02:00
Xilmi
102b537353 Recruit-behavior
Moved recruit-behavior back to tasks that plans get made for since otherwise it can mess up plans by blocking town-exits.
2024-07-12 23:33:58 +02:00
Xilmi
a821978d4e Merge remote-tracking branch 'upstream/develop' into develop 2024-07-12 17:43:04 +02:00
Xilmi
92bed2305e priority-tiers
Tasks are now in different priority-tiers. For now there's 2 tiers. One for regular tasks and one for tasks of the new "conquest"-type. Regular tasks will only be considered when no possible conquest-type tasks were found.

Slightly reworked scoring heuristics.
2024-07-12 17:41:46 +02:00
Xilmi
9456ab41da Priority-tier
Openmap is no longer tied to difficulty-level due to being configurable anyways.

Tasks are now in different priority-tiers. For now there's 2 tiers. One for regular tasks and one for tasks of the new "conquest"-type. Regular tasks will only be considered when no possible conquest-type tasks were found.

Recruit-hero-behavior is now evaluated before movement to make it more likely a new hero can exchange their stuff with others.
2024-07-12 17:39:52 +02:00
Xilmi
638c1350b8 Path-safety
No longer excluding paths for exposing a hero to an enemy in the behaviors. There definitely are reasons for doing something anyways, even if threatened. The logic for that should be done in the PriorityEvaluator.
2024-07-12 15:43:40 +02:00
Xilmi
663ca23f6f Army-hiring
Supressing hiring army on turn one seems just bad. Starting the main-hero as strong as possible seems like a good idea to me and hiring the available troops outright will help achieve that goal.

However, if there's a hero for hire, who has army with him that is a better deal, we hire that one first.
2024-07-12 15:41:55 +02:00
Xilmi
fdaac9d3c3 Hero-hiring
When we have no hero, we will definitely want to hire one.
We will also want to hire heroes who already pay for more than themselves by coming with an army that has more value than the hero costs.
2024-07-12 15:39:50 +02:00
Xilmi
3fed58c47b Gold-pressure 2024-07-12 15:36:29 +02:00
Ivan Savenko
6b8f94e6e7 Merge remote-tracking branch 'vcmi/master' into develop 2024-07-11 17:43:44 +00:00
Xilmi
98415e98da Spellcasting-bug-fix
Fixed a bug that prevented the AI from using spells when attacking an enemy settlement that has towers.
The bug was caused by noticing how greatly effective spells would be against towers but not being able to actually target them.
By skipping invalid targets, this no longer is an issue.
2024-07-10 14:36:35 +00:00
Xilmi
073c5bee45 Spellcasting fixes
Allowed the AI to cast spells that are aimed at a location instead of a unit. For example meteor shower.
Fixed an issue that caused the AI to not kill unit-stacks with spells due to only considering stacks where at least one unit survives in it's score-calculations.
2024-07-10 02:40:42 +02:00
Xilmi
13bbb573bd Spellcasting-bug-fix
Fixed a bug that prevented the AI from using spells when attacking an enemy settlement that has towers.
The bug was caused by noticing how greatly effective spells would be against towers but not being able to actually target them.
By skipping invalid targets, this no longer is an issue.
2024-07-09 22:55:39 +02:00
Ivan Savenko
e42285c2f1
Merge pull request #4240 from IvanSavenko/bugfixing
[1.5.4] Bugfixing
2024-07-09 14:32:24 +03:00
Tomasz Zieliński
5eabadd7db Use vstd 2024-07-09 06:50:00 +02:00
Tomasz Zieliński
bfa93be765 Limit predicted damage / loses to actual stack health 2024-07-09 06:39:41 +02:00
Ivan Savenko
7445e950ba Replace uint64_t with signed type to prevent overflow on substraction 2024-07-08 20:52:11 +00:00
Xilmi
94e5b5519c Fixed AI constantly visiting towns thinking they can get a huge upgrade
Due to morale-considerations the AI sometimes calculated that their strongest army after doing an exchange had slightly lower total value than the army they used before.
But by using unsigned "slightly lower" became near infinite.
So they constantly wanted to upgrade their army because they considered it more useful than anything else.
Changing the unsigned into signed fixes this.
2024-07-08 16:53:14 +02:00
Xilmi
d4308c2ce4 Merge branch 'fixes_only' into develop 2024-07-07 22:52:03 +02:00
Xilmi
a72d23ed8d Debug-Info
Added some debug-info and non-fuzzy-specific-priority-cutoff.
2024-07-07 22:51:50 +02:00
Xilmi
7b407b6432 AI-variant without fuzzy-logic
It is now possible to switch to an AI-variant that uses hand-written heuristics for decision-making rather than the FuzzyLite-engine. This is configurable in nkai-settings.json via the new parameter "useFuzzy".
2024-07-07 22:44:52 +02:00
Xilmi
e0a81b3e69 Fixed AI-exploration-data being lost after loading savegame
The information of whether objects like a redwood-observatory or subterranian gates have been interacted with by the AI will now be retrieved from the game-state instead of using an AI-internal memory that won't survive loading a save-game.
2024-07-07 22:08:19 +02:00
Andrii Danylchenko
1be36e1ad4 NKAI: rewardables 2024-07-07 21:58:39 +03: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
Xilmi
734f815e67 Sorting tasks after buildPlan
Tasks need to be sorted again after buildPlan as otherwise the correct order isn't guaranteed. This led to inconsistent behavior by the AI.
2024-07-07 15:12:05 +02:00
Ivan Savenko
b5c36958a9 Workaround for very slow boat summon tests 2024-07-04 19:56:01 +00:00
Ivan Savenko
41ed7e2e10 Added TODO's for potential optimizations that I've discovered 2024-07-04 07:59:50 +00:00
Ivan Savenko
075582910a Less CPU intensive version of ExplorationHelper::scanMap method 2024-07-04 07:53:25 +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
95d8e447b2 Remove access to text translation system from AI 2024-07-03 21:13:55 +00:00
Ivan Savenko
40f17d654d Use containers with pre-allocations to improve pathfinding speed 2024-07-03 18:06:56 +00:00
Ivan Savenko
24b77b0972 Remove access to hero name translation 2024-07-03 17:01:38 +00:00
Alexander Wilms
02e429e973 Fix typos using https://github.com/crate-ci/typos
Changes were reviewed manually
2024-06-24 03:47:19 +02:00
Alexander Wilms
820b1b446e Fix typo: TowmPortalFinder -> TownPortalFinder 2024-06-23 22:40:15 +02:00
Ivan Savenko
3bea383b59 Merge branch 'vcmi/beta' into 'vcmi/develop' 2024-06-21 12:58:36 +00:00
Ivan Savenko
0e4be8c776 Fix crash on sieging Citadel or Castle 2024-06-19 19:59:06 +00:00
Ivan Savenko
a9cf322f61
Merge pull request #4161 from vcmi/fix-4142
#4142 - sometimes Battle AI wants to attack unit which is behind a lo…
2024-06-19 21:28:58 +03:00
Andrii Danylchenko
fc32078a3a #4142 - sometimes Battle AI wants to attack unit which is behind a lot of obstackles and other units 2024-06-18 20:03:07 +03:00