Java gets all Player / Strategy combinations for NashEquilibrium

I'm trying to calculate Nash Equilibirum, so I need all the possible combinations of players and their strategies.

I have classes and methods:

  • Strategy
  • Player from LinkedList<Strategy> strategies
  • StrategyCombination from TreeMap<Player, Strategy> combination
  • boolean isNashEquilibrium()that checks if StrategyCombination is NashEquilibrium

everything works perfectly. Now for this list of players and their strategies, I want to calculate all the possible StrategyCombinations and check each combination for isNashEquilibirum. I just can't figure out how to do this. I assume a recursive algorithm is possible.

So far I have:

        public class Game {

        LinkedList<Player> players = new LinkedList<Player>();

        public Game(){
        }

        public void addPlayer(Player p){
            this.players.add(p);
        }

        public StrategyCombination computeNashEquilibrium(){

            StrategyCombination nash = null;

            StrategyCombination sc = new StrategyCombination();

            for(int i = 0; i < this.players.size(); i++){
                    sc.combination.put(this.players.get(i), this.players.get(i).strategies.get(0));
            }

            for(int i = 0; i <= this.players.size()-1; i++){
                for(int j = 0; j <= this.players.get(i).strategies.size()-1; i++){
                    StrategyCombination sc2 = sc.createNew(this.players.get(i).strategies.get(j)); /* makes a new StrategyCombination with one Strategy replaced */
                if(sc2.isNashEquilibrium){
                nash = sc2;
                }
                    for(int k = i+1; k <= this.players.size()-1; i++){
                        for(int l = i+1; l <= this.players.size()-1; l++){
                            sc2.createNew(...);
                        }
                    }
                }
            }

            return nash;
        }

So how can I get all StrategyCombination? Even Brute Force is fine, I just can't figure it out right now: /. Thanks for reading and replies. Sorry for my English.

+4
2

...

.

:

createSetup(listOfplayers, listOfStrategies, indexOfPlayer){
    for each strategy of listOfStrategies
       assign strategy to indexOfPlayer-th player
       if (isLastPlayer()){
            executeSimluation(listOfPlayers);
       } else {
            createSetup(listOfplayers, listOfStrategies, indexOfPlayer+1);
       }
}
0

Source: https://habr.com/ru/post/1530606/


All Articles