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

1974 Commits

Author SHA1 Message Date
Andrii Danylchenko
da46d5d01b BattleAI: take into account defender dragon breath and other mutitarget attacks 2024-07-22 20:39:33 +03:00
Andrii Danylchenko
4e83deca92 BattleAI: fix waited attack calculation 2024-07-22 20:39:33 +03:00
Andrii Danylchenko
33e0eeaa8a BattleAI: fix dragon breath 2024-07-22 20:39:32 +03:00
Ivan Savenko
37cf788079
Merge pull request #4317 from IvanSavenko/split_townhandler
Split CTownHandler into smaller chunks
2024-07-22 17:42:48 +03:00
Ivan Savenko
4aa73b40c9 Split CTownHandler into smaller chunks 2024-07-21 18:21:48 +00:00
Xilmi
6f9309696d Merge remote-tracking branch 'upstream/develop' into develop 2024-07-21 19:06:14 +02:00
Andrii Danylchenko
683c363946 NKAI: whirlpool 2024-07-21 17:20:54 +03:00
Ivan Savenko
550540f8ab
Merge pull request #4316 from IvanSavenko/crashfixes
Crashfixes
2024-07-21 16:15:28 +03:00
Xilmi
945de7c369 More warnings
Removed unused code
2024-07-20 21:12:43 +02:00
Xilmi
ed82e2bf4a Warnings
Removed unused variable.
2024-07-20 21:02:39 +02:00
Ivan Savenko
1c522c49b6 Fix possible crash on trying to move to invalid battlefield hexes 2024-07-20 18:28:13 +00:00
Ivan Savenko
1aa391fdf8 Split CGeneralTextHandler file into 1 file per class form
All text processing code is now located in lib/texts.
No changes other than code being moved around and adjustment of includes

Moved without changes:
Languages.h           -> texts/Languages.h
MetaString.*          -> texts/MetaString.*
TextOperations.*      -> texts/TextOperations.*

Split into parts:
CGeneralTextHandler.* -> texts/CGeneralTextHandler.*
                      -> texts/CLegacyConfigParser.*
                      -> texts/TextLocalizationContainer.*
                      -> texts/TextIdentifier.h
2024-07-20 12:55:17 +00:00
Xilmi
2bf7b3200b Merge remote-tracking branch 'upstream/develop' into develop 2024-07-19 22:05:58 +02:00
Andrii Danylchenko
3502e30fe5
Merge pull request #4296 from vcmi/build-take-into-account-7lvl-creatures
NKAI: take into account 7lvl creature cost when we consider what reso…
2024-07-19 21:34:25 +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
Xilmi
e374f24016 complete Building-costs as evaluation-context
Added building-cost including all resoruces as evaluation-context for more sophisticated building-selection and also as a countermeasure to softlocking a build-order by having no ways to obtain certain resources.
For example, if the AI would drop below 5 wood, while having no market-place and no wood-income it will avoid building any buildings that neither allow trading nor produce wood.
2024-07-19 15:25:24 +02:00
Xilmi
2d715f4d7e Trading logic
Added trading-logic to Nullkiller-AI.
The AI can now identify which resources it is lacking the most and buy them to fix softlocks in their build-order. It can also sell excess resources that it doesn't have a need for.
2024-07-19 15:21:56 +02:00
Xilmi
f094bf9602 Added marketplace to buildable buildings
Before marketplaces could only be built as part of a requirement for other buildings but not on their own when that other building already existed like it is the case in certain campaign-missions.
2024-07-19 15:19:27 +02:00
Xilmi
9c6d8762c5 Lowered restrictions from hero-hiring.
Removed two restrictions from hero-hiring, that prevented AI from hiring heros in certain scenarios.
2024-07-19 15:18:02 +02:00
Ivan Savenko
2020d96070
Merge pull request #4071 from IvanSavenko/fix_rng_syncronization
[1.6] Fix potential desync if client uses different stdlib with different random number generators
2024-07-19 13:08:09 +03:00
Andrii Danylchenko
e9e5948d61 NKAI: take into account 7lvl creature cost when we consider what resources we need 2024-07-18 20:24:24 +03:00
Andrii Danylchenko
37dc2a38e8 NKAI: reduce double army loss cases 2024-07-18 13:38:25 +03:00
Andrii Danylchenko
7571fb7046 NKAI: fix gosolo when human is lead by gosolo AI + multiplayer 2024-07-17 17:09:04 +03:00
Ivan Savenko
1072356002
Merge pull request #4268 from IvanSavenko/pathnode_reduce
Reduce size of CGPathNode and AIPathNode
2024-07-17 13:08:05 +03:00
Ivan Savenko
63bcf7d83c Replaced most of usages of CRandomGenerator with vstd::RNG in library 2024-07-16 13:13:07 +00:00
Ivan Savenko
60a51e98de Remove usage of std::function from CRandomGenerator 2024-07-16 13:13:07 +00:00
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
Ivan Savenko
04a81fee87 Reduce size of CGPathNode and AIPathNode 2024-07-15 07:49:04 +00: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
Ivan Savenko
8e68c7dcd8
Merge pull request #4144 from vcmi/fix-4139
#4139 - attempt to fix crash on portal probbing
2024-06-18 12:07:24 +03:00
Ivan Savenko
b7efa6c8cc Fixed potential thread races in Battle AI 2024-06-17 16:15:19 +00:00
Ivan Savenko
431b2865a4 Review fixes 2024-06-17 09:43:22 +00:00
Andrii Danylchenko
cd4aaf93ee #4139 - attempt to fix crash on portal probbing 2024-06-16 11:58:15 +03:00
Ivan Savenko
e699941a39 Disable logic that seems to be leading to thread races 2024-06-12 18:17:23 +00:00
Ivan Savenko
e32b6bd807 Fix potentially uninitialized members 2024-06-12 18:10:38 +00:00
Ivan Savenko
b4c6906471 Merge branch 'vcmi/beta' into 'vcmi/develop' 2024-06-11 19:22:23 +00:00
Ivan Savenko
9c05e80315 Fix Admiral's Hat whirlpool immunity. Reduce usage of
convertFromVisitablePos
2024-06-11 14:31:11 +00:00
Ivan Savenko
b8beb4fb13 Fixes for various minor issues detected by Sonar Cloud 2024-06-01 11:48:30 +00:00
Andrii Danylchenko
7bf047ff18 #4066 - fix exploration 2024-06-01 13:13:51 +03:00
Andrii Danylchenko
9728413742 NKAI: fix dead end cancellation 2024-06-01 12:25:23 +03:00
Ivan Savenko
df83fa33a1 Merge branch 'vcmi/master' into 'vcmi/develop' 2024-05-31 09:34:21 +00:00
Ivan Savenko
5d6470e527
Merge pull request #4025 from IvanSavenko/shared_ptr_lib
[1.6] Use shared_ptr for library entities
2024-05-30 19:14:06 +03:00
Ivan Savenko
5ecb527252
Merge pull request #3997 from IvanSavenko/serialization_refactor
[1.6] Serialization refactor
2024-05-30 19:13:21 +03:00
Andrii Danylchenko
02ea497951 NKAI: speedup exploration a bit 2024-05-22 22:49:11 +03:00
Andrii Danylchenko
820f0e0c1a NKAI: port exploration from VCAI 2024-05-20 23:50:13 +03:00
Andrii Danylchenko
5b7e355953
Merge pull request #4009 from vcmi/nkai-exploration
NKAI: port exploration from VCAI
2024-05-20 23:44:12 +03:00
Andrii Danylchenko
1388fb1493 NKAI: port exploration from VCAI 2024-05-20 22:43:23 +03:00
Ivan Savenko
ffe14fc1fc
Merge pull request #4022 from vcmi/master
Merge master -> beta
2024-05-20 18:09:51 +03:00
Ivan Savenko
8931121d2e
Merge pull request #3995 from IvanSavenko/old_projects_remove
[1.6] Remove old project files
2024-05-19 15:44:32 +03:00
Ivan Savenko
9bfe000724 Added semi-workaround method for network thread shutdown:
Currently closing game while network thread is waiting for something is
very bug-prone, since network thread may resume during shutdown and
access partially destroyed client state.

Now if exit has been requested, the very first step would be semi-
graceful shutdown of network thread (via exception throwing). This may
in theory skip some cleanup in non-RAII code, but since game is shutting
down this does not matters much.

This logic applies to:
- shutting down while network thread is waiting for dialogs
- shuttind down while network thread waiting for animations in combat
2024-05-18 11:04:10 +00:00
Ivan Savenko
f3de2cfe1c Removed broken & unused serialization of player interface and AI 2024-05-17 16:35:53 +00:00
Ivan Savenko
7461df161c lib now uses shared_ptr for entities. Removed manual memory management. 2024-05-17 15:04:05 +00:00
Ivan Savenko
eb67e04ccb Remove old and unmaintained codeblocks project 2024-05-17 10:44:57 +00:00
Ivan Savenko
3f6eb13ee0 Delete old and unmaintained msvc project files 2024-05-17 10:44:11 +00:00
Ivan Savenko
cba49a9952 Fix gcc-14 build 2024-05-17 10:10:06 +00:00
Ivan Savenko
721b15d9de Merge branch 'vcmi/master' into 'vcmi/develop' 2024-05-17 08:26:37 +00:00
Ivan Savenko
84bc6c42db Added 'Serializeable' base class for classes serializeable by pointer 2024-05-16 18:40:59 +00:00
Laserlicht
560923fc1f
show cheating problem message only once per AI 2024-05-15 12:50:51 +02:00
Laserlicht
e9b2159c0a
hint about disabled cheats for nullkiller 2024-05-15 00:18:14 +02:00
DjWarmonger
560d53a07c
Merge pull request #3960 from vcmi/fix-3941
#3941 - recruit hero when no heroes
2024-05-13 11:30:11 +02:00
Andrii Danylchenko
98afd43969 #3941 - recruit hero when no heroes 2024-05-12 21:10:31 +03:00
Andrii Danylchenko
98a78b3386 #3930 - fix usage of wrong variable 2024-05-12 18:04:23 +03:00
Ivan Savenko
30e0a16ee9 Fix some 'new' issues reported by Sonar Cloud 2024-05-06 15:33:30 +00:00
Andrii Danylchenko
157443c1df #3876 - allow to embark after battle for AI pathfinder 2024-05-05 13:52:57 +03:00
Ivan Savenko
be54836401
Merge pull request #3849 from IvanSavenko/fix_vcai_crash
Fix possible crash on AI attempting to build building in town
2024-04-28 19:48:23 +03:00
Ivan Savenko
8fa615a8f7 Fix possible crash on AI attempting to build building in town 2024-04-28 12:53:10 +03:00
Andrii Danylchenko
f1d7151a93 #3842 - fix negative link cost because of bonuses 2024-04-28 09:11:15 +03:00
Andrii Danylchenko
39e19f79f4 Fix #3754, #2316 2024-04-27 13:57:50 +03:00
Andrii Danylchenko
afa766c763 #3824 - fix cluster unlock 2024-04-27 10:57:30 +03:00
Andrii Danylchenko
6e641dbdea #3824 - fix empty army with only commander issues 2024-04-26 23:18:20 +03:00
Andrii Danylchenko
b4abb3a56c
Merge pull request #3814 from vcmi/fixes
NKAI: fix patrolling heroes never retreat and town danger evaluation
2024-04-23 18:52:47 +03:00
Ivan Savenko
62d15ed23c
Merge pull request #3820 from IvanSavenko/bugfixing
Bugfixing
2024-04-23 13:03:36 +03:00
Ivan Savenko
1b6d6c3f5e Disable broken visitation of external markets for VCAI 2024-04-22 15:46:51 +03:00
Ivan Savenko
a6dead7725 Fixed loading of text strings for hota quests 2024-04-22 13:49:17 +03:00
Ivan Savenko
a46e022421 Fixed format string 2024-04-22 13:48:56 +03:00
Ivan Savenko
438ec08d72 AI will only ignore garrisons in 'Steadwick Fall' mission (H3 logic) 2024-04-22 11:14:58 +03:00
Ivan Savenko
e8e4446886 Simplify NKAI settings loading code 2024-04-22 11:14:58 +03:00
Ivan Savenko
20f323d83c Added 'useTroopsFromGarrisons' option to NKAI 2024-04-22 11:14:57 +03:00
Ivan Savenko
21dff9413e
Merge pull request #3786 from IvanSavenko/instant_movement
Instant movement
2024-04-22 11:08:00 +03:00
Ivan Savenko
1b469036a3
Merge pull request #3784 from dydzio0614/quick-dwellings-visit
Add handling for yes/no dialogs that can be safely skipped by player
2024-04-22 11:06:40 +03:00
Andrii Danylchenko
390136e536 NKAI: fix patrolling heroes never retreat and town danger evaluation 2024-04-21 14:23:58 +03:00
Andrii Danylchenko
7aff0e63fc NKAI: fix parallel access to object graph 2024-04-21 12:27:58 +03:00
Andrii Danylchenko
0935f931fa BattleAI: fix bypassing 2-hex moat 2024-04-20 15:28:57 +03:00
Andrii Danylchenko
70fad45316
Merge pull request #3770 from vcmi/nkai-multitask
NKAI: allow multiple tasks to be executed from one calculation
2024-04-20 15:21:11 +03:00
Andrii Danylchenko
3939c4b9d3 NKAI: stability fixes and regression 2024-04-20 14:32:58 +03:00
Ivan Savenko
d5a2ad1be8 Allow sending requests to move across multiple tiles at once 2024-04-20 12:28:50 +03:00
Andrii Danylchenko
50432b9614
Merge pull request #3782 from Alexander-Wilms/typo
Fix typo: preasure -> pressure
2024-04-18 13:19:12 +03:00
Dydzio
19453aab41 Add handling for yes/no dialogs that can be safely skipped by player 2024-04-17 01:08:27 +02:00
Alexander Wilms
e70411bf1a Fix typo: preasure -> pressure 2024-04-16 21:10:49 +00:00
Alexander Wilms
7d925b3689 Fix typo: Preasure -> Pressure 2024-04-16 21:10:15 +00:00
Ivan Savenko
ced0bbe526 Remove "catch everything and silently ignore" block 2024-04-16 18:54:51 +03:00
Andrii Danylchenko
ed76d8a652 NKAI: allow multiple tasks to be executed from one calculation 2024-04-14 16:46:05 +03:00
Ivan Savenko
9e49587749 Replace bonus string description with metastring that can properly
handle translations
2024-04-09 16:13:30 +03:00
Ivan Savenko
03786fb63b VCAI will now check whether it actually has enough gold to buy a hero 2024-04-06 15:59:08 +03:00
Andrii Danylchenko
fd0dd7441a
Merge pull request #3700 from vcmi/object-graph
NKAI: parallel capture objects
2024-04-01 12:59:08 +03:00
Andrii Danylchenko
728f673763 NKAI: remove static ai field 2024-03-31 21:11:25 +03:00
Andrii Danylchenko
ca7c91e766
Merge pull request #3677 from vcmi/object-graph
Object graph
2024-03-29 20:39:56 +02:00
Andrii Danylchenko
d6f1a5c2b3 NKAI: parallel capture objects 2024-03-29 20:39:03 +02:00
Evgeny Malygin
25125f96da
Fix: licenses, pragma guards, StdInc 2024-03-29 07:48:52 +02:00
Andrii Danylchenko
ff654c2148 NKAI: fix build 2024-03-28 17:47:08 +02:00
Andrii Danylchenko
30d9daf62c NKAI: improve boat handling by object graph, a set of fixes 2024-03-28 13:39:15 +02:00
Andrii Danylchenko
adfcb650e2 NKAI: object graph fixes 2024-03-25 21:04:08 +02:00
Andrii Danylchenko
3820f6f78b NKAI: fix headless and compilation 2024-03-24 13:16:46 +02:00
Andrii Danylchenko
419d6a648b NKAI: optimize clusterization and pathfinding for object graph 2024-03-24 09:32:54 +02:00
Andrii Danylchenko
017fb204a1 NKAI: remove 5th dimension 2024-03-24 09:32:54 +02:00
Andrii Danylchenko
e66ceff154 NKAI: object graph improved and optimized 2024-03-21 12:13:36 +02:00
Andrii Danylchenko
bec2c0cac2 NKAI: fix sonar and refactoring 2024-03-10 15:14:15 +02:00
Andrii Danylchenko
6245adb9a4 NKAI: configurable object graph 2024-03-08 14:39:16 +02:00
Andrii Danylchenko
5f8a157c6d NKAI: rollback changes with removing scan depth 2024-03-03 10:21:17 +02:00
Andrii Danylchenko
fb6fd63a58 NKAI: water paths in graph 2024-03-02 15:55:36 +02:00
Andrii Danylchenko
b236384356 NKAI: graph add battle layer 2024-03-02 15:54:05 +02:00
Andrii Danylchenko
a090441672 NKAI: object graph second layer not operational yet 2024-03-02 15:54:03 +02:00
Andrii Danylchenko
376a17409f NKAI: initial implementation of object graph 2024-03-02 15:52:45 +02:00
Andrii Danylchenko
35429eab52 NKAI: moddable configuration 2024-03-01 22:03:07 +02:00
Alexander Wilms
2ea78a5883 Fix float comparisons
Replace this "==" with a more tolerant comparison operation.
Floating point numbers should not be tested for equality cpp:S1244
2024-02-14 23:30:29 +01:00
Ivan Savenko
c23953eac5 Remove custom casts 2024-02-14 12:56:37 +02:00
Ivan Savenko
45c971a405 Replace throws() with nothrow 2024-02-14 12:07:07 +02:00
Ivan Savenko
7359b66f99 Do not use floating point equality checks 2024-02-14 12:07:07 +02:00
Ivan Savenko
9ebd194ab1
Merge pull request #3609 from IvanSavenko/single_process
Allow running server as part of client process
2024-02-14 12:06:22 +02:00
Alexander Wilms
678cacbd25 Remove more redundant virtual specifiers
`grep -nr "virtual " | grep -v googletest | grep " override" | grep -v overriden > ../redundant_virtual.txt`

```python
import os

with open("../redundant_virtual.txt") as f:
    for line in f:
        print()
        line: str = line.strip()
        print(line)
        tmp = line.split(":",2)
        file = tmp[0].strip()
        code = tmp[-1].strip()
        print(file)
        print(code)
        new_code = code.replace("virtual ", "", 1)
        # https://superuser.com/a/802490/578501
        command = f"export FIND='{code}' && export REPLACE='{new_code}' && ruby -p -i -e \"gsub(ENV['FIND'], ENV['REPLACE'])\" {file}"
        os.system(command)
```
2024-02-13 15:21:30 +01:00
Ivan Savenko
4c70abbeb5 Reduced usage of global variables - removed or made const / constexpr 2024-02-12 13:49:45 +02:00
Ivan Savenko
c03196257f Fix "identical expressions on both sides of comparison" 2024-02-12 12:32:35 +02:00
Ivan Savenko
c577ea3e8d Fix potentially uninitialized values 2024-02-12 12:31:27 +02:00
Ivan Savenko
a909d7ddde Removed cmake_modules/VCMI_lib macro, use it directly in place 2024-02-11 20:38:24 +02:00
Ivan Savenko
f08c9f4d59 Renamed ENABLE_STATIC_AI_LIBS option to match its actual effect 2024-02-11 17:55:02 +02:00
Alexander Wilms
522cb571b3 Remove redundant virtual specifiers
`grep -nr virtual | grep -v googletest | grep override > ../redundant_virtual.txt`

```python
import os

with open("../redundant_virtual.txt") as f:
    for line in f:
        print()
        line: str = line.strip()
        print(line)
        tmp = line.split(":")
        file = tmp[0].strip()
        code = tmp[-1].strip()
        print(file)
        print(code)
        new_code = code.replace("virtual ", "", 1)
        # https://superuser.com/a/802490/578501
        command = f"export FIND='{code}' && export REPLACE='{new_code}' && ruby -p -i -e \"gsub(ENV['FIND'], ENV['REPLACE'])\" {file}"
        os.system(command)
```
2024-02-10 20:46:13 +01:00
Andrii Danylchenko
ec5c44bb92
Merge pull request #3594 from vcmi/fix-3550
#3550 - fix case when unit is in reachability map but only next turn
2024-02-04 10:07:44 +02:00
Andrii Danylchenko
c66de29550 #3550 - fix case when unit is in reachability map but only next turn 2024-02-03 17:48:52 +02:00
Ivan Savenko
f329bfbe71
Merge pull request #3582 from IvanSavenko/campaign_fixes
Campaign fixes
2024-02-01 11:30:38 +02:00
Ivan Savenko
626087ab14
Merge pull request #3561 from MnHebi/develop
Try to improve VCAI building build order
2024-01-31 21:48:36 +02:00
Ivan Savenko
2e4895766a Implemented tracking of objects destroyed by players 2024-01-31 01:37:33 +02:00
Ivan Savenko
a9866bb5c6 Added RandomGeneratorUtil::nextItemWeighted convenience method 2024-01-31 00:17:40 +02:00
MnHebi
8b24b0e9a7 Add Marketplace, Blacksmith into extra buildings category to ensure they get built. Misc changes. 2024-01-26 00:56:36 +02:00
Laserlicht
7f58333ef9
quick combat vs ai 2024-01-25 23:44:41 +01:00
MnHebi
4318b25399
Merge branch 'vcmi:develop' into develop 2024-01-25 21:27:06 +02:00
Ivan Savenko
2a193effcc Merge branch 'master' into 'develop' 2024-01-25 16:23:13 +02:00
MnHebi
a668dc2721 Try to improve VCAI building build order. Testing reveals extra structures still get done before intended build order(seen Market being built when Dwellings were expected). 2024-01-25 03:26:42 +02:00
Ivan Savenko
284273379e
Merge pull request #3536 from IvanSavenko/serialization_refactor
Refactoring of serialization versioning handling
2024-01-22 19:49:24 +02:00
Andrii Danylchenko
bf54a6a7d3
Merge pull request #3537 from vcmi/nkai-fix-pathfinder-commited-tiles
NKAI: avoid writing to commited tiles when calculating hero chain
2024-01-21 14:51:33 +02:00
Andrii Danylchenko
708e0d1107 NKAI: avoid writing to commited tiles when calculating hero chain 2024-01-21 10:18:39 +02:00
Andrii Danylchenko
cb297793e0 NKAI: fix lock 2024-01-21 10:05:40 +02:00
Andrii Danylchenko
0c1664dbe7 NKAI: various AI fixes after tests in headless 2024-01-20 22:55:30 +02:00
Andrii Danylchenko
1db43a509e NKAI: fix casting FLY several times during path calculation 2024-01-20 22:55:28 +02:00
Andrii Danylchenko
36bc9ddcec NKAI: mutex for internal AI state 2024-01-20 22:55:27 +02:00
Andrii Danylchenko
cc7fc4a2c6 Fix headless mode 2024-01-20 22:55:27 +02:00
Ivan Savenko
0c07384293 Refactoring of serialization versioning handling
- Removed 'version' field from serialize() method
- Handler classes - Binary(De)Serializer now have 'version' field
- Serialization versioning now uses named enum

Save compatibility with 1.4.X saves should be intact
2024-01-20 20:34:51 +02:00
Ivan Savenko
62935b4ba4 Fix crash on using StupidAI for player actions 2024-01-20 17:15:51 +02:00
Ivan Savenko
d04241b10a Code cleanup 2024-01-19 23:02:00 +02:00
Ivan Savenko
ea1f05d15a Stabilization 2024-01-19 13:55:22 +02:00
Ivan Savenko
60ffb81b33 Replaced remaining placeholder code with callbacks 2024-01-19 13:55:22 +02:00
Ivan Savenko
a15366f5a5 Make IObjectInterface::cb non-static 2024-01-19 13:55:21 +02:00
Ivan Savenko
2c4cad7d9c Slight simplification of bonus system node class 2024-01-19 13:54:49 +02:00
Ivan Savenko
d5c4478816 Remove most of non-const access to VLC entities 2024-01-19 13:54:49 +02:00
Ivan Savenko
bd5682ecc3 Merge remote-tracking branch 'vcmi/master' into develop 2024-01-19 13:49:54 +02:00
Alexander Wilms
73019c204d Replace redundant types with auto for the lvalues of template factory functions for smart pointers
grep -r --include \*.h --include \*.cpp "= std::" * | grep -v auto | grep -Po ".*[^ ]+ [^ ]+ [^ ]*[ ]*=.*;" | grep -v "auto\|int\|char\|bool\|float|\double\|for\|if\|googletest\|fuzzylite\|size_t\|using\|return" | grep -v double | grep -v si64 | grep -v si32 | grep -v ui32 | grep \< | grep -v float | tr -d '\t' | grep -v assert > redundant_types.txt

import re

with open("redundant_types.txt") as f:
    for line in f:
        line = line.strip()
        path = line.split(":", 1)[0]
        original_code = ":".join(line.split(":")[1:]).strip()

        print()
        print(path)
        print(original_code)
        prefix = "auto "
        if original_code.startswith("static"):
            static = True
        else:
            static = False

        cpp_type = " ".join(original_code.split("=")[0].strip().split(" ")[0:-1])
        print(cpp_type)

        if static:
            new_code = "static auto "+ " ".join(original_code.split(" ")[2:])
        else:
            new_code = "auto "+ " ".join(original_code.split(" ")[1:])
        print(new_code)

        if True:
            with open(path, "r") as f:
                filedata = f.read()

            filedata = filedata.replace(original_code, new_code)

            with open(path, "w") as f:
                f.write(filedata)
2024-01-17 12:50:00 +00:00
Ivan Savenko
e849e4170a
Merge pull request #3486 from Alexander-Wilms/replace-redundant-types-with-auto
Replace redundant types with `auto`
2024-01-17 13:31:05 +02:00
Alexander Wilms
1b85abb508 Use auto instead of redundant type in initializations using new
grep -r --include \*.h --include \*.cpp "=" * | grep -v "auto\|int\|char\|bool\|float|\double\|for\|if\|googletest\|fuzzylite\|size_t\|using\|return\|{\|}\|= \"\|= tr(\|virtual\|void" | grep -Po ".*[^ ]+ [^ ]+ [^ ]*[ ]*=.*;" | grep -v "float\|nullptr" | grep "new" | grep -v "AI/FuzzyLite" | grep \( | grep "= new" > redundant_types.txt

import re

with open("redundant_types.txt") as f:
    for line in f:
        line = line.strip()
        path = line.split(":", 1)[0]
        original_code = line.split(":")[1].strip()
        if "new " in original_code:

            cpp_type = original_code.split(" ")[0]
            if original_code.count(cpp_type) == 2:
                print()
                print(path)
                print(original_code)
                new_code = "auto "+" ".join(original_code.split(" ")[1:])
                print(new_code)

                with open(path, "r") as f:
                    filedata = f.read()

                filedata = filedata.replace(original_code, new_code)

                with open(path, "w") as f:
                    f.write(filedata)
2024-01-16 21:40:53 +00:00
Alexander Wilms
cca08e29da Remove duplicate semicolons 2024-01-16 19:02:39 +00:00
Ivan Savenko
a582cb554e
Merge pull request #3500 from IvanSavenko/fix_dendroid_bind
[1.4.3] Fix handling of Dendroid's Bind ability
2024-01-15 12:02:06 +02:00
Ivan Savenko
b4a1a755a4
Merge pull request #3498 from IvanSavenko/simturns_pathfinder
[1.4.3] Fixes for simultaneous turns
2024-01-15 12:00:54 +02:00
Ivan Savenko
0d0d3d8c80 Renamed speed -> getMovementRange, remove misleading default parameter 2024-01-14 17:14:36 +02:00
Alexander Wilms
bc781c28e0 Remove trailing semicolon from NET_EVENT_HANDLER macro 2024-01-14 14:49:25 +00:00
Andrii Danylchenko
3602be5eab BattleAI: remove adjustPositions method as it gives more troubles than usefulness 2024-01-14 10:23:44 +02:00
Ivan Savenko
8303ce5d13 Added option to ignore guards in pathfinder
Used for simturns contact detection, by default disabled for player
pathfinding
2024-01-13 19:44:37 +02:00
Alexander Wilms
f3277b7953 Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
Andrii Danylchenko
1a1ae5cd8b BattleAI: fixes 2024-01-02 17:35:10 +02:00
Joakim Thorén
daf9f9f7f5
Re-add const that was erronously removed with 88ec4fa
Co-authored-by: Andrey Filipenkov <kambaladecapitator@gmail.com>
2023-12-30 11:01:21 +01:00
Joakim Thorén
88ec4fa0e7 Use getTileThreat-helper instead of directly accessing hitMap with tile coordinates 2023-12-29 23:12:06 +01:00
Joakim Thorén
61314a36f6 Fix copy-paste mistake 2023-12-27 22:35:43 +01:00
Joakim Thorén
406d136cdc Fixes warnings about possibly dangling references 2023-12-27 22:24:58 +01:00
Ivan Savenko
85de3143ff Fixed Genie spellcasting logic to account for spell immunities 2023-12-24 01:13:19 +02:00
Dydzio
fe39faf36c Add UNTIL_OWN_ATTACK bonus duration and use for berserk 2023-12-19 19:52:40 +01:00
Andrii Danylchenko
26b6d1cf74 NKAI: fix capturing shipyards 2023-12-02 14:03:54 +02:00
Ivan Savenko
d326c53b9a AI will now respect current value of "Use spells in autocombat" setting 2023-11-28 15:48:35 +02:00
Ivan Savenko
60ca6f968c Fix hero limit check in AI 2023-11-27 14:08:49 +02:00
Ivan Savenko
ff6260e5c5
Merge pull request #3195 from IvanSavenko/identifier_string_serialization
Serialize Identifiers that can be added by mods as strings
2023-11-20 14:07:24 +02:00
Ivan Savenko
b58301849b Pass functor via reference to avoid costly copies 2023-11-18 19:43:11 +02:00
Ivan Savenko
9b8145f522 Compute creature speed only once during evaluation 2023-11-18 19:41:29 +02:00
Ivan Savenko
9f906ff1d2 Remove pointer to CGObjectInstance from map header 2023-11-17 16:39:15 +02:00
Ivan Savenko
76956cfe3a
Merge pull request #3188 from IvanSavenko/remove_identifier_implicit_int_conversion2
Remove implicit conversion of identifier to integer
2023-11-16 17:26:32 +02:00
Ivan Savenko
52050d0ef1 Fix build 2023-11-15 15:55:19 +02:00
Ivan Savenko
96c81be68e Win/loss conditions now use VariantIdentifier. Removed non-implemented
options
2023-11-15 15:55:19 +02:00
Ivan Savenko
20ef3a69e7 Fix most of memleaks discovered by valgrind 2023-11-13 16:27:15 +02:00
Ivan Savenko
4a7fa9bf8c Simplified CTypeList class 2023-11-08 22:05:36 +02:00
Ivan Savenko
6b81012f31 Use variant identifier in netpacks where applicable 2023-11-08 14:00:23 +02:00
Ivan Savenko
10e50548e7 Converted Component class to use VariantIdentifier instead of int 2023-11-02 12:00:04 +02:00
Ivan Savenko
8346d71c98 Remove more subID access 2023-11-01 14:44:05 +02:00
Ivan Savenko
7107b3202f
Merge pull request #3069 from SoundSSGood/artifact-location-id
ArtifactLocation now use ID for artHolder identification
2023-11-01 14:41:36 +02:00
SoundSSGood
ab2f6abb87 ArtifactLocation now use ID for artHolder identification part2 2023-10-29 17:46:13 +02:00
SoundSSGood
61fc236d79 ArtifactLocation now use ID for artHolder identification part1 2023-10-29 17:46:13 +02:00
Alexander Wilms
5cbc75d3b7 Merge remote-tracking branch 'upstream/develop' into develop 2023-10-29 13:35:37 +00:00
Alexander Wilms
ed86a917eb AI/BattleAI/BattleAI.cpp: Use Class template argument deduction for wallParts array
Co-authored-by: Ivan Savenko <saven.ivan@gmail.com>
2023-10-29 13:34:19 +00:00
Alexander Wilms
0232ae5327 AI/BattleAI/BattleEvaluator.cpp: Convert this integer literal to a bool literal.
Integer literals should not be cast to bool
2023-10-29 13:34:19 +00:00
Alexander Wilms
bfddc90ff4 AI/BattleAI.cpp: Use "std::array" or "std::vector" instead of a C-style array.
Variables of array type should not be declared cpp:M23_356
2023-10-29 13:34:19 +00:00
Ivan Savenko
0169c65937
Merge pull request #3100 from IvanSavenko/split_net_packs
Split netpacks.h into multiple files
2023-10-29 13:46:40 +02:00
Alexander Wilms
0a6c82c639 AI/Nullkiller/Behaviors/DefenceBehavior.{h,cpp}: treat -> threat 2023-10-27 23:34:11 +00:00
Alexander Wilms
457e73ed12 AI/BattleAI/BattleExchangeVariant.cpp: Do not assign data members in a constructor. Initialize members in an initialization list.
Member data should be initialized in-class or in a constructor initialization list
2023-10-27 23:34:11 +00:00
Alexander Wilms
b10b1a5444 AI/BattleAI/BattleExchangeVariant.cpp: This function should be declared "const".
Member functions that don't mutate their objects should be declared "const"
2023-10-27 23:34:11 +00:00
Alexander Wilms
af330ff038 AI/BattleAI/BattleEvaluator.cpp: Remove this redundant cast.
Redundant casts should not be used
2023-10-27 18:19:17 +00:00
Alexander Wilms
f01ec55d21 Use the "nullptr" literal.
"nullptr" should be used to denote the null pointer
2023-10-27 18:18:59 +00:00