add documentation to AI

I felt that I should document what's happening in each of the functions
used in the algorithm for anybody having trouble understanding how it
works. The first three functions are not game specific per se so I gave
general names to the function and variables.
Merge pull request #3 from zachmokahn/ai_annotation

add documentation to AI