|
I have a turn-based tactics game that is played in a persistent world and I would like to write AI for the NPCs. There are two scales that the game is currently played on: the World scale and the Field scale. Both the squad AI and the unit AI operate on the Field scale. (At some point there will be AI that operate on the World scale and up but that is outside the scope of this very long question.) At the moment the game plays a lot like chess, there are two sides and each player picks a unit to act, then the unit can target a tile or move to a tile. There are two categories of attacks, magical attacks and physical attacks. The magical attacks are area of effect and damage over time. The physical attacks are ranged and melee. Every unit has a primary element (suit), if a magical attack is of the same element as the unit attacked, the unit is healed using an inversion of what the damage would have been. Here is the code that determines this: https://bitbucket.org/a.f.dudley/binary-tactics/src/06f02072ba11/binary_tactics/hex_battlefield.py#cl-365 The NPCs are called Nescients. Player controlled units are called Scients. The AI would be for controlling Nescients regardless of if they are interacting with players or not. Currently, the plan is for them Forage, Fight and Mate. Everything in the world has a composition that is a set of 4 0-255 values: E, F, I, W. Units, have a primary element or suit. Depending on the unit type, the distribution of points within the values is constrained. Scients must have 0 points in the value opposite of their suit and a maximum of half (rounded down) the points of their suit can be in their orthogonal elements. A low-level Earth Scient would be {E:5, F:2, I:2 W:0} for example. Nescients are constrained such that points can only be distributed to their primary element and one orthogonal element such that the points in the orthogonal element are always less than the points in the primary. A low-level Earth Nescient would be {E:5, F:4, I:0, W:0}. Magic defense, magic attack, physical defense and physical attack are determined by I, W, E, and F respectively. (A full description of unit attributes can be found here: https://bitbucket.org/a.f.dudley/binary-tactics/src/06f02072ba11/binary_tactics/units.py#cl-25 ) I want the composition (and its value) to play a key role in the behavior of units. For example, I want Nescients to have a positive affinity for units of the same suit, a neutral affinity for units of orthogonal suits and a negative affinity for units of opposite suits. The same goes for eating. Also it seems reasonable that E and I units would be less aggressive than W and F units and more aggressive units would be more likely to eat (attack) neutral units. There will need to be some more thought given to how the Fields treat groups of Nescients when there is no player on the field... one of the problems that is important to AI design that I am leaving out is how turns may change in the future. Without being too digressive, one of the key elements of Yasumi Matsuno's battle systems is the use of an action timer. I feel as though this is what sets tactics game apart from more traditional turn-based board games. But for complexity reasons I do not plan on having action timers in the alpha version of the code. Thus in the current model two Nescients "fill" a Field. That way they can take turns as two players would, which is written and (mostly!) working. In idealized game play there can be up to 4 Nescients in player controlled squads and as many Nescients in a NPC field as it can hold. What the Nescients sense of the world is the value (the sum of all the points in a composition) of a unit and some vagaries of the point distribution. If a unit strikes or is struck by another unit more information about their composition is revealed. (Sorry, this is still in the hand wavy stages, but should be addressed in AI design.) Given the above set of constrains my opinion is that braitenberg vehicles controlled by something like a GA/NN would be ideal for the Nescients and player-configurable GA-susceptible behavior trees would be ideal for the squad AI. Currently, I am writing the game in python with the intention of either using pypy or porting to C/C++ as required. Does the above seem like a reasonable course of action? is there an off-the-shelf player-configurable behavior tree system? Are there any recommendations for NN topographies? I have access to enough CPU to run games in the billions to train the AI and I am willing to wait for reasonable results. Any advice, pointers or coding assistance would be appreciated, thanks! |