Search algorithm pseudocode (hal function) store original board var theBoard = new Array(33); for (var i = 1; i<=32; i++) { theBoard[i] = _level[i]._currentframe; } var score=-9999 var bestpiece=0;//initialize to 0 var bestposition=0;//initialize to 0 var depth=4 //amount of times to recurse for (i =1;i <=32; i++){ srcClick=i; //try moving to position +3, +4, +5, +7 and +9.if these are valid moves, start recursing if validmove(i+3){ this will move the board to the new position thisscore=bestmove(depth); if(thisscore>score){ score=thisscore+thismovescore(3); bestpiece=i; bestposition=3; } for (var j = 1; j<=32; j++) { _level[j]._currentframe=theBoard[j]; //reset board } } if validmove(i+4){ thisscore=bestmove(depth); if(thisscore>score){ score=thisscore+thismovescore(4); bestpiece=i; bestposition=3; } for (var j = 1; j<=32; j++) { _level[j]._currentframe=theBoard[j]; //reset board } } if validmove(i+5){ thisscore=bestmove(depth); if(thisscore>score){ score=thisscore+thismovescore(5); bestpiece=i; bestposition=3; } for (var j = 1; j<=32; j++) { _level[j]._currentframe=theBoard[j]; //reset board } } if validmove(i+7){ thisscore=bestmove(depth); if(thisscore>score){ score=thisscore+thismovescore(7; bestpiece=i; bestposition=3; } for (var j = 1; j<=32; j++) { _level[j]._currentframe=theBoard[j]; //reset board } } if validmove(i+9){ thisscore=bestmove(depth); if(thisscore>score){ score=thisscore+thismovescore(9); bestpiece=i; bestposition=3; } for (var j = 1; j<=32; j++) { _level[j]._currentframe=theBoard[j]; //reset board } } } //board is now at original position and the best move has been determined srcClick = bestpiece; validmove(bestposition); //bestmoves have been made and now turn will switch; bestmove function pseudocode if(depth>0){ store original board var theBoard = new Array(33); for (var i = 1; i<=32; i++) { theBoard[i] = _level[i]._currentframe; } var myscore=-9999 var mybestpiece=0;//initialize to 0 var mybestposition=0;//initialize to 0 for (i =1;i <=32; i++){ srcClick=i; //try moving to position +3, +4, +5, +7 and +9.if these are valid moves, start recursing if(turn='b') moveto=i+3; else moveto=i-3; if validmove(moveto){ this will move the board to the new position thisscore=bestmove(depth-1); if(thisscore>score){ myscore=thisscore+thismovescore(moveto,theBoard); } for (var j = 1; j<=32; j++) { _level[j]._currentframe=theBoard[j]; //reset board } } if(turn='b') moveto=i+4; else moveto=i-4; if validmove(moveto){ thisscore=bestmove(depth-1); if(thisscore>score){ myscore=thisscore+thismovescore(moveto,theBoard); } for (var j = 1; j<=32; j++) { _level[j]._currentframe=theBoard[j]; //reset board } } if(turn='b') moveto=i+5; else moveto=i-5; if validmove(moveto){ thisscore=bestmove(depth-1); if(thisscore>score){ myscore=thisscore+thismovescore(moveto,theBoard); } for (var j = 1; j<=32; j++) { _level[j]._currentframe=theBoard[j]; //reset board } } if(turn='b') moveto=i+7; else moveto=i-7; if validmove(moveto){ thisscore=bestmove(depth-1); if(thisscore>score){ myscore=thisscore+thismovescore(moveto,theBoard); } for (var j = 1; j<=32; j++) { _level[j]._currentframe=theBoard[j]; //reset board } } if(turn='b') moveto=i+9; else moveto=i-9; if validmove(moveto){ thisscore=bestmove(depth-1); if(thisscore>score){ myscore=thisscore+ thismovescore(moveto,theBoard); } for (var j = 1; j<=32; j++) { _level[j]._currentframe=theBoard[j]; //reset board } } } return myscore; //return the best score } return 0; //return 0 if depth is 0; thismovescore function pseudocode function thismovescore(moveto:Number,theBoard):Number { for (var j = 1; j<=32; j++) { _level[j]._currentframe=theBoard[j]; //reset board } uses srcClick and the arguement from the function call to give a score to the current move current scores(will need adjustments): +1000-jump with another jump somewhere +50-jump to corner +0-jump to noncorner from noncorner -50-jump to noncorner from corner +200-jump becoming king +300-jump over king 700-jump single piece +50-move to corner -50-move to noncorner from side +0-move to noncorner from noncorner -100-no longer top 100-move }