The game I'm talking about is something similar to Gomoku or a "large", simplified version of Tic-Tac-Toe. Basically, you have an 8x8 board and the winner is the one that chains 4 in a row or column (no diagonal).
I've set up a minimax with alpha-beta pruning, the problem I have is that I'm not sure how returned values can let you know which move to make. Or like how to connect values to a move.
Currently, I've considered returning a GameStateNode instead. With the GameStateNode having fields: char[][] (the current state of the board), evaluationVal(the value of the current state when it is not a terminal node).
But I still can't think of a way to use the returned node to decide on the best move.
// Alpha-Beta Pruning Search
private static Node alphaBeta(Node initial, int depth) {
Node bestMove = max(initial, depth, NEGATIVE_INFINITY, POSITIVE_INFINITY);
return bestMove;
}
private static Node max(Node n, int depth, int alpha, int beta) {
int value = NEGATIVE_INFINITY;
Node currentBestMove = null;
Node temp = null;
// Terminal state
if(n.fourInALine() != 0) {
return n;
}
// Depth limit reached
if(depth == 0) {
return n;
}
ArrayList<Node> successors = n.generateSuccessors('X');
// Iterate through all the successors, starting with best evaluationValues
for(Node s : successors) {
temp = min(s, depth - 1, alpha, beta);
if(temp.evaluationVal > value) {
value = temp.evaluationVal;
currentBestMove = temp;
}
alpha = Math.max(alpha, value);
if(alpha >= beta) {
break;
}
}
return currentBestMove;
}
// I have similar min method just with the correct comparison