Пример #1
0
        private ObservableCollection <string> gennereateCollection(CardStats card)
        {
            var cards = cont.getModel().cardsToDisplay;
            ObservableCollection <string> list = new ObservableCollection <string>();
            string name;

            foreach (CardStats c in cards)
            {
                name = c.card.GetNameType();
                if (name.Equals(card.card.GetNameType()))
                {
                }
                else
                {
                    list.Add(name);
                }
            }

            return(list);
        }
Пример #2
0
        public static SimulationResults runSimulation(ContainerClass container, SetupData setup)
        {
            foreach (var card in setup.Cardpool)
            {
                (card as ITrackable).Reset();
            }

            var Res = Simulator.RunSimulation(setup);

            //Get results back

            List <CardStats> ListWithCards = new List <CardStats>();

            //var winRatios = con.model.calculateWinRatio(ICards, Res.Decks);

            foreach (var card in Res.Cardpool)
            {
                var cardStats = new CardStats(card);

                //var wins = ((winRatios[card.GetNameType()])[0] * 1.0);
                //var fights = ((winRatios[card.GetNameType()])[1] * 1.0);
                var win_ratio = (card as ITrackable).GetWinLossRate(); //(wins / fights) * 100;//(card as ITrackable).GetWinLossRate();

                var win_ratio_int = Convert.ToInt32(win_ratio);

                cardStats.win_ratio = win_ratio_int;

                //cardStats.win_ratio = r.Next(0,100); //Random
                var dom = (card as ITrackable).GetDominance(card);

                cardStats.domminance = dom;
                cardStats.simulated  = true;
                cardStats.changed    = false;
                ListWithCards.Add(cardStats);
            }
            List <ICard> ICardsNOT = new List <ICard>();

            foreach (var card in container.getModel().cardsToDisplay)
            {
                if (!Res.Cardpool.Contains(card.card))
                {
                    ICardsNOT.Add(card.card);
                }
            }

            foreach (var card in ICardsNOT)
            {
                var cardStats = new CardStats(card);

                cardStats.win_ratio  = -1;
                cardStats.domminance = -1;
                cardStats.simulated  = false;
                cardStats.changed    = false;
                ListWithCards.Add(cardStats);
            }

            container.getModel().cardsToDisplay = ListWithCards;
            container.simulated = true;
            container.simulationCriteria.setup = setup;

            return(Res);
        }
Пример #3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            con = e.Parameter as ContainerClass;
            var cards = con.getModel().cardsToDisplay;

            EqualShareBox.IsEnabled = false;

            cardsToPresent = new ObservableCollection <listBoxExtra>();

            listBoxExtra l;

            foreach (var card in cards)
            {
                l               = new listBoxExtra();
                l.Height        = 45;
                l.Content       = card.card.GetNameType();
                l.Foreground    = new SolidColorBrush(Colors.Black);
                l.IsEnabled     = true;
                l.SelectedOrNot = true;
                l.card          = card;
                cardsToPresent.Add(l);
            }

            cardsBox.ItemsSource    = cardsToPresent;
            cardsToExamine          = cardsToPresent.Count();
            textBlock1_Copy13.Text  = "Cards to examine: " + cardsToExamine;
            checkBox.IsChecked      = true;
            EqualShareBox.IsChecked = true;

            if (!con.rankCriteriaReview)
            {
                OR_S.IsChecked       = true;
                OR_S_Copy.IsChecked  = true;
                OR_S_Copy1.IsChecked = true;
                OR_S_Copy2.IsChecked = true;
                OR_S_Copy3.IsChecked = true;

                Win_box_S.IsChecked       = true;
                Win_box_S_Copy.IsChecked  = true;
                Win_box_S_Copy1.IsChecked = true;
                Win_box_S_Copy2.IsChecked = true;
                Win_box_S_Copy3.IsChecked = true;

                Dom_box_S.IsChecked       = true;
                Dom_box_S_Copy.IsChecked  = true;
                Dom_box_S_Copy1.IsChecked = true;
                Dom_box_S_Copy2.IsChecked = true;
                Dom_box_S_Copy3.IsChecked = true;
                checkBox1.IsChecked       = true;
            }
            else
            {
                if (con.simulationCriteria.matchupStrategyType == MatchupStrategyType.All)
                {
                    checkBox1.IsChecked = true;
                }
                else
                {
                    checkBox1_Copy.IsChecked = true;
                }

                con.rankCriteriaReview = false;
                var rankCriteria = con.rankCriteria;
                AND_S.IsChecked       = rankCriteria.ands[0];
                AND_S_Copy.IsChecked  = rankCriteria.ands[1];
                AND_S_Copy1.IsChecked = rankCriteria.ands[2];
                AND_S_Copy2.IsChecked = rankCriteria.ands[3];
                AND_S_Copy3.IsChecked = rankCriteria.ands[4];

                OR_S.IsChecked       = rankCriteria.ors[0];
                OR_S_Copy.IsChecked  = rankCriteria.ors[1];
                OR_S_Copy1.IsChecked = rankCriteria.ors[2];
                OR_S_Copy2.IsChecked = rankCriteria.ors[3];
                OR_S_Copy3.IsChecked = rankCriteria.ors[4];

                Win_box_S.IsChecked       = rankCriteria.winRatio_t[0];
                Win_box_S_Copy.IsChecked  = rankCriteria.winRatio_t[1];
                Win_box_S_Copy1.IsChecked = rankCriteria.winRatio_t[2];
                Win_box_S_Copy2.IsChecked = rankCriteria.winRatio_t[3];
                Win_box_S_Copy3.IsChecked = rankCriteria.winRatio_t[4];

                Dom_box_S.IsChecked       = rankCriteria.domminance_t[0];
                Dom_box_S_Copy.IsChecked  = rankCriteria.domminance_t[1];
                Dom_box_S_Copy1.IsChecked = rankCriteria.domminance_t[2];
                Dom_box_S_Copy2.IsChecked = rankCriteria.domminance_t[3];
                Dom_box_S_Copy3.IsChecked = rankCriteria.domminance_t[4];

                Run_button.Click  -= Run_button_Click;
                Run_button.Click  += run_rank_click;
                Run_button.Content = "Rerun criteria";
            }
        }
Пример #4
0
        private void Run_button_Click(object sender, RoutedEventArgs e)
        {
            var          cards     = con.getModel().cardsToDisplay;
            List <ICard> ICards    = new List <ICard>();
            List <ICard> ICardsNOT = new List <ICard>();

            foreach (var card in cardsToPresent)
            {
                card.card.simulated = false;
                if (card.SelectedOrNot)
                {
                    ICards.Add(card.card.card);
                }
                else
                {
                    ICardsNOT.Add(card.card.card);
                }
            }

            //Run new simulation with criteria

            SetupData setup = SetupData.GetDefault();

            setup.MaxDuplicates = 1;
            setup.DeckSize      = 5;
            setup.Cardpool      = ICards;
            setup.StartCards    = 2;
            //setup.GamesEachDeckMustPlayMultiplier = 2; //Designer should be able to set this value as they want.

            SimulationCriteria sim = new SimulationCriteria(Int32.Parse(textBox_Copy3.Text));

            if (checkBox.IsChecked ?? false)
            {
                setup.DeckFactory   = DeckFactoryType.Unique;
                sim.deckFactoryType = DeckFactoryType.Unique;
            }
            else
            {
                setup.AmountOfDecksToGenerate = Int32.Parse(textBox.Text);
                setup.DeckFactory             = DeckFactoryType.Random;

                sim.deckFactoryType = DeckFactoryType.Unique;
                sim.NumberOfDecks   = Int32.Parse(textBox.Text);
            }

            setup.GamesEachDeckMustPlayMultiplier = Int32.Parse(textBox_Copy3.Text);
            sim.numberOfFightsPrDeck = Int32.Parse(textBox_Copy3.Text);

            if (checkBox1.IsChecked ?? false)
            {
                setup.matchupStrategyType = MatchupStrategyType.All;
                sim.matchupStrategyType   = MatchupStrategyType.All;
            }
            else
            {
                setup.matchupStrategyType    = MatchupStrategyType.SpecifiedAmount;
                setup.specifiedMatchupAmount = Int32.Parse(textBox_Copy3.Text);

                sim.matchupStrategyType    = MatchupStrategyType.SpecifiedAmount;
                sim.specifiedMatchupAmount = Int32.Parse(textBox_Copy3.Text);
            }
            con.simulationCriteria       = sim;
            con.simulationCriteria.setup = setup;
            var res = runSimulation(con, setup);

            var rankCriteria = new RankCriteria();

            rankCriteria.ands[0] = AND_S.IsChecked ?? false;
            rankCriteria.ands[1] = AND_S_Copy.IsChecked ?? false;
            rankCriteria.ands[2] = AND_S_Copy1.IsChecked ?? false;
            rankCriteria.ands[3] = AND_S_Copy2.IsChecked ?? false;
            rankCriteria.ands[4] = AND_S_Copy3.IsChecked ?? false;

            rankCriteria.ors[0] = OR_S.IsChecked ?? false;
            rankCriteria.ors[1] = OR_S_Copy.IsChecked ?? false;
            rankCriteria.ors[2] = OR_S_Copy1.IsChecked ?? false;
            rankCriteria.ors[3] = OR_S_Copy2.IsChecked ?? false;
            rankCriteria.ors[4] = OR_S_Copy3.IsChecked ?? false;

            rankCriteria.winRatio_t[0] = Win_box_S.IsChecked ?? false;
            rankCriteria.winRatio_t[1] = Win_box_S_Copy.IsChecked ?? false;
            rankCriteria.winRatio_t[2] = Win_box_S_Copy1.IsChecked ?? false;
            rankCriteria.winRatio_t[3] = Win_box_S_Copy2.IsChecked ?? false;
            rankCriteria.winRatio_t[4] = Win_box_S_Copy3.IsChecked ?? false;

            rankCriteria.domminance_t[0] = Dom_box_S.IsChecked ?? false;
            rankCriteria.domminance_t[1] = Dom_box_S_Copy.IsChecked ?? false;
            rankCriteria.domminance_t[2] = Dom_box_S_Copy1.IsChecked ?? false;
            rankCriteria.domminance_t[3] = Dom_box_S_Copy2.IsChecked ?? false;
            rankCriteria.domminance_t[4] = Dom_box_S_Copy3.IsChecked ?? false;

            Win_S.Text       = Win_S.Text.Replace('%', ' ');
            Win_S_Copy.Text  = Win_S_Copy.Text.Replace('%', ' ');
            Win_S_Copy1.Text = Win_S_Copy1.Text.Replace('%', ' ');
            Win_S_Copy2.Text = Win_S_Copy2.Text.Replace('%', ' ');
            Win_S_Copy3.Text = Win_S_Copy3.Text.Replace('%', ' ');

            rankCriteria.winRatio[0] = Int32.Parse(Win_S.Text);
            rankCriteria.winRatio[1] = Int32.Parse(Win_S_Copy.Text);
            rankCriteria.winRatio[2] = Int32.Parse(Win_S_Copy1.Text);
            rankCriteria.winRatio[3] = Int32.Parse(Win_S_Copy2.Text);
            rankCriteria.winRatio[4] = Int32.Parse(Win_S_Copy3.Text);

            rankCriteria.domminance[0] = Double.Parse(Dom_S.Text);
            rankCriteria.domminance[1] = Double.Parse(Dom_S_Copy.Text);
            rankCriteria.domminance[2] = Double.Parse(Dom_S_Copy1.Text);
            rankCriteria.domminance[3] = Double.Parse(Dom_S_Copy2.Text);
            rankCriteria.domminance[4] = Double.Parse(Dom_S_Copy3.Text);

            con.rankCriteria = rankCriteria;

            this.Frame.Navigate((typeof(MainPage)), con);
        }