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)?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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.
1
2
3
4
5
6
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:
1
2
3
4
5
6
//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.