Buy it, use it, break it, fix it, plug it, play it, burn it, rip it, drag and drop it, zip – unzip it
What one can learn from Game AI development
Below is an excerpt from STRIPS: A New Approach to the Application of Theorem Proving to Problem Solving, R. E. Fikes and N. J. Nilsson, Artificial Intelligence 2 (3–4), 1971. (pdf):
STRIPS belongs to the class of problem solvers that search a space of “world models” to find one in which a given goal is achieved. For any world model, we assume there exists a set of applicable operators each of which transforms the world model to some other world model. The task of the problem solver is to find some composition of operators that transforms a given initial world model into one that satisfies some particular goal condition.
The basic idea is that a world model is modified by operators, which have a set of preconditions and side effects. STRIPS planner is used to find out how to apply these operators to achieve the goal given some state. (But don’t confuse this approach with a Prolog programming language that operates with formal logic on top of a knowledge base without any side effects.) The original algorithm without any optimizations is simple: find which operator achieves the goal, then if the operator’s prerequisites are not satisfied your new goal is to satisfy those, in the end, choose the easiest plan. STRIPS was featured in F.E.A.R. and several other games, that were (and to some degree still are) cutting-edge in-game AI development.
The main thing one can learn from this is clear segregation between WHAT and HOW. WHAT is your goal defined in terms of conditions applied to the state (defines a subset of all possible states). HOW is a set of operators do the job. Everything else does a planner that doesn’t depend on the domain and can be easily reused from project to project.
An example
Imagine you are about to implement a private cloud solution. You can implement a set of operators like bring the interface up, make a bridge, obtain an address via DHCP, mount volume, create the container with lxc, etc. Each of these operators has prerequisites like obtaining an address via DHCP an interface must be up and running. Define states in terms of MIBs and use SNMPv3 to get/set state. Then you can easily define goals like provision a VM and the planner will do it for you using defined operators. The good news is that if something happens in the middle of VM provisioning (state changed from A to A’) planner can deal with this by providing a new plan. If you need to integrate someone’s solution just add a few new operators and the planner will benefit from them immediately. Compare and contrast this approach to OpenStack solution that is obsessed with (micro-)SOA ideas, not in the best way.
Can this be applied to web development? Consider you have a bunch of operators with arguments, prerequisites and side effects defined. In case one does not handle these operators as black boxes and with a bit of introspection understands prerequisites and side effects planner can build workflows by connecting operators together and it can also build an interface to input arguments for operators in the plan and react to unexpected (what if Paypal payment failed, a planner can suggest you pay in another way). The only thing left is to present the current state in a nice way to the user.
Final thoughts
One day devs used macro assembler, then C, nowadays OOP and FP hit the fan, but we need to go further and program in terms of business rules and goals. Even AngularJS and Backbone are too low level.
http://adolgarev.blogspot.com/2014/09/what-one-can-learn-from-game-ai.html