示例#1
0
文件: Pairing.cs 项目: Lecale/Miasma
//        string[] res = {"None","WWin","BWin","Draw","WAdj","BAdj","DAdj","LAdj"};

        public override bool Equals(object obj)
        {
            Pairing p = (Pairing)obj;

            if (p.white.getSeed() == white.getSeed())
            {
                if (p.black.getSeed() == black.getSeed())
                {
                    return(true);
                }
            }
            if (p.white.getSeed() == black.getSeed())
            {
                if (p.black.getSeed() == white.getSeed())
                {
                    return(true);
                }
            }

            if (p.white.EGDPin == white.EGDPin)
            {
                if (p.black.EGDPin == black.EGDPin)
                {
                    return(true);
                }
            }
            if (p.white.EGDPin == black.EGDPin)
            {
                if (p.black.EGDPin == white.EGDPin)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#2
0
        public DrawMachine3(List <Player> ply, List <Pairing> _History, int _Rnd,
                            int _MaxHandi = 9, int _AdjHandi = 1, bool _HandiAboveBar = false, bool _Verbose = false)
        {
            Verbose = _Verbose;
            plys.AddRange(ply); //Careful with Byes
            History     = _History;
            lookUpTable = new int[ply.Count];
            Pairs       = new List <Pairing>();
            Pairing.setStatics(_MaxHandi, _AdjHandi, _HandiAboveBar);
            // plys.Sort(); //just in case
            foreach (Player pd in plys)
            {
                if (pd.getParticipation(_Rnd - 1))
                {
                    totalPairs++;
                }
            }
            List <Player> takingABye = new List <Player>();

            foreach (Player pd in plys)
            {
                if (pd.getParticipation(_Rnd - 1) == false)
                {
                    takingABye.Add(pd);                                     //0 based
                }
            }
            foreach (Player tab in takingABye)
            {
                plys.Remove(tab);
            }
            totalPairs = totalPairs / 2;
            //i want to search for Seed and see player
            for (int i = 0; i < plys.Count; i++)
            {
                lookUpTable[plys[i].Seed - 1] = i;
            }
            //end DO WE NEED

            _Split = new List <SplitLayer>();
            //populate Split layers which use Seed and not Deed
            _Split.Add(new SplitLayer(plys[0].getMMS(), plys[0].Seed));
            for (int i = 1; i < plys.Count; i++)
            {
                if (plys[i].getMMS() == _Split[_Split.Count - 1].MMSKey)
                {
                    _Split[_Split.Count - 1].Add(plys[i].Seed);
                }
                else
                {
                    _Split.Add(new SplitLayer(plys[i].getMMS(), plys[i].Seed));
                }
            }
            if (Verbose)
            {
                DebugSplit();
            }
            DRAW();
        }
示例#3
0
        public DrawMachine1(List <Player> ply, List <Pairing> _History,
                            int _MaxHandi = 9, int _AdjHandi = 1, bool _HandiAboveBar = false, bool _Verb = false)
        {
            Verbose       = _Verb;
            plys          = ply;
            History       = _History;
            LookUpTable   = new int[ply.Count];
            LookUpBull    = new bool[ply.Count];
            Pairs         = new List <Pairing>();
            MaxHandi      = _MaxHandi;
            AdjHandi      = _AdjHandi;
            HandiAboveBar = _HandiAboveBar;
            Pairing.setStatics(MaxHandi, AdjHandi, HandiAboveBar);
            plys.Sort();              //just in case
            int d = 0;

            foreach (Player pp in plys)
            {
                LookUpBull[d] = false;
                pp.Deed       = d++;
            }
            BigM = new List <McLayer>();
            //populate BigM
            BigM.Add(new McLayer(plys [1].getMMS(), plys [1].Deed));
            for (int i = 2; i < plys.Count; i++)
            {
                if (plys [i].getMMS() == BigM [BigM.Count - 1].MMSKey)
                {
                    BigM [BigM.Count - 1].Add(plys [i].Deed);
                }
                else
                {
                    BigM.Add(new McLayer(plys [i].getMMS(), plys [i].Deed));
                }
            }
            //Shuffle
            foreach (McLayer mcl in BigM)
            {
                mcl.Shuffle();
            }
            for (int j = 0; j < LookUpTable.Length; j++)
            {
                LookUpTable [plys [j].Deed] = j;
            }
            DRAW();
        }
示例#4
0
        public void DRAW(int start = 0)
        {
            Player  top = plys [start];
            Pairing tmp;

            if (Verbose)
            {
                Console.WriteLine("Calling SimpleDraw() start:" + start);
            }
            bool found = false;

            for (int i = start + 1; i <= plys.Count - 1; i++)            //foreachPlayer
            {
                if (LookUpBull [i] == true)
                {
                    found = true;
                }
                else
                {
                    found = false;
                }
                while (found == false)
                {
                    foreach (McLayer mcl in BigM)                       //foreachLayer
                    {
                        if (found == false)
                        {
                            for (int j = 0; j < mcl.Length; j++)
                            {
                                tmp = new Pairing(plys[mcl.GetAt(j)], top);
                                //Is this path really accurate?
                                tryPath = path + " " + top.Deed + "," + plys[mcl.GetAt(j)].Deed;
                                if (plys[mcl.GetAt(j)].Deed != top.Deed)
                                {
                                    if (LookUpBull[plys[mcl.GetAt(j)].Deed] == false)
                                    {
                                        if (ValidPath(tryPath) == true)
                                        {
                                            if (History.Contains(tmp) == false) //cannot allow repeat pairing
                                            {
                                                LookUpBull[top.Deed] = true;
                                                LookUpBull[plys[mcl.GetAt(j)].Deed] = true;
                                                path += " " + top.Deed + "," + plys[mcl.GetAt(j)].Deed;
                                                if (Verbose)
                                                {
                                                    Console.WriteLine(path);
                                                }
                                                Pairs.Add(tmp);
                                                found = true;
                                                top   = plys[0];
                                                for (int k = 0; k < LookUpBull.Length; k++)                         //update top
                                                {
                                                    if (LookUpBull[k] == false)
                                                    {
                                                        top = plys [k];
                                                        k   = LookUpBull.Length + 1;
                                                    }
                                                }
                                                if ((Pairs.Count + Pairs.Count) == plys.Count)
                                                {
                                                    found = true;
                                                    return;
                                                }
                                                break; //out of j
                                            }//end if
                                        }
                                    }
                                }
                            }            //end j
                        }
                    }                    //foreachLayer
                    if (found == false)
                    {
                        if (Pairs.Count == plys.Count - Pairs.Count)
                        {
                            return;
                        }
                        string sp = path;
                        Paths.Add(sp);
                        CleanBlocked(sp);
                        int penultimateSpace = path.LastIndexOf(" ");
                        //DM1 doesn't need restore as we never empty the McLayer
                        //Which makes it super slug like
                        path = path.Remove(penultimateSpace);
                        //Mandatory removal of last pair
                        //update lookups
                        LookUpBull [Pairs [Pairs.Count - 1].black.Deed] = false;
                        LookUpBull [Pairs [Pairs.Count - 1].white.Deed] = false;
                        //rm last pairing added
                        Pairs.RemoveAt(Pairs.Count - 1);
                        //Now we check the path to see if we need to go deeper

                        //why don't we call at highest false
                        for (int re = 0; re < LookUpBull.Length; re++)
                        {
                            if (LookUpBull[re] == false)
                            {
                                //    depth = Pairs.Count;
                                retry++;
                                DRAW(re);
                            }
                        }
                        //used to be DRAW(i-2);
                    }
                }
            }            //end foreachplayer
        }