Great ideas. Anyone up for coding it?
Form orderly queues, please...
LOL, An appeal to my dark side!
I think that's my new favored quote! Do we have a FAQ or chart laying out how the source code is built. I don't have the time now, or in the foreseeable future, but it's definitely on my list of things that "might be fun". After finishing my bloody NWN Mod to get units to march in formation. It's almost done, just classes take too much time for me to sit down and get the work done.(Damnable script restrictions! The project is nearing it's err another birthday.)
The
wiki on the subject is not directly useful, but branches out to all manner of useful links.
The approach I would use? First, in either method, make the absolutely huge data file. Running though every map, I would have each side (PHALANX, VXI, and Civi) have side move though every possible unit combination in every valid place to stand.
Then maybe make a second data file. Give every unit the ability to use any valid item available to it's side, move one square, or be shot at from any given enemy unit able to see it in a given senario. Seeing this is the AI I'll ignore PHALANX for the most part, and assume that the AI's stats are not totally random. I'll then automate some process to either make a formula, or do another loop for each set of stats. What this will do is give a expected outcome for any of the actions the unit does or has done to it(get shot at).
We'd then make a list. This list would look at the above, being just single actions, and string them together based on the expected outcome of that action. For example, I need to move up to enemies position to fire at "them". The above list would just have the 'move up' or 'fire at "them"' actions, but they wouldn't be directly connected. It would just have a entrie saying, given this goal this is the most desirable action to meet that goal. In this case(not being able to desirable to fire at them now.) the entry for the current unit deployment to fire at "them" would list "move up" as the desired action.
So what this pass would do is string like entries together by looking at the above data file and following each entries, from entry to entry, of desired actions until it found a action that directly met it's goal(SHOOT THEM!). In this case it would link move left, move left, and FIRE! into a list. Each list would then be given a set of goals it was design to meet("I want to shoot this guy!") So the AI could then see what it wanted to do and have the actions need to meet that goal already laid out for it. Of course, we'd only make lists of actions that where longer then one action long
However, this too would be a massive, maybe even bigger, file and only marginally useful, thankfully it just happens to be useful, it's not the end goal!
Plan A:Also, thankfully I happen to know a trick that should cut that down to size, and layer that into a easy to use format tied into the map file. Each square on the map a unit can occupy is given a blank node(class object) containing a list of all possible actions. Then use the above file and list to populate each action in the node with how well each action will work to the desired goal. This node could also be altered to each AI unit on the map, with each AI keeping a list of the last it use from the last turn or two, then update the weight on each action based on what really happened to the AI. This way the AI could "learn" as the game progresses. Making each install, if not game, unique the more it's played. If you do that though I suggest a short term, that degrades over time, and long term weights. The AI using the sum of both, and only affecting the short term weight. Then a fraction of the short term changing the long term to keep freak accidents from wrecking the AI.
Plan B:Each square on the would have a node(read as class object). This node would then be given a list of goals you can accomplish here, and actions that accomplish that goal, taken directly from the first data file. Not very useful for much. This is where the lists we just made comes into play, and gets narrowed down.
We'd go though the above lists starting with the first action of each list. We'd start at the node the first action was based off off. Then instead of giving a single action to do, we'd give a pointer to the first action in this list, and tell the AI to "hop to buddy!". We'd then move down to the second action in the list, and add a pointer from the node the first action leads us to to the second action in the list. and so forth. Associating each pointer we make with the outcome the list is to accomplish.
To keep the from accessing the map nodes every time it so much as moved, could be made to only look at the node network when it needs to. Looking ahead from node to node, storing a list of each action each node stores. Then either only accessing the network again when it's done or something changes enough it needs new instructions.
A CO:Up to now the AI has been basically "every (man) for himself!" The CO would be a script that doesn't look at each unit as a single unit, but looks at each unit as one single "unit". Then looks what action(s) would most benefit the squad or best meet the squads goals. Then enforces those actions on the squad. So each unit doesn't have a AI per say. The "CO" script in the background is the one calling the shots, the units just look at the best way to follow the given orders. It also has the advantage of off loading the work into a central point that only has to be run once each turn, instead of over and over by each unit in turn.
Edit: Maybe even preloading plans of attack, or save passed successful actions.