/* * Creates player objects based on initial initialization. * Human player takes pid of 1; index 0. */ public void PopulatePlayers(int numUsers, List <Federation> federationList) { for (int i = 0; i < numUsers; i++) { Player tempPlayer; if (i == 0) { tempPlayer = new Player(i + 1); } else { tempPlayer = new EqualDistributionAgent(i + 1); } //tempPlayer.InitList(federationList); this.PlayerList.Add(tempPlayer); } }
public List <Bid> ProcessCPUActions(List <Federation> federationList, List <InTraining> inTrainingList) { if (federationList.Count == 0) { return(null); } List <Bid> tempBidList = new List <Bid>(); for (int i = 1; i < this.PlayerList.Count; i++) { EqualDistributionAgent tempPlayer = (EqualDistributionAgent)this.PlayerList[i]; //if no more resource continue if (tempPlayer.ResourceOwned.AssignedQty - tempPlayer.ResourceOwned.InBidQty - tempPlayer.ResourceOwned.InTrainingQty == 0) { continue; } //List<InTraining> playersParticipation = inTrainingList.Where(t => t.Pid == tempPlayer.Pid).ToList(); List <int> federationsIDList = (from t in inTrainingList select t.Fid).ToList(); //List<Federation> federationListWithoutCurrentParticipation = federationList.Where(f => playersParticipation //.All(t => t.Fid != f.FederationId)).ToList(); List <Federation> federationListWithoutCurrentParticipation = (from f in federationList where !federationsIDList.Contains(f.FederationId) select f).ToList(); foreach (Federation f in federationListWithoutCurrentParticipation) { Console.WriteLine("Player " + tempPlayer.Pid + " Federation ID " + f.FederationId); } //List<Bid> CPUPlayerDecision = tempPlayer.CPU_Decision2(federationList); //tempBidList.AddRange(CPUPlayerDecision); List <Federation> shuffleList = RandomizeList(federationListWithoutCurrentParticipation); List <Tuple <int, int, double, double, int, double> > tempList = tempPlayer.GenerateBidList(shuffleList); if (tempList != null) { List <Bid> tempTupleBidList = this.GenerateBidList(tempList); tempBidList.AddRange(tempTupleBidList); } } return(tempBidList); }
public void FixedSettings() { string fixedTextParams = this._ioManager.GetFixedSettings(); string[] textCategory = fixedTextParams.Split('#'); //, StringSplitOptions.RemoveEmptyEntries); //.Split('#',StringSplitOptions.RemoveEmptyEntries); string[] fixedParamsNum = textCategory[1].Split(new[] { "\r\n", "\n" }, StringSplitOptions.None); string[] playersParam = textCategory[2].Split(new[] { "\r\n", "\n" }, StringSplitOptions.None); string[] federationParam = textCategory[3].Split(new[] { "\r\n", "\n" }, StringSplitOptions.None); //Console.WriteLine(fixedParamsNum[1]); int numPlayers = Convert.ToInt32(fixedParamsNum[1].Split(',')[0]); int numFederations = Convert.ToInt32(fixedParamsNum[1].Split(',')[1]); this.simulationSettings.NUM_OF_PLAYERS = numPlayers; this.simulationSettings.NUM_OF_FEDERATIONS = numFederations; this._numFederations = numFederations; this._numUsers = numPlayers; double dataQualityWeight = simulationSettings.DATA_QUALITY_WEIGHT; double dataQuantityWeight = simulationSettings.DATA_QUANTITY_WEIGHT; Console.WriteLine(String.Format("Num Players {0} , Num Federations {1}", numPlayers, numFederations)); List <int> fedSchemeSplit = new List <int>(); //federation params for (int i = 1; i <= numFederations; i++) { string[] param = federationParam[i].Split(','); int schemeIndex = Convert.ToInt32(param[1]); fedSchemeSplit.Add(schemeIndex); } //recreate env objs this._schemeManager.BuildFederationSchemeList(this._numFederations, this._numUsers, fedSchemeSplit); for (int i = 1; i <= numPlayers; i++) { string [] param = playersParam[i].Split(','); double dataQuality = Convert.ToDouble(param[1]); double dataQuantity = Convert.ToDouble(param[2]); double asset = Convert.ToDouble(param[3]); int resourceQty = Convert.ToInt32(param[4]); int humanIndic = Convert.ToInt32(param[5]); Player tempPlayer = null; if (humanIndic == 0) { tempPlayer = new Player(i); } else { //TODO Case if more agents tempPlayer = new EqualDistributionAgent(i); } this._playerManager.PlayerList.Add(tempPlayer); this._playerManager.AllocatePlayer(i - 1, new DataObject(dataQuality, dataQuantity), new Resource(resourceQty), asset, dataQualityWeight, dataQuantityWeight); Console.WriteLine(playersParam[i]); } Admission policy = new Admission(simulationSettings.INIT_DATA_QUALITY, simulationSettings.INIT_DATA_QUANTITY, simulationSettings.INIT_RESOURCE_QUANTITY, simulationSettings.INIT_AMOUNT_BID); _federationManager.PopulateFederations(_numFederations, _schemeManager.PythonSchemeList, policy, simulationSettings.MIN_BID_LENGTH); double split = 100 / this._federationManager.FederationList.Count; for (int i = 0; i < this._federationManager.FederationList.Count; i++) { this._federationManager.FederationList[i].MarketShare = Math.Round(split / 100, 2); this._federationManager.FederationList[i].CollabTrainingQuality = 0.1; this._federationManager.FederationList[i].FederationMarketShareHistory.Add(this._federationManager.FederationList[i].MarketShare); } //set up premise for initial DB set up //Game ID, Settings, Initial Federation/ Players this.dbManager.AddGameInstance(simulationSettings, Guid.NewGuid().ToString()); Boolean b = true; foreach (Player p in this._playerManager.PlayerList) { if (p.Pid != 1) { b = false; } this.dbManager.AddParticipant(p, b); this.dbManager.AddParticipantHistory(p, 0, 0); } foreach (Federation f in this._federationManager.FederationList) { this.dbManager.AddFederation(f); this.dbManager.AddFederationHistory(f, 0, 0); } //_ioManager.LoadPythonModules(_schemeManager,strategyManager); }