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.
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.
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.
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.
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.
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.
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.
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.
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".
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.
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
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