This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
1 - You create a method that looks at any given position and makes an evaluation about how "good" or "bad" that position is. This method is often called a "static evaluation function" (SEF),because it looks only at a static position.
2 - You create a "Search tree" much as you discussed. In your example the beginning position would be the base or "root" of the tree, and you would have 20 white moves branching off of the root. For each of those 20 branches you would have 20 black branches, for each of those ~20-40 white branches, then black, then white, and so on. (Each set of branches is called a "ply".) Because computers are not infinitely fast and do not have infinite memory, you have to choose an arbitrary maximum number of plies to create and evaluate.
3 - You apply your static evaluation function to each of the positions you created and you assign each spot or "node" on the tree a value.
4 - There are various "minimum - maximum" algorithms that you can use to review the search tree's values and pick the best possible next move.
There are various ways to limit the size of the tree as you build it (called "pruning"), and of course creating a good SEF is a very difficult task. Typically your SEF would consider things like how many pieces each player has, how much each player controls the center of the board, how many total moves each player can make, how safe is each king, and so on.
This overall approach can be used for Chess, Checkers, Go, Backgammon, Othello, Connect-4, Pente, Go-Moku, and on and on.
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Joined: Jun 19, 2008
Thanks a bunch Bert for giving an insight
I dont know how much I can achieve - but will start giving it a thought and then some shot !