public List <String> NPlayerWrapper() { GameFrame GF = new GameFrame();//initialize a GameFrame //int PI =2;//number of players int PI = 4; //strategies of each player List <List <string> > playersstrategies = new List <List <string> >(); //p2 // playersstrategies.Add(new List<string> { "split1", "steal1" }); //playersstrategies.Add(new List<string> { "split2", "steal2" }); //p3 //4p playersstrategies.Add(new List <string> { "p1", "np1" }); playersstrategies.Add(new List <string> { "p2", "np2" }); playersstrategies.Add(new List <string> { "p3", "np3" }); playersstrategies.Add(new List <string> { "p4", "np4" }); GF.Game_Initializr(PI, playersstrategies);//Initialize Game //preferences of each player List <string> players_preferences = new List <string>(); players_preferences.Add("o1 = o4 = o6 = o7 = o9 = o12 = o14 = o16 > o2 = o3 = o5 = o8 = o10 = o11 = o13 = o15"); //p1 players_preferences.Add("o2 = o3 = o5 = o9 = o11 = o16 > o1 = o4 = o6 = o7 = o8 = o10 = o12 = o13 = o14 = o15"); //p2 players_preferences.Add("o8 > o1 = o2 = o3 = o4 = o5 = o6 = o7 = o9 = o10 = o11 = o12 = o13 = o14 = o15 = o16"); //p3 players_preferences.Add("o8 = o1 > o2 > o3 > o4 = o5 = o6 > o7 > o9 > o10 = o11 > o12 > o13 = o14 > o15 > o16"); //p4 //2p //players_preferences.Add("o3 > o1 > o2 = o4");//p1 //players_preferences.Add("o2 > o1 > o3 = o4");//p2 GF.PayOffs_generater(players_preferences); // Enter preferences to generate Payoffs // only needed in a console application GF.Fill_Nash_Equilibrium_Set(); //One call for both Best_outcomes and Fill_NE_set List <String> Result = new List <String>(); for (int i = 0; i < GF.get_Nash_Indices.Count; i++) { for (int j = 0; j < GF.get_NumOfPlayer; j++) { Result.Add(GF.get_SetOfCStategy[GF.get_Nash_Indices[i]][j]);//returns a list of string of the strategies of the players at the nash points } } return(Result); }
public GameFrame PreferencesGetterNplayer(string preferences, string username)//gets the prefrences of each individual player { foreach (var player in wrapper_TwoThree.playerInfo) { if (player.username == username)//fill the player's { if (player.preferences.Count() == 0) { player.preferences = preferences; } else { return(new GameFrame()); } } } bool check = false;//all players entered thier preferences foreach (var player in wrapper_TwoThree.playerInfo) { if (player.preferences == "") { check = true; } } if (check == false)//all the players have their preferences filled { //2: Generate Payoffs in n game and copy prev computed info from wrapper to returned GameFrame GameFrame ReturnedGame = new GameFrame(); ReturnedGame.Game_Initializr(wrapper_TwoThree.N_Players_Game.get_NumOfPlayer, wrapper_TwoThree.N_Players_Game.get_SetOfPlayersStrategies); List <string> allpprefrences = new List <string>(); for (int i = 0; i < wrapper_TwoThree.playerInfo.Count; i++) { allpprefrences.Add(wrapper_TwoThree.playerInfo.Find(item => (item.orderInGame == i)).preferences);//order players' prefrences } //3: Generate Payoffs in n game ReturnedGame.PayOffs_generater(allpprefrences);//Generate the outcomes of player's preferences //nonum : not sure if this will be in use List <PF> OrderedPlayers = new List <PF>(); for (int i = 0; i < wrapper_TwoThree.playerInfo.Count; i++) { OrderedPlayers.Add(wrapper_TwoThree.playerInfo.Find(item => (item.orderInGame == i)));//order players } //4: Compute Nash Equili ReturnedGame.Fill_Nash_Equilibrium_Set(); //5: Adding the points to database and clearing all used lists in game. //Add ash points to database //��LogNashPointsinDB_Nplayers(wrapper_TwoThree.playerInfo[0].GID, OrderedPlayers,) //Clear for the next game wrapper_TwoThree.N_Players_Game = new GameFrame(); wrapper_TwoThree.playerInfo.Clear(); wrapper_TwoThree.neprofiles.Clear();//clear for the next //6:return gameframe -> each player can know her payoffs and strategies by her orderingame index return(ReturnedGame); } return(null); }