### how to make minimax multi player?

I have pseudo code for the minimax algorithm but i was wondering what i would need to add to make it work with many players (n players)?

 ``123456789101112131415161718192021222324`` ``````score minimax(state s, int n) if (n = 0 OR s is a terminal node) { if win position for program return +inf; if loss position for prg return -inf; if draw game return 0; return f(s); // static eval. func @ s } else bestscore = prg's move ? -inf : +inf; for each successor state s' of s { v= minimax(s’ n-1); if programs move bestscore = max(v, bestscore); else bestscore = min(v, bestscore); } return bestscore; } ``````
Create an array which is equal to the size of n players. Run the minimax algorithm from the perspective of each player and fill the appropriate array entry with their evaluation.
ok thanks but what should i add to the pseudo code to do that?
So let's say you have 4 players.
 ``123456`` ``````int playerevals[4], i; for(i = 0; i < 4; ++i) { //run the minimax playerevals[i] = minimax(); }``````

In the minimax, you'll obviously have to change the evaluation to analyze from the perspective of each player. So it will be like:
 ``123456`` ``````//Pseudocode on player 1 pass... if win position for player 1 score = some really high number if win position for any other player score = some really low number. ``````
Topic archived. No new replies allowed.