Esempio n. 1
0
    private SpellMap TryCalcSpellMap(List <Order> orders, ImmutableStack <Spell> baseSpell, List <Spell> spellForLearn,
                                     List <Learn> tomeSpell, int depth, Stopwatch sw)
    {
        var spellForSearch = baseSpell;

        foreach (var s in spellForLearn)
        {
            spellForSearch = spellForSearch.Push(s);
        }

        var pathFinder = new OrderPathFinder(timeout: timeout, depth);
        var paths      = pathFinder.FindOrderPaths(orders, spellForSearch, sw);

        for (var i = 0; i < orders.Count; i++)
        {
            if (orders[i].Price < minOrderPrice)
            {
                paths[i].Clear();
            }
        }
        var(score, order) = GetScore(orders, paths, baseSpell.ToList(), spellForLearn);
        return(new SpellMap(order, paths, score.points, score.length, orders, tomeSpell));
    }
Esempio n. 2
0
        public void Test1()
        {
            var allSpells = GetAllSpells().ToList();

            var startSpell = ImmutableStack <Spell> .Instance
                             .Push(allSpells[0])
                             .Push(allSpells[1])
                             .Push(allSpells[2])
                             .Push(allSpells[3]);

            //.Push(allSpells[15])
            //.Push(allSpells[27])
            //.Push(allSpells[31])
            //.Push(allSpells[9])
            //.Push(allSpells[7])
            //.Push(allSpells[11]);

            //var startSpell = ImmutableStack<Spell>.Instance;

            //foreach (var spell in allSpells)
            //{
            //    var excluded = new int[0];
            //    //{
            //    // //   121, 120, 119, 118, 117, 109, 108, 107, 101, // образующие элементы. (8 / 42)
            //    //    //найти популярные продолжения (2) посчитать "потенциальную" стоимость префикса
            //    //    //как только ты заканчиваешь текщее зелье (если ты его варишь..)
            //    //    //забываешь в переборе про
            //    //};
            //    if (!excluded.Contains(spell.Id))
            //        startSpell = startSpell.Push(spell);
            //}

            //var spells = ImmutableStack<Spell>.Instance;
            //foreach (var spell in startSpell)
            //{
            //    spells = spells.Push(spell);
            //}

            //var orders = OrderReceipts;
            var orders = new List <Order>
            {
                OrderReceipts[2],
                OrderReceipts[7],
                OrderReceipts[22],
                OrderReceipts[31],
                OrderReceipts[13],
            };

            var sw = new Stopwatch();
            var orderPathFinder = new OrderPathFinder();
            var shortPaths      = orderPathFinder.FindOrderPaths(orders, startSpell, sw);

            Console.WriteLine(sw.ElapsedMilliseconds);

            Console.WriteLine($"Total path: {shortPaths.SelectMany(x => x).Count()}");

            var cnt = shortPaths.SelectMany(x => x)
                      .SelectMany(x => x.GetActions())
                      .Where(x => x is Spell)
                      .Select(x => ((Spell)x).Id)
                      .Where(x => x > 104)
                      .ToHashSet()
                      .Count;

            Console.WriteLine($"Total new spells: {cnt}");

            for (var i = 0; i < orders.Count; i++)
            {
                var sb = new StringBuilder($"{orders[i].Tiers}: |\r\n");
                if (shortPaths[i].Count != 0)
                {
                    foreach (var path in shortPaths[i])
                    {
                        sb.AppendLine($"\t{path}");
                    }
                }

                Console.WriteLine(sb);
            }
        }