Thank you, sorry I haven't been clearer, I've been looking for any info and because I couldn't find it, I ended up writing a poorly-worded question.
So, I wrote a chess game in Flash actionscript, one of the very few engines written in this language.
You can see the current implementation here:
http://www.sparkchess.comThe online version can search 4 plies, uses alpha-beta pruning with iterative deepening and principal variation and up to 4 plies of quiescence. The offline version can do more plies but it's pretty slow (can do about 20000 nodes/second).
One of the problems I'm having is that it's single-threaded, once it starts evaluating there's no way to interact with the program until is done (it has time management).
So if I could convert my search to work iteratively, I could have more control over it. I can use conditionals, loops and switches, but no Goto.
Right now, simplied, the search function looks like this:
- Code: Select all
function search(depth, alpha, beta)
{
if (depth == 0)
return eval();
var moves = generateMoves();
var crtMove;
var score = 200000;
var i;
while (i<moves.length)
{
crtMove = moves.moveList[i++];
doMove(crtMove);
score = -search(depth-1, -beta, -alpha);
undoMove(crtMove);
if (score > alpha)
{
if (score >= beta)
return beta;
alpha = score;
}
}
return alpha;
}
I'll have a look at your code in the morning and I'll see how I could adapt it. I've been trying to use a single loop so far and I've been able to traverse the tree with it, but I was having issues doing the alpha-beta pruning...