You could do a search for the "minimax" algorithm, I don't think the name was mentioned in this thread but it's the most often used algorithm for turn based games such as chess. I have also written a chess game in BB using this same algorithm.
For instance:
http://ai-depot.com/LogicGames/MiniMax.html
For instance:
http://ai-depot.com/LogicGames/MiniMax.html