I was wondering if someone out there could help me understand how Transposition Tables could be incorporated into the Hypermax algorithm. Any examples, pseudo-code, tips, or implementation references would be much appreciated!
A little background:
- Hypermax is a recursive game tree search algorithm used for n-player games, typically for 3+ players. It's an extension of minimax and alpha beta pruning.
- Generally at each node in the game tree the current player (chooser) will look at all of the moves it can make and choose the one that maximizes it's own utility. Different than minimax / negamax.
- I understand how transposition tables work, but I don't know how the values stored in them would be used to initiate cutoffs when a transposition table entry is found. A transposition flag is required in minimax with transposition & alpha-beta pruning. I can't seem to wrap my head around how that would be incorporated here.
Hypermax Algorithm without Transposition Tables in Javascript:
/**
* @param {*} state A game state object.
* @param {number[]} alphaVector The alpha vector.
* @returns {number[]} An array of utility values for each player.
*/
function hypermax(state, alphaVector) {
// If terminal return the utilities for all of the players
if (state.isTerminal()) {
return state.calculateUtilities();
}
// Play out each move
var moves = state.getLegalMoves();
var bestUtilityVector = null;
for (var i = 0; i < moves.length; ++i) {
var move = moves[i];
state.doMove(move); // move to child state - updates game board and advances player 1
var utilityVector = hypermax(state, alphaVector.slice(0)); // copy the alpha values down
state.undoMove(move); // return to this state - remove board updates and rollsback player 1
// Select this as best utility if first found
if (i === 0) {
bestUtilityVector = utilityVector;
}
// Update alpha
if (utilityVector[state.currentPlayer] > alpha[state.currentPlayer]) {
alpha[state.currentPlayer] = utilities[state.currentPlayer];
bestUtilities = utilityVector;
}
// Alpha prune
var sum = 0;
for (var j = 0; j < alphaVector.length; ++j) {
sum += alpha[j];
}
if (sum >= 0) {
break;
}
}
}
References:
- Minimax (negamax variant) with alpha-beta pruning and transposition tables: https://en.wikipedia.org/wiki/Negamax#Negamax_with_alpha_beta_pruning_and_transposition_tables
- An Implementation without Transposition Tables: https://meatfighter.com/spotai/#references_2
- Original derivation and Proofs of Hypermax: http://uu.diva-portal.org/smash/get/diva2:761634/FULLTEXT01.pdf