//Gets default market data //Should we pull from DB or cache and call each iteration to accomodate outages? private MarketData getMarketData(int numAgentsOfEachType) { List <Good> goods = new List <Good>(); List <AgentData> agentTypes = new List <AgentData>(); List <BasicAgent> agents = new List <BasicAgent>(); goods.Add(new Good("food", 0.5)); goods.Add(new Good("wood", 1.0)); goods.Add(new Good("ore", 1.0)); goods.Add(new Good("metal", 1.0)); goods.Add(new Good("tools", 1.0)); goods.Add(new Good("work", 0.1)); agentTypes.Add(new AgentData("farmer", 100, "farmer")); agentTypes.Add(new AgentData("miner", 100, "miner")); agentTypes.Add(new AgentData("refiner", 100, "refiner")); agentTypes.Add(new AgentData("woodcutter", 100, "woodcutter")); agentTypes.Add(new AgentData("blacksmith", 100, "blacksmith")); agentTypes.Add(new AgentData("worker", 10, "worker")); InventoryData ii; ii = new InventoryData(20, //farmer new Dictionary <string, double> { { "food", 0 }, { "tools", 1 }, { "wood", 3 }, { "work", 3 } }, new Dictionary <string, double> { { "food", 1 }, { "tools", 1 }, { "wood", 0 }, { "work", 0 } }, null ); agentTypes[0].Inventory = ii; ii = new InventoryData(20, //miner new Dictionary <string, double> { { "food", 3 }, { "tools", 1 }, { "ore", 0 } }, new Dictionary <string, double> { { "food", 1 }, { "tools", 1 }, { "ore", 0 } }, null ); agentTypes[1].Inventory = ii; ii = new InventoryData(20, //refiner new Dictionary <string, double> { { "food", 3 }, { "tools", 1 }, { "ore", 5 } }, new Dictionary <string, double> { { "food", 1 }, { "tools", 1 }, { "ore", 0 } }, null ); agentTypes[2].Inventory = ii; ii = new InventoryData(20, //woodcutter new Dictionary <string, double> { { "food", 3 }, { "tools", 1 }, { "wood", 0 } }, new Dictionary <string, double> { { "food", 1 }, { "tools", 1 }, { "wood", 0 } }, null ); agentTypes[3].Inventory = ii; ii = new InventoryData(20, //blacksmith new Dictionary <string, double> { { "food", 3 }, { "tools", 1 }, { "metal", 5 }, { "ore", 0 } }, new Dictionary <string, double> { { "food", 1 }, { "tools", 0 }, { "metal", 0 }, { "ore", 0 } }, null ); agentTypes[4].Inventory = ii; ii = new InventoryData(20, //worker new Dictionary <string, double> { { "food", 3 } }, new Dictionary <string, double> { { "food", 1 } }, null ); agentTypes[5].Inventory = ii; int idc = 0; for (int iagent = 0; iagent < agentTypes.Count; iagent++) { for (int i = 0; i < numAgentsOfEachType; i++) { agents.Add(getAgent(agentTypes[iagent])); agents[agents.Count - 1].Id = idc++; } } MarketData data = new MarketData(goods, agentTypes, agents); return(data); }
public void Init(MarketData data) { fromData(data); }
private MarketData GetMarketData() { List <Good> goods = new List <Good>(); List <AgentData> agentTypes = new List <AgentData>(); List <BasicAgent> agents = new List <BasicAgent>(); goods.Add(new Good("food", 0.5)); goods.Add(new Good("wood", 1.0)); goods.Add(new Good("ore", 1.0)); goods.Add(new Good("metal", 1.0)); goods.Add(new Good("tools", 1.0)); goods.Add(new Good("work", 0.1)); agentTypes.Add(new AgentData("farmer", 100, "farmer")); agentTypes.Add(new AgentData("miner", 100, "miner")); agentTypes.Add(new AgentData("refiner", 100, "refiner")); agentTypes.Add(new AgentData("woodcutter", 100, "woodcutter")); agentTypes.Add(new AgentData("blacksmith", 100, "blacksmith")); agentTypes.Add(new AgentData("worker", 10, "worker")); InventoryData ii; ii = new InventoryData(20, //farmer new Dictionary <string, double> { { "food", 0 }, { "tools", 1 }, { "wood", 3 }, { "work", 3 } }, new Dictionary <string, double> { { "food", 1 }, { "tools", 1 }, { "wood", 0 }, { "work", 0 } }, null ); agentTypes[0].inventory = ii; ii = new InventoryData(20, //miner new Dictionary <string, double> { { "food", 3 }, { "tools", 1 }, { "ore", 0 } }, new Dictionary <string, double> { { "food", 1 }, { "tools", 1 }, { "ore", 0 } }, null ); agentTypes[1].inventory = ii; ii = new InventoryData(20, //refiner new Dictionary <string, double> { { "food", 3 }, { "tools", 1 }, { "ore", 5 } }, new Dictionary <string, double> { { "food", 1 }, { "tools", 1 }, { "ore", 0 } }, null ); agentTypes[2].inventory = ii; ii = new InventoryData(20, //woodcutter new Dictionary <string, double> { { "food", 3 }, { "tools", 1 }, { "wood", 0 } }, new Dictionary <string, double> { { "food", 1 }, { "tools", 1 }, { "wood", 0 } }, null ); agentTypes[3].inventory = ii; ii = new InventoryData(20, //blacksmith new Dictionary <string, double> { { "food", 3 }, { "tools", 1 }, { "metal", 5 }, { "ore", 0 } }, new Dictionary <string, double> { { "food", 1 }, { "tools", 0 }, { "metal", 0 }, { "ore", 0 } }, null ); agentTypes[4].inventory = ii; ii = new InventoryData(20, //worker new Dictionary <string, double> { { "food", 3 } }, new Dictionary <string, double> { { "food", 1 } }, null ); agentTypes[5].inventory = ii; int idc = 0; for (int iagent = 0; iagent < agentTypes.Count; iagent++) { for (int i = 0; i < 5; i++) { agents.Add(getAgent(agentTypes[iagent])); agents[agents.Count - 1].id = idc++; } } MarketData data = new MarketData(goods, agentTypes, agents); return(data); //var assembly = Assembly.GetExecutingAssembly(); //var resourceName = "EconomySim.settings.txt"; //string[] names = assembly.GetManifestResourceNames(); //using (Stream stream = assembly.GetManifestResourceStream(resourceName)) //using (StreamReader reader = new StreamReader(stream)) //{ // string result = reader.ReadToEnd(); // MarketData data = JsonConvert.DeserializeObject<MarketData>(result); // return data; //} //return null; }