コード例 #1
0
 internal void Append(FeiTing mostWanted)
 {
     this.Fire += mostWanted.Fire;
     this.Arm  += mostWanted.Arm;
     this.Mane += mostWanted.Mane;
     this.Luck += mostWanted.Luck;
 }
コード例 #2
0
 internal void Remove(FeiTing mostHated)
 {
     this.Fire -= mostHated.Fire;
     this.Arm  -= mostHated.Arm;
     this.Mane -= mostHated.Mane;
     this.Luck -= mostHated.Luck;
 }
コード例 #3
0
        internal int GetMostWantedValue(FeiTing args)
        {
            var items = new SortItem[]
            {
                new SortItem(args.Fire, 0),
                new SortItem(args.Arm, 0),
                new SortItem(args.Mane, 0),
                new SortItem(args.Luck, 0)
            };
            var sortItems = items.OrderBy(t => t.Val).ToArray();

            sortItems[0].Weight = 1;

            return(this.Fire * items[0].Weight + this.Arm * items[1].Weight
                   + this.Mane * items[2].Weight + this.Luck * items[3].Weight);
        }
コード例 #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var addedFire   = int.Parse(tbFire.Text);
                var addedArm    = int.Parse(tbArm.Text);
                var addedMane   = int.Parse(tbMane.Text);
                var addedLuck   = int.Parse(tbLuck.Text);
                var ftNumber    = int.Parse((FtNumber.SelectedItem as ComboBoxItem).Content.ToString());
                var ftHot       = int.Parse((FtHot.SelectedItem as ComboBoxItem).Content.ToString());
                var ftArray     = FTList.Where(t => t.IsChecked).ToArray();
                var sumProperty = new FeiTing("sum", addedFire, addedArm, addedMane, addedLuck);
                if (ftArray.Length < ftNumber)
                {
                    MessageBox.Show("选择数量过少");
                    return;
                }

                // 第一次捕获
                var loadedList = new List <FeiTing>();
                for (int i = 0; i < ftNumber; i++)
                {
                    var mostWanted = GetMostWanted(ftArray.Where(t => !loadedList.Contains(t)), sumProperty);
                    loadedList.Add(mostWanted);
                    sumProperty.Append(mostWanted);
                }

                // 第二次微调
                for (int i = 0; i < 10; i++)
                {
                    var diff = sumProperty.GetAverageDiff();
                    if (diff < 2)
                    {
                        break;
                    }

                    var mostHated = GetMostHated(loadedList, sumProperty);
                    var restList  = ftArray.Where(t => !loadedList.Contains(t));
                    var isHit     = false;
                    foreach (var item in restList)
                    {
                        var tmpSumProperty = sumProperty.Clone() as FeiTing;
                        tmpSumProperty.Remove(mostHated);
                        tmpSumProperty.Append(item);

                        var tmpDiff = tmpSumProperty.GetAverageDiff();
                        if (tmpDiff < diff)
                        {
                            loadedList.Remove(mostHated);
                            sumProperty.Remove(mostHated);

                            loadedList.Add(item);
                            sumProperty.Append(item);
                            isHit = true;
                            break;
                        }
                    }

                    if (!isHit)
                    {
                        break;
                    }
                }

                sumProperty.Name = string.Join("、", loadedList.Select(t => t.Name));
                var msg = string.Format("最佳飞艇组合:\n\t{0}\n四维属性:\n\t{1} {2} {3} {4}",
                                        sumProperty.Name,
                                        sumProperty.Fire + ftHot * ftNumber,
                                        sumProperty.Arm + ftHot * ftNumber,
                                        sumProperty.Mane + ftHot * ftNumber,
                                        sumProperty.Luck + ftHot * ftNumber);
                MessageBox.Show(msg);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #5
0
        private FeiTing GetMostHated(IEnumerable <FeiTing> list, FeiTing args)
        {
            var orderList = list.OrderBy(t => t.GetMostWantedValue(args));

            return(orderList.FirstOrDefault());
        }