+---+---+---+---+---+---+---+---+
8 |*r*| |*b*|*q*|*k*|*b*| |*r*|
+---+---+---+---+---+---+---+---+
7 |*p*|*p*|*p*|*p*|*p*|*p*|*p*|*p*|
+---+---+---+---+---+---+---+---+
6 | | |*n*| | | | |*n*|
+---+---+---+---+---+---+---+---+
5 | | | | | | |(P)| |
+---+---+---+---+---+---+---+---+
4 | | | |(P)|(P)| | | |
+---+---+---+---+---+---+---+---+
3 | | |(P)|(B)|(B)|(P)| | |
+---+---+---+---+---+---+---+---+
2 |(P)|(P)| |(N)|(N)| | |(P)|
+---+---+---+---+---+---+---+---+
1 |(R)| | |(Q)| |(R)|(K)| |
+---+---+---+---+---+---+---+---+
a b c d e f g h
The best move is g5h6. However when I run alphaBeta to any depth farther than 2 the engine seems to want to wait to make that move and tries to make set up moves first. The results of different depths are given here:
First guess for this would have to be your Trans Table, assuming you have one. I would imagine this is the issue.
How are you getting the best move out of the search? If it's not trans, maybe you are returning the wrong move.
All else fails, start turning off improvements one at a time. If it's open source and you cant find it, feel free to post some code snippets.
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra "Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
here is my very simple alphaBeta. Any help would be greatly appreciated I am a self aught programmer so my skills are not fantastic. Thank you all for the help
Two things. I question how you store the Pv. Also, you always return alpha... why if the best move is worth less than alpha?
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra "Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
troubling part of that pv is it doesn't want to save the knight in most iterations. if black doesn't want to save the knight with Ng8 then there's no reason you have to take it immediately and if for instance you're lacking quiescent search it might put it off to the last ply in order to save the pawn from being recaptured.
your output certainly look like you don't have quiescent search working yet (the oscillating odd-even scores being a typical sign of that) and if you've started adding reductions of any sort first that could be the cause of some of the oddness as changing the length of a line by a ply could change the score dramaticly.
Minimax does not care whether you gain something early or late; only the scorein the leaves counts. In this position, however, it seems that blackcan easily save the Knight by withdrawing it to f8. But at 3 ply he does not do that, in the PV, but instead plays a useless move a7a6. So it seems there is something wrong with your search.
int alphaBetaMin(int alpha, int beta, int depthleft, String input,
int goal, int[] pv) {
nodeCount++;
if (goal == depthleft) {
System.out.println("info depth " + goal);
}
// ArrayList<Integer> moves = board.sortMoves(
// board.generateMovesNeo(true), 1);
ArrayList<Integer> moves = board.generateMovesNeo(true);
if (pv.length > 1 + (goal - depthleft)) {
int temp = moves.indexOf(pv[goal - depthleft]);
if (temp > 0) {
moves.remove(temp);
moves.add(0, pv[goal - depthleft]);
}
}
if (depthleft == 0 || moves.size() == 0) {
if (changed) {
// System.out.println("info nodes " + nodeCount + " pv"
// + UCIBestLine(bestLine));
changed = false;
}
//System.out.print("Move: " + input);
//System.out.println("\t:\t " + board.getValue());
return board.getValue();
}
for (int i = 0; i < moves.size(); i++) {
if (goal == depthleft) {
System.out.println("info Currmove "
+ UCIBestLine(board.translate(moves.get(i)))
+ " currmovenumber " + (1 + i));
}
board.move(moves.get(i));
String temp = input + " " + board.translate(moves.get(i));
int score = alphaBetaMax(alpha, beta, depthleft - 1, temp, goal, pv);
board.undo();
if (score <= alpha)
return alpha; // fail hard alpha-cutoff
if (score < beta) {
if (!bestLine.toLowerCase().contains(temp.toLowerCase())) {
changed = true;
bestLine = temp;
}
beta = score; // beta acts like min in MiniMax
}
}
return beta;
}
It's common for chess engines to use the same alpha-beta search function (not max and min), but instead to pass in -beta and -alpha instead of alpha and beta to a new function. This is simpler to understand and maintain (only 1 search function). I expect there is an obscure problem in one of your search functions that experienced people here (not myself) are not familiar with.