我正在努力計算納什平衡因此我需要球員和他們的策略的所有可能的組合。爪哇獲得所有組合的球員/戰略納什均衡
我已經得到的類和方法:
Strategy
Player
與LinkedList<Strategy> strategies
StrategyCombination
與TreeMap<Player, Strategy> combination
boolean isNashEquilibrium()
在此進行測試,如果StrategyCombination是一個納什均衡點
這一切工作正常。現在對於給定的玩家列表及其策略,我想計算所有可能的策略組合,並測試每個組合是否爲isNashEquilibirum。我無法弄清楚如何。我想遞歸算法是可能的。
到目前爲止我有:
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;
}
那麼如何才能得到所有StrategyCombinations?即使蠻力也行,我現在無法弄清楚:/。感謝您閱讀和回覆。對不起我的英語不好。