An On-Algortihm has refers to an algorithm which does not just receive an input and calculates the fitting output (eg. Input: Goal, Output: Plan) but rather continously reads inputs and reacts with outputs.
That is, we do not directly formulate our plan and instead perform the search “live”. We use a stack containing the objectives to be achieved and start from the current position and introduce the goal objective. The inital goal objective will be requested from the Behavior Model to gibve the AI goals which are conformant with its behavioral parameters. Then in each time step we do the following:
Note that using a stack for achieving our objectives limits the planning capabilities. In traditional partial-order planning achieving a state of the form “Goal A AND Goal B” is complicated because we cant just first achieve Goal A and then Goal B. After all, we may no longer satisfy goal A after achieving Goal B.
This is why we need to be critical when introducing new sub objectives or executing an action to achieve a sub objective. We must always inquire the entire stack if this new objective/action is conformant with all lower objectives.
The following example demonstrates how the AI may reason with this kind of approach and how the interaction between the Planning Model and the Behavior Model looks like.
The AI attempts to formulate a plan to expand its number of holdings, however, while trying to make money to stock up the troops, it realized that it cannot realize the goal and eventually the objective times out.
From here on the AI must reevaluate whether the objective to expand the army should still be pursued or if it should be popped from the stack. Fo example, the target X may have by now lost troops due to another war and a declaration of war at this point of time might befeasable.
I want to write a bit about the AI in Sword&Scrolls, so here we go.
When tackling AI for systems involving different aspects such as warfare, diplomacy and management it can be hard to even figure out where to start. So for anybody interested and working on his own strategy game AI, I wanted to provide some insight into how the AI in Sword&Scroll is built and operates.
The starting point is, as always with complex systems, to divide the problem into smaller sub problems and solve these independently and then add interaction at a later point.
The AI of Sword&Scroll consists of several Models (also called agents in the literature). A model is nothing but one component of the AI system dedicated to solving one sub problem. Models may be request information from other models and ask them to solve something for them. In the terminology of traditional AI a construct like this is called multi-agent-system.
Sword&Sword uses 3 models to drive the behavior of the AI.
If you have ever worked on a tactical RPG or some of these consorts you will probably also have used an approach entailing the models 2. and 3. Therefore today I would like to go more into depth regarding the Planning Model.
Lets start of with a very basic question. What is planning?
Planning involves finding a sequence of actions to satisfy a given goal from a given state.
Examples for some goals may be:
Typically, planning is done in a sort of backtrack search. We start with the goal state and introduce intermediate goals we can achieve via some action until we have found a valid plan.
In Sword&Scroll I want to have many agents. But in each iteration there are several possible actions (building something, sending diplomats, asking for marriage, etc) and to make matters worse most of them have parameters. For example SendDiplomat(X) requires the parameter to whom we want to send a diplomat. This blows up the search space.
We therefore relax the planning problem. Instead of searching for completely specified actions to reach our main goal we dont care about the exact parameters. Instead, we ask the Behavior Model to provide us for any given action the parameters which it thinks suit the AI behavior the most and would be profitable for it.
This approach still leaves two big problem:
The second point is especial crucial as I dont want the game to just have 1 AI, but dozens and each having at least a certain degree of playing capabilities. In order to deal with these issues we further relax the Planning Problem.
summer->winter transition and back
we real politics now
My old machine kinda died and when I got a new laptop I kinda ended up realizing that I could play modern gaems on decent settings on it, so yea… I there went the dev time in the past week. Anyways, I’ve got my fill and heres some progress about implementing intrigues and also how I intend to continue on with this.
Intrigues work similarly as in CKII, you start a plot against some target (For example fabricating a claim on a holding from him) and then you look for supporters who want to support your plot.
If you ask somebody to help you with your plot he gains favor points over you. These points can be used in return to force you to support their plots later on (refusing to repay a favor hits your honor) or also to force you to lend them a loan (Currently there are no other uses, but I intend to add more things).
Each plot requires a certain amount of plot points (I seriously need some cooler names than X points later on) to be realized. These are gathered slowly over time and instantly by receiving supporters. The amount of plot points a House can contribute depends on their court power which reflects their influence on the House you wish to intrigue against. This influence can be increased by marriage, sending a diplomat, being a branch family, being the overlord and also by infiltrating the target House with a spy.
Fabricating claims and planting a spy in the target House are currently the two intrigues I implemented.
A spy enables you to see the military strength of the target House, what they are currently building and it makes it easier to perform intrigues. I will probably also introduce intrigues which are only possible when you have a spy. These are how things stand right now. Next let me talk on how I want to I currently plan to continue this (I say currently because I have revised this entire intrigue thingy dozens of times and I may do it again).
So what are the backdraws when inviting supporters? One thing is, as I mentioned, that they will gain favor over you which they can use against you. There will also be a diplomatic option to reveal a plot to the target House. There will be two ways which enable revealing a plot:
In the same way you will also be able to reveal spies. If a plot is revealed it will become more difficult to perform it. Revealed spies will be killed off.
If your plot has been revealed, you will be informed about it, but you will not necessarily know who revealed it. You will only be told who revealed your plot if you have a spy at the target House.
Well, that basically covers my plans for the spy business. I dont want to expand this game mechanic too much since this is not a spy infiltration game.
Sword & Scroll Windows, Linux, Android game
Its that time guys. Which one do you prefer?