Have you found the right implementation?
Fiddling a bit, I tend to agree with Steven G. Johnson `for` loops would be the most efficient and probably the most understandable implementation.
Also, would it not be easier to have the first index in the `payoff_matrix` determine which player's payoff are we using?
Finally, following is an implementation using `mapslices` which seems to work:
nplayers = last(size(payoff_matrix));
bestresponse = cat(nplayers+1,(mapslices(x->fill(indmax(x),size(payoff_matrix,i)), payoff_matrix[fill(:,nplayers)...,i],i) for i=1:nplayers)...)
The `bestresponse` array is the same shape as `payoff_matrix`, with each entry in `bestresponse[..,..,..,..,i]` denoting the strategy number which is a best response to the others choices for player `i` (chosen in the last index). The other player's strategies are determined by all the `..,...,..` indices before, with the choice of player `i` immaterial (since a single best response is chosen by the `indmax` function.
This is a good exercise, perhaps another question on Stackoverflow would yield interesting variations.