Search this blog...

AI : Heuristics

Programming artificial intelligence into a piece of code is NOT about anticipating every single thing that can possibly happen. A heuristic approach is more practical to implement. Implementing a heuristic model has an added advantage that the system improves every time it is run.

Missed Part1 of this series? AI: Artificial or Actual intelligence
 
Heuristics (meaning "to find" or "discover") refers to techniques for learning, discovery and problem solving. Heuristic methods are used to speed up the process of finding a satisfactory solution. When an exhaustive search is impractical.




Implementing a heuristic model:
1. Setup a generic system that runs by a "rulebook".
  • The "rulebook" contains set of very simple rules to start with.

2. Design a "playbook" which is easily extensible.
  • Use arrays, linked-lists, b-trees, tables, a relational-database,... Anything. Just remember that the "playbook" is going to grow very fast. Eventually it will contain ALL the rules & tactics that exist.

3. Let the system run-wild.
  • At each turn, the system follows the existing rules in the "rulebook". It picks the best move applicable in the current context from the "playbook"  At the end of each run, save the moves & the outcome to the "playbook" for reference in the next runs. 
Thus the code "learns" the consequences of each move and gradually evolves (into something better) with each run. Care should be taken to formulate the "rulebook". It must be carefully devised to prevent the AI system from performing any illegal moves.


Additional points of interest:
  • Pruning : Removing obsolete/duplicate entries from the rulebook.
    - Reduces the "rulebook" size. Leads to faster decision making.
  • Character traits : Aggressive, defensive, favorite moves etc.
    - Useful in games. To provide multiple opponents.
  • Realistic AI : Possible to trick AI into making occasional mistakes.
    - Again useful in games. Makes gameplay more realistic & fun.



No comments :

Post a Comment