Example #1
0
        private void sendResults(String instance, EdgeAuction auction)
        {
            Dictionary <EdgePair, Double>         flow     = auction.getCurrentFlow();
            Dictionary <EdgePair, List <Bid> >    edgeBids = auction.getEdgeBids();
            Dictionary <EdgePair, List <String> > W        = auction.getWinners();

            makeResultsMessage(instance, flow, edgeBids, W);
        }
Example #2
0
        public void matchOn(FileInfo child, List <string> players)
        {
            FCTPGraph problem =
                InstanceConverter.convert(
                    child.FullName);

            log("Match " + problem.Name);

            //Initialize Edge Auction
            EdgeAuction auction = new EdgeAuction(problem, GamePlay.U, players); // GamePlay.U - Gets Constant Factor K = 20 (U = K on problem description)

            //int edgesPerRound = computeEdgesPerRound(problem, players.Count);
            //log(edgesPerRound + " edges per round");

            //String msg = "instance " + problem.Name + " " + edgesPerRound;
            playRound(child.Name, auction, GamePlay.round); // GamePlay.round - Gets the current round number.

            Dictionary <String, Double> instancePayoffs = auction.getPayoffMap();

            foreach (HandleClient c in GamePlay.socket.ClientList) // GamePlay.socket.ClientList - Gets list of players
            {
                String s = c.player.name;

                if (instancePayoffs.ContainsKey(c.player.name))
                {
                    c.player.SetScore(instancePayoffs[s]);

                    if (!payoffs.ContainsKey(s))
                    {
                        payoffs.Add(s, instancePayoffs[s]);
                    }
                    else
                    {
                        payoffs[s] = payoffs[s] + instancePayoffs[s];
                    }
                }
            }

            log("PARTIAL");
            String partial = getSortedPayoffMapMsg(payoffs);

            log(partial);
        }
Example #3
0
        private void playRound(String instance, EdgeAuction auction, int round)
        {
            log("Round: " + round);

            List <Bid> bids = new List <Bid>();

            foreach (HandleClient c in GamePlay.socket.ClientList) // GamePlay.socket.ClientList - Gets list of players
            {
                List <Bid> iBids = c.player.GetBidsTo(instance);
                bids.AddRange(iBids);
            }
            auction.update(bids);

            log("Round " + round + " Payoffs");
            Dictionary <String, Double> payoffMap = auction.getPayoffMap();

            String msg = getSortedPayoffMapMsg(payoffMap);

            log(msg);

            sendResults(instance, auction);
        }