示例#1
0
        public void cuttingposibilitiesET()
        {
            Dictionary <Int64, Playfield> tempDict = new Dictionary <Int64, Playfield>();
            Playfield p   = null;
            int       max = posmoves.Count;

            for (int i = 0; i < max; i++)
            {
                p = posmoves[i];
                Int64 hash = p.GetPHash();
                if (!tempDict.ContainsKey(hash))
                {
                    tempDict.Add(hash, p);
                }
            }
            posmoves.Clear();
            foreach (KeyValuePair <Int64, Playfield> d in tempDict)
            {
                posmoves.Add(d.Value);
            }
            tempDict.Clear();
        }
示例#2
0
        public void cuttingposibilities(int maxwide)
        {
            // take the x best values
            List <Playfield> temp = new List <Playfield>();
            Dictionary <Int64, Playfield> tempDict = new Dictionary <Int64, Playfield>();

            posmoves.Sort((a, b) => - (botBase.getPlayfieldValue(a)).CompareTo(botBase.getPlayfieldValue(b)));//want to keep the best

            if (this.useComparison)
            {
                int i   = 0;
                int max = Math.Min(posmoves.Count, maxwide);

                Playfield p = null;
                //foreach (Playfield p in posmoves)
                for (i = 0; i < max; i++)
                {
                    p = posmoves[i];
                    Int64 hash = p.GetPHash();
                    p.hashcode = hash;
                    if (!tempDict.ContainsKey(hash))
                    {
                        tempDict.Add(hash, p);
                    }
                }
                foreach (KeyValuePair <Int64, Playfield> d in tempDict)
                {
                    temp.Add(d.Value);
                }
            }
            else
            {
                temp.AddRange(posmoves);
            }
            posmoves.Clear();
            posmoves.AddRange(temp.GetRange(0, Math.Min(maxwide, temp.Count)));
        }
        public void cuttingposibilitiesET()
        {
            var       tempDict = new Dictionary <long, Playfield>();
            Playfield p        = null;
            var       max      = this.posmoves.Count;

            for (var i = 0; i < max; i++)
            {
                p = this.posmoves[i];
                var hash = p.GetPHash();
                if (!tempDict.ContainsKey(hash))
                {
                    tempDict.Add(hash, p);
                }
            }

            this.posmoves.Clear();
            foreach (var d in tempDict)
            {
                this.posmoves.Add(d.Value);
            }

            tempDict.Clear();
        }
示例#4
0
        public void cuttingposibilities(bool isLethalCheck)
        {
            // take the x best values
            List <Playfield> temp = new List <Playfield>();
            Dictionary <Int64, Playfield> tempDict = new Dictionary <Int64, Playfield>();

            posmoves.Sort((a, b) => botBase.getPlayfieldValue(b).CompareTo(botBase.getPlayfieldValue(a)));//want to keep the best

            if (this.useComparison)
            {
                int i   = 0;
                int max = Math.Min(posmoves.Count, this.maxwide);

                Playfield p = null;
                for (i = 0; i < max; i++)
                {
                    p = posmoves[i];
                    Int64 hash = p.GetPHash();
                    p.hashcode = hash;
                    if (!tempDict.ContainsKey(hash))
                    {
                        tempDict.Add(hash, p);
                    }
                    else if (p.evaluatePenalty < tempDict[hash].evaluatePenalty)
                    {
                        tempDict[hash] = p;
                    }
                }
                foreach (KeyValuePair <Int64, Playfield> d in tempDict)
                {
                    temp.Add(d.Value);
                }
            }
            else
            {
                temp.AddRange(posmoves);
            }
            posmoves.Clear();
            posmoves.AddRange(temp);



            //twoturnfields!
            if (this.dirtyTwoTurnSim == 0 || isLethalCheck)
            {
                return;
            }
            tempDict.Clear();
            temp.Clear();
            if (bestoldval >= 10000)
            {
                return;
            }
            foreach (Playfield p in twoturnfields)
            {
                tempDict.Add(p.hashcode, p);
            }
            posmoves.Sort((a, b) => botBase.getPlayfieldValue(b).CompareTo(botBase.getPlayfieldValue(a)));

            int maxTts = Math.Min(posmoves.Count, this.dirtyTwoTurnSim);

            for (int i = 0; i < maxTts; i++)
            {
                if (!tempDict.ContainsKey(posmoves[i].hashcode))
                {
                    temp.Add(posmoves[i]);
                }
            }
            twoturnfields.Sort((a, b) => botBase.getPlayfieldValue(b).CompareTo(botBase.getPlayfieldValue(a)));
            temp.AddRange(twoturnfields.GetRange(0, Math.Min(this.dirtyTwoTurnSim, twoturnfields.Count)));
            twoturnfields.Clear();
            twoturnfields.AddRange(temp);
        }