void HoningTest(
            HSCardExpasionConfiguration config,
            HSHoningBayes fixedBayes,
            KNNEfficiency fixedKNN,
            int mana,
            int maxCards,
            HoningNetwork <String> net,
            Dictionary <String, CardObject> cardTable,
            String seed,
            HSCardOperator op,
            ExpansionGeneralPolitics pol,
            out List <String> combo,
            out double creativity,
            out double efficiency,
            out double surprise)
        {
            config.maxCards   = maxCards;
            config.total_mana = mana;
            List <List <String> > out_subcluster;
            List <String>         out_combo;

            op.GreedyExpansionDelegated(
                ref net,
                ref config,
                ref cardTable,
                pol,
                PriorityPolitics.Random,
                PriorityPolitics.Random,
                seed,
                out out_subcluster,
                out out_combo);

            // Context filter
            int voidCount = 0;

            for (int i = 0; i < out_combo.Count; i++)
            {
                if (out_combo[i] == "")
                {
                    voidCount++;
                }
            }

            while (voidCount > 0)
            {
                out_combo.Remove("");
                voidCount--;
            }

            // Surprise
            ComboNode comboNode = ToComboNode(out_combo);

            double[] surpriseVector;
            fixedBayes.CalculateSurprise(ref comboNode, 1, out surpriseVector, out surprise, true);

            // Calculate efficiency
            Double[] efficiencyVector;
            config.bayes.GenerateComboVector(ref comboNode, out efficiencyVector);
            Instance knnInstance = new Instance(efficiencyVector);

            efficiency = config.knn.getKNearestWinrates(knnInstance, 5);

            // Percent
            efficiency /= 100;

            // Calculate creativity
            creativity = ((surprise / config.highestSurprise) + efficiency) / 2;

            // Combo return
            combo = out_combo;
        }
Пример #2
0
        public void PopulateFromHoningNetwork(ref HSDecksParser decks, ref Dictionary <String, CardObject> cardTable, int mana_mult)
        {
            combos_per_card    = 10;
            combos_by_quantity = new Dictionary <string, Dictionary <int, List <ComboNode> > >();

            // Hero loop
            foreach (String hero in decks.decks_by_hero.Keys)
            {
                // Decks loop
                foreach (HSDeckInfo deckinfo in decks.decks_by_hero[hero])
                {
                    // Generate honingNet for the deck
                    HoningNetwork <String> deck_net      = new HoningNetwork <string>();
                    List <CardObject>      cards_objects = new List <CardObject>();
                    HoningStoneBuilder     builder       = new HoningStoneBuilder();

                    // Generate card table info to populate the honingNetwork
                    foreach (String card in deckinfo.cards)
                    {
                        if (cardTable.ContainsKey(card))
                        {
                            cards_objects.Add(cardTable[card]);
                        }
                    }

                    builder.PopulateFromCardData(ref deck_net, ref cards_objects);
                    builder.BuildThirdLevel(ref deck_net, ref cards_objects);

                    // Generate all combos
                    HSCardOperator op = new HSCardOperator();
                    HSCardExpasionConfiguration conf = new HSCardExpasionConfiguration(null, null);

                    for (int j = 1; j < mana_mult; j++)
                    {
                        // Mana to spend on combo
                        conf.total_mana = 10 * j;

                        // Same deck insertion flag
                        bool same_deck = false;
                        foreach (String card in deckinfo.cards)
                        {
                            for (int i = 0; i < combos_per_card; i++)
                            {
                                List <List <String> > combo;
                                List <String>         sCombo;
                                op.GreedyExpansionDelegated(
                                    ref deck_net,
                                    ref conf,
                                    ref cardTable,
                                    ExpansionGeneralPolitics.Random,
                                    PriorityPolitics.Random,
                                    PriorityPolitics.Random,
                                    card,
                                    out combo,
                                    out sCombo);

                                // Create new combo object(Node) or get an existing one
                                Dictionary <String, String> comboToFind = new Dictionary <string, string>();
                                foreach (String c in sCombo)
                                {
                                    comboToFind.Add(c, c);
                                }

                                if (comboToFind.Count == 0)
                                {
                                    continue;
                                }

                                ComboNode new_combo = FindCombo(ref comboToFind, hero);

                                if (new_combo == null)
                                {
                                    new_combo = new ComboNode();
                                    if (!combos_by_quantity.ContainsKey(hero))
                                    {
                                        combos_by_quantity.Add(hero, new Dictionary <int, List <ComboNode> >());
                                    }
                                    if (!combos_by_quantity[hero].ContainsKey(comboToFind.Count))
                                    {
                                        combos_by_quantity[hero].Add(comboToFind.Count, new List <ComboNode>());
                                    }


                                    // Configura winrate for this combo
                                    float comboWinrate;
                                    float.TryParse(deckinfo.winrate, out comboWinrate);
                                    new_combo.winrates.Add(comboWinrate);
                                    new_combo.combo = comboToFind;

                                    // Add the combo to the master holder
                                    combos_by_quantity[hero][comboToFind.Count].Add(new_combo);
                                }
                                else
                                {
                                    if (!same_deck && new_combo.combo.Count != 0)
                                    {
                                        float comboWinrate;
                                        float.TryParse(deckinfo.winrate, out comboWinrate);
                                        new_combo.winrates.Add(comboWinrate);
                                    }
                                }

                                same_deck = true;
                            }
                        } // end foreach card
                    }     // end for manda
                }         // end foreach deck
            }             // end foreach hero
        }