I am creating a board game using Actionscript 3.0. I've finished it to the point of the game playable with (computer players making random decision). I'm now working to create an AI framework/module ( Designing and creating classes that will be used to drive the AI). Is there a commonly/popular approach on creating an AI framework)? I've searhed around abit and could only find algorithms and sample codes. What I'm not looking for game/code specifics but more to thinking process in designing and modeling the AI.
The AI broadly depends of what is it supposed to do. What I mean is that so many kinds of AI exist that it is impossible to just cover them all.
These algorithm can easily be developed as a framework since what you really need are basically 2 functions:
- a function
(game state, player) -> game state list, which computes all the possible moves from a specific state of the game for a player
- a function
(game state, player) -> floatwhich is the kernel of the algorithm. This function is used to evaluate how good is a state for a specific player. This is the heuristic involved, and it is what you will tweak of the whole algorithm to make your AI more cleaver.
One you build the main algorithm (which goes recursively over a tree) you could easily adapt it to whatever board game you like by modifying just the two functions described above.
Behavior trees have been growing in popularity lately as a way to partially decouple game logic from AI flow. You will probably want to find a library that implements the basic elements though, it is annoying to write from scratch.
I don't think there's a generic approach because AI is not so much a component or a system as a broad classification of algorithms, many of which do entirely different things. There is no standard interface that could be applied to them all, nor a standard representation that could be used across them.
You need to decide exactly which parts of your program require an AI approach (eg. picking a move to make), then select an algorithm that facilitates that (eg. minimax).