| Package | com.lookbackon.AI.searching |
| Class | public class AlphaBeta |
| Inheritance | AlphaBeta SearchingBase AbstractProcess Object |
See also
| Method | Defined By | ||
|---|---|---|---|
AlphaBeta(gamePosition:PositionVO, depth:int = 1, alpha:int, beta:int)
The major improvement over MiniMax/NegaMax is the AlphaBeta algorithm:
Here you realize that you don't have to go through the whole search tree. | AlphaBeta | ||
![]() | SearchingBase | ||
![]() |
The evaluation function will return positive values if the position is good for red and negative values.
if the position is bad for red in the MinMax formulation.
Many things could be said about evaluation functions,
for me,the two main objectives in designing a evaluation function are speed and accuracy.
The faster your evaluation function is,the better is.
and the more accurate its evaluation is,the beeter.
Obviously,these two things are somewhat at odds:
an accurate evaluation function probably is slower than a 'quick-and-dirty' one.
The evaluation function I'm taking about here is a heuristic one -not a exact one.
| SearchingBase | |
![]() | generateMoves(pieces:Vector.<ChessPiece>):Vector.<ConductVO>
This function generates all possible moves and stores them in the vector.
It returns the vector of the legal moves.
While is checking,defend moves with high priority.
| SearchingBase | |
![]() |
Obviously,the struct move must contain all information necessary to support this operations.
As always,the structures are passed by reference,
in this case it is not only a speed question:
the position will be modified by this functions.
| SearchingBase | |
![]() | noneMove():int | SearchingBase | |
run():void [override] | AlphaBeta | ||
![]() | runAndManage(allocation:int):void | AbstractProcess | |
![]() | terminate():void | AbstractProcess | |
![]() | unmakeMove(conductVO:ConductVO):void
Unmake previous move,for all kinds of searching tree algorithms. | SearchingBase | |
![]() | willNoneMove(gamePosition:PositionVO):Boolean | SearchingBase | |
![]() | yield():void | AbstractProcess | |
| AlphaBeta | () | Constructor |
public function AlphaBeta(gamePosition:PositionVO, depth:int = 1, alpha:int, beta:int)The major improvement over MiniMax/NegaMax is the AlphaBeta algorithm: Here you realize that you don't have to go through the whole search tree. If you find one winning continuation, you don't have to look at any others. Similarly, if you have found one continuation which will give you the value V you can stop your search along another continuation if you find only one possibility for your opponent which gives you a lower score than V. You don't have to look at all the other possibilities your opponent might have - one refutation is enough! Here is the code for AlphaBeta, extending the earlier NegaMax code: It receives two extra parameters, alpha and beta. They define an interval within which the evaluation has to be. If it isn't, the function will return. Your first call to AlphaBeta will be with an interval -INFINITY...INFINITY; subsequent recursive calls to the function will make the window smaller.
ParametersgamePosition:PositionVO — the piece's postion in board.
| |
depth:int (default = 1) — the piece's depth in this game tree.
| |
alpha:int (default = NaN) — INFINITY.
| |
beta:int (default = NaN) — -INFINITY.
|
See also
| run | () | method |
override public function run():void