I'm trying to calculate Nash Equilibirum, so I need all the possible combinations of players and their strategies.
I have classes and methods:
StrategyPlayer from LinkedList<Strategy> strategiesStrategyCombination from TreeMap<Player, Strategy> combinationboolean 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));
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.