Ejemplo n.º 1
0
        public void Step()
        {
            Supply.Clear();
            Demand.Clear();
            foreach (var agent in Agents)
            {
                // Adding supplies from every agent in market to market's supply
                foreach (var entry in agent.Supplies)
                {
                    Good good   = entry.Key;
                    int  amount = entry.Value;

                    if (Supply.ContainsKey(good))
                    {
                        Supply[good] += amount;
                    }
                    else
                    {
                        Supply[good] = amount;
                    }
                }

                // Adding demands from every agent in market to market's demand
                foreach (var entry in agent.Demands)
                {
                    Good good   = entry.Key;
                    int  amount = entry.Value;

                    if (Demand.ContainsKey(good))
                    {
                        Demand[good] += amount;
                    }
                    else
                    {
                        Demand[good] = amount;
                    }
                }
            }
        }