Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            // inefficient, uses broadcast to simulate public open-cry auction

            var env = new ConcurrentEnvironment();

            for (int i = 1; i <= Utils.NoBidders; i++)
            {
                int agentValuation = Utils.MinPrice + Utils.RandNoGen.Next(Utils.MaxPrice - Utils.MinPrice);
                var bidderAgent    = new BidderAgent(agentValuation);
                env.Add(bidderAgent, string.Format("bidder{0:D2}", i));
                bidderAgent.Start();
            }

            Thread.Sleep(100);

            var auctioneerAgent = new AuctioneerAgent();

            env.Add(auctioneerAgent, "auctioneer");
            auctioneerAgent.Start();

            env.WaitAll();
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            // more efficient, each bidder only talks to the auctioneer

            var env = new ConcurrentEnvironment();

            for (int i = 1; i <= Utils.NoBidders; i++)
            {
                int agentValuation = Utils.MinPrice + Utils.RandNoGen.Next(Utils.MaxPrice - Utils.MinPrice);
                var bidderAgent    = new BidderAgent(agentValuation);
                env.Add(bidderAgent, string.Format("bidder{0:D2}", i));
                bidderAgent.Start();
            }

            Thread.Sleep(100);

            var auctioneerAgent = new AuctioneerAgent();

            env.Add(auctioneerAgent, "auctioneer");
            auctioneerAgent.Start();

            env.WaitAll();
        }