Exemple #1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="f">孩子花朵</param>
 /// <param name="probability">生成概率</param>
 public ChildCard(MyFlower p1, MyFlower p2, MyFlower f, float p)
 {
     Child       = f;
     Parent1     = p1;
     Parent2     = p2;
     probability = p;
 }
Exemple #2
0
        public List <MyFlower> GetChildren()
        {
            List <MyFlower> mList = new List <MyFlower>();

            if ((Gene)a4 != Gene.Unknown)
            {
                if (a1 < 4 || a2 < 4 || a3 < 4 || a4 < 4)
                {
                    return(mList);
                }

                var aa = GetGeneAAName();
                string[,] child = new string[, ] {
                    { aa[0].ToString(), aa[1].ToString() },
                    { aa[2].ToString(), aa[3].ToString() },
                    { aa[4].ToString(), aa[5].ToString() },
                    { aa[6].ToString(), aa[7].ToString() },
                };

                List <string> ls = new List <string>();
                Permutation(ref ls, child, "");
                foreach (var s in ls)
                {
                    MyFlower ll = new MyFlower(
                        type,
                        (Gene)Enum.Parse(typeof(Gene), s[0].ToString()),
                        (Gene)Enum.Parse(typeof(Gene), s[1].ToString()),
                        (Gene)Enum.Parse(typeof(Gene), s[2].ToString()),
                        (Gene)Enum.Parse(typeof(Gene), s[3].ToString())
                        );
                    mList.Add(ll);
                }
            }
            else
            {
                if (a1 < 4 || a2 < 4 || a3 < 4)
                {
                    return(mList);
                }

                var aa = GetGeneAAName();
                string[,] child = new string[, ] {
                    { aa[0].ToString(), aa[1].ToString() },
                    { aa[2].ToString(), aa[3].ToString() },
                    { aa[4].ToString(), aa[5].ToString() }
                };

                List <string> ls = new List <string>();
                Permutation(ref ls, child, "");
                foreach (var s in ls)
                {
                    MyFlower ll = new MyFlower(
                        type,
                        (Gene)Enum.Parse(typeof(Gene), s[0].ToString()),
                        (Gene)Enum.Parse(typeof(Gene), s[1].ToString()),
                        (Gene)Enum.Parse(typeof(Gene), s[2].ToString())
                        );
                    mList.Add(ll);
                }
            }
            return(mList);
        }