コード例 #1
0
        public void Init(StatisticsCollection collection, Core core)
        {
            mCore       = core;
            mCollection = collection;

            foreach (var name in collection.StatisticsNames)
            {
                Series current = new Series(name, 100);
                Series mean    = new Series(name + " Mean", 100);

                current.ChartType = SeriesChartType.Line;
                mean.ChartType    = SeriesChartType.Line;

                sharedGraph.Series.Add(current);
                sharedGraph.Series.Add(mean);

                namesList.Items.Add(name);

                ListViewItem row = new ListViewItem(name);
                //row.SubItems.Add(name);
                row.SubItems.Add("0");
                row.SubItems.Add("0");
                row.SubItems.Add("0");
                row.SubItems.Add("0");
                statsList.Items.Add(row);

                mCurrentSeries.Add(name, current);
                mMeanSeries.Add(name, mean);
                mRows.Add(name, row);
            }
        }
コード例 #2
0
        protected override void PrintAgent()
        {
            base.PrintAgent();

            if (!this.LogStatistics)
            {
                return;
            }

            var emotionalQuantityList = new StatisticsCollection
            {
                { CONTROL_STAT_ID, this.testStatisticsAvg[CONTROL_STAT_ID] },
                { VALENCE_STAT_ID, this.testStatisticsAvg[VALENCE_STAT_ID] },
                { GOAL_REL_STAT_ID, this.testStatisticsAvg[GOAL_REL_STAT_ID] },
                { NOVELTY_STAT_ID, this.testStatisticsAvg[NOVELTY_STAT_ID] }
            };

            emotionalQuantityList.PrintAllQuantitiesToCSV(string.Format("{0}/Emotions/DimensionsAvg.csv", this.FilePath));

            //emotionalQuantityList.Clear();
            //foreach (var emotionLabel in this.emotionLabels)
            //    emotionalQuantityList.Add(emotionLabel, this.testStatisticsAvg[emotionLabel));

            //StatisticsUtil.PrintAllQuantitiesToCSV(this.FilePath + "/Emotions/LabelsAvg.csv", emotionalQuantityList);
            //StatisticsUtil.PrintAllQuantitiesCountToXLS(this.FilePath + "/Emotions/LabelsCountAvg.csv",
            //                                     emotionalQuantityList);
        }
コード例 #3
0
        /// <summary>
        /// Load the requested file/match
        /// </summary>
        /// <returns></returns>
        public async Task Load(String Filename)
        {
            try
            {
                //Load the data
                String XML = await Helpers.LocalStorage.Load(Filename);

                //CompressedXML = "";
                //Deserialize
                TennisMatch StoredMatch = (TennisMatch)Helpers.Serializer.XMLDeserialize(XML, typeof(TennisMatch));

                //Restore references

                //Set it as the current match
                Match = StoredMatch;
                StatisticsCollection.SetSource(_Match);
            }
            catch (Exception)
            {
                ExtendedEventArgs eea = new ExtendedEventArgs();
                eea.Error = "An error occured while loading the stored match";
                OnFatalError(eea);
                //throw new Exception();
            }
        }
コード例 #4
0
 public virtual void Dispose()
 {
     this.LogWriter?.Close();
     this.testStatisticsAvg?.Dispose();
     this.testStatisticsAvg = null;
     this.FinalScores?.Dispose();
 }
コード例 #5
0
 public static void PrintAllQuantitiesToImage(
     this StatisticsCollection statisticalQuantities, string filePath,
     ChartType chartType = ChartType.Line, ChartImageFormat imageFormat = ChartImageFormat.Png,
     int width           = 1024, int height = 768)
 {
     CreateAndPrintChart(statisticalQuantities, filePath, "Chart", chartType, width, height, imageFormat);
 }
コード例 #6
0
        private static Dictionary <string, IEnumerable <DataErrorPoint> > CreateDataPointCollection(
            StatisticsCollection statisticalQuantities)
        {
            var dictionary = new Dictionary <string, IEnumerable <DataErrorPoint> >();

            foreach (var quantity in statisticalQuantities)
            {
                if (quantity.Value.Samples == null)
                {
                    continue;
                }
                var samples    = quantity.Value.Samples;
                var dataPoints = new List <DataErrorPoint>();
                for (var i = 0; i < quantity.Value.SampleCount; i++)
                {
                    var sample = samples[i];
                    var data   = new DataPoint(i, sample.Mean);
                    var error  = new ScatterErrorPoint(i, sample.Mean, 0, sample.StandardError);
                    var point  = new DataErrorPoint {
                        Data = data, Error = error
                    };
                    dataPoints.Add(point);
                }

                //only add >0 point series
                if (dataPoints.Count > 0)
                {
                    dictionary.Add(quantity.Key, dataPoints);
                }
            }
            return(dictionary);
        }
コード例 #7
0
        public QuantitiesForm(string title, string filePath, StatisticsCollection quantities)
        {
            InitializeComponent();

            this._filePath        = filePath;
            this.Chart.Quantities = quantities;
            this.Chart.Title      = title;
        }
コード例 #8
0
        public static PlotModel CreateChart(
            this StatisticsCollection statisticalQuantities,
            string chartName, ChartType chartType = ChartType.Line)
        {
            var data = CreateDataPointCollection(statisticalQuantities);

            return(PlottingUtil.CreatePlotModel(data, chartName, chartType));
        }
コード例 #9
0
        public ConditionTrigger(Core core, string name)
        {
            mCore         = core;
            mTickListener = new Action(mCoordinator_Tick);

#if DEBUG
            StatisticsCollection.AddStatistics(mStatistics, name + " Trigger");
        #endif
        }
コード例 #10
0
ファイル: MousePlugin.cs プロジェクト: veyvin/ChimeraClean
        public MousePlugin()
        {
            PluginConfig cfg = new PluginConfig();

            mTickListener = new Action(mCore_Tick);

#if DEBUG
            StatisticsCollection.AddStatistics(mStatistics, "Mouse Plugin");
#endif
        }
コード例 #11
0
        protected void PrintActionsStatistics()
        {
            //prints action info
            var actionQuantitiesList = new StatisticsCollection();

            actionQuantitiesList.AddRange(this.lastSimulation.Agent.Actions.Keys.ToDictionary(
                                              actionID => actionID,
                                              quantityName => this.testStatisticsAvg[quantityName]));
            actionQuantitiesList.PrintAllQuantitiesToCSV($"{this.FilePath}/Behavior/ActionsAvg.csv");
            actionQuantitiesList.PrintAllQuantitiesToImage($"{this.FilePath}/Behavior/ActionsAvg.png");
        }
コード例 #12
0
ファイル: KBMousePlugin.cs プロジェクト: veyvin/ChimeraClean
        public KBMousePlugin()
        {
            PluginConfig cfg = new PluginConfig();

            mEnabled = cfg.KeyboardEnabled;

            mTickListener = new Action(mCoordinator_Tick);

#if DEBUG
            StatisticsCollection.AddStatistics(mStatistics, Name);
#endif
        }
コード例 #13
0
        /// <summary>
        /// Initialise the fade transition, specifying how long the fade should last, in ms.
        /// </summary>
        /// <param name="transition">The transition this fade is part of.</param>
        /// <param name="manager">The window this fade is to be drawn on.</param>
        /// <param name="lengthMS">The length of time, in ms, the fade should last.</param>
        public OpacityFadeWindowTransition(StateTransition transition, FrameOverlayManager manager, double lengthMS, bool fadeIn)
            : base(transition, manager)
        {
            mLengthMS     = lengthMS;
            mFadeIn       = fadeIn;
            mTickListener = new Action(Coordinator_Tick);

            Finished += new Action <IWindowTransition>(OpacityFadeWindowTransition_Finished);

#if DEBUG
            StatisticsCollection.AddStatistics(mStatistics, transition.Name + " " + manager.Name);
#endif
        }
コード例 #14
0
ファイル: GamepadManager.cs プロジェクト: veyvin/ChimeraClean
        public static void Init(ITickSource source)
        {
            if (!sTracking)
            {
                GetController();
                source.Tick += new Action(source_Tick);
                sTracking    = true;

#if DEBUG
                StatisticsCollection.AddStatistics(sStatistics, "GamepadManager");
#endif
            }
        }
コード例 #15
0
        private Task DecorateChart(StatisticsCollection stats, List <TimelineModel> timeline)
        {
            #region BarChart
            foreach (var s in stats.data)
            {
                if (s.RegionName.Equals("Central Visayas"))
                {
                    statisticsModel.DeceasedCount  = s.DeceasedCount;
                    statisticsModel.CasesCount     = s.CasesCount;
                    statisticsModel.RecoveredCount = s.RecoveredCount;
                    statisticsModel.RegionName     = s.RegionName;
                    RaisePropertyChanged(() => StatisticsModel);
                    break;
                }
            }

            for (int l = timeline.Count - 8; l < timeline.Count; l++)
            {
                LineConfirmed.Add(new Microcharts.Entry(timeline[l].Confirmed)
                {
                    Color      = SKColor.Parse(chartColors[l % 7]),
                    ValueLabel = timeline[l].Confirmed.ToString("#,#", CultureInfo.InvariantCulture),
                    Label      = timeline[l].Date.Replace("-2020", string.Empty)
                });

                LineDiseased.Add(new Microcharts.Entry(timeline[l].Deaths)
                {
                    Color      = SKColor.Parse(chartColors[l % 7]),
                    ValueLabel = timeline[l].Deaths.ToString("#,#", CultureInfo.InvariantCulture),
                    Label      = timeline[l].Date.Replace("-2020", string.Empty)
                });

                LineRecovered.Add(new Microcharts.Entry(timeline[l].Recovered)
                {
                    Color      = SKColor.Parse(chartColors[l % 7]),
                    ValueLabel = timeline[l].Recovered.ToString("#,#", CultureInfo.InvariantCulture),
                    Label      = timeline[l].Date.Replace("-2020", string.Empty)
                });
            }

            DailyUpdateChart = new BarChart()
            {
                Entries         = LineConfirmed,
                LabelTextSize   = 40,
                BackgroundColor = SKColors.Transparent
            };
            #endregion

            return(Task.CompletedTask);
        }
コード例 #16
0
        protected virtual StatisticsCollection GetFitnessQuantityList()
        {
            var cumulativeFitnessAvgList = new StatisticsCollection();

            foreach (var testParameters in this)
            {
                var testMeasure = this[testParameters];
                if ((testMeasure.Quantity != null) &&
                    !cumulativeFitnessAvgList.ContainsKey(testMeasure.ToString()))
                {
                    cumulativeFitnessAvgList.Add(testMeasure.ToString(), testMeasure.Quantity);
                }
            }
            return(cumulativeFitnessAvgList);
        }
コード例 #17
0
        public static void Main(string[] args)
        {
            var baseFilter = new HotslogsFilter
            {
                Mode         = (GameMode)Enum.Parse(typeof(GameMode), Settings.Default.BaseWinrateGameMode),
                LookbackDays = Settings.Default.BaseWinrateNumberOfDays > 0 ? Settings.Default.BaseWinrateNumberOfDays : (int?)null
            };
            var adjFilter = new HotslogsFilter
            {
                Mode         = (GameMode)Enum.Parse(typeof(GameMode), Settings.Default.AdjustmentsGameMode),
                LookbackDays = Settings.Default.AdjustmentsNumberOfDays > 0 ? Settings.Default.AdjustmentsNumberOfDays : (int?)null
            };
            var stats = StatisticsCollection.FromHotslogsExport(Settings.Default.HotsLogsExportPath, baseFilter, adjFilter);

            stats.SerializeToFile(Settings.Default.ExtractDestinationPath);
        }
コード例 #18
0
        protected void PrintEmotionDimensions(string filePath)
        {
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            var allDimensions = new StatisticsCollection();

            allDimensions.Add(this.emotionalSTM.Mood.Id, this.emotionalSTM.Mood);
            allDimensions.Add(this.emotionalSTM.Clarity.Id, this.emotionalSTM.Clarity);
            foreach (var dimension in this.emotionalSTM.AppraisalSet.Dimensions.Values)
            {
                allDimensions.Add(dimension.Id, dimension);
            }

            allDimensions.PrintAllQuantitiesToCSV(filePath);
        }
コード例 #19
0
        public static PlotModel CreateAndPrintChart(
            this StatisticsCollection statisticalQuantities,
            string filePath, string chartName, ChartType chartType = ChartType.Line,
            int width = 640, int height = 480, ChartImageFormat imageFormat = ChartImageFormat.Png)
        {
            var dataCollection = CreateDataPointCollection(statisticalQuantities);

            //ignore if no data
            if (dataCollection.Count == 0)
            {
                return(null);
            }

            //creates chart
            var chartModel = PlottingUtil.CreateAndPrintChart(
                dataCollection, filePath, chartName, chartType, width, height, imageFormat);

            return(chartModel);
        }
コード例 #20
0
        protected virtual StatisticsCollection GetPopulationStatsCollectionAvg(IPopulation population)
        {
            if ((population == null) || (population.Count == 0))
            {
                return(null);
            }
            var popStatsCollectionAvg = new StatisticsCollection();

            //for each agent statistic
            foreach (var statKey in population[0].StatisticsCollection.Keys)
            {
                //average statistic between all agents
                var stat = StatisticalQuantity.GetQuantitiesAverage(
                    population.Select(ag => ag.StatisticsCollection[statKey]).ToList());

                popStatsCollectionAvg.Add(statKey, stat);
            }
            return(popStatsCollectionAvg);
        }
コード例 #21
0
        protected virtual void PrintAgent(uint agentIdx)
        {
            this.WriteLine($@"Printing {agentIdx} statistical quantities...");

            //this.PrintAgentQuantity(agentID, "StateActionValue", "/" + agentID + "/STM/StateActionValueAvg.csv");
            this.PrintAgentQuantity(agentIdx, "Epsilon", $"/{agentIdx}/Learning/EpsilonAvg.csv");
            //this.PrintAgentQuantity(agentID, "PredictionError", "/" + agentID + "/Learning/PredictionErrorAvg.csv");
            //this.PrintAgentQuantity(agentID, "NumBackups", string.Format("/{0}/Learning/NumBackups.csv", agentID));

            var rewardQuantityList =
                new StatisticsCollection
            {
                //{"Reward", this.GetAgentQuantityAverage(agentID, "Reward")},
                { "ExtrinsicReward", this.GetAgentQuantityAverage(agentIdx, "ExtrinsicReward") },
                { "IntrinsicReward", this.GetAgentQuantityAverage(agentIdx, "IntrinsicReward") }
            };

            rewardQuantityList.PrintAllQuantitiesToCSV($"{this.FilePath}/{agentIdx}/STM/RewardAvg.csv");
        }
コード例 #22
0
        private void DoLoad()
        {
            Ready = false;
            Task <StatisticsCollection> loadTask;

            if (Settings.Default.UseRawHotslogsExport)
            {
                loadTask = Task.Factory.StartNew(() =>
                {
                    var baseFilter = new HotslogsFilter
                    {
                        Mode         = (GameMode)Enum.Parse(typeof(GameMode), Settings.Default.BaseWinrateGameMode),
                        LookbackDays = Settings.Default.BaseWinrateNumberOfDays > 0 ? Settings.Default.BaseWinrateNumberOfDays : (int?)null
                    };
                    var adjFilter = new HotslogsFilter
                    {
                        Mode         = (GameMode)Enum.Parse(typeof(GameMode), Settings.Default.AdjustmentsGameMode),
                        LookbackDays = Settings.Default.AdjustmentsNumberOfDays > 0 ? Settings.Default.AdjustmentsNumberOfDays : (int?)null
                    };
                    return(StatisticsCollection.FromHotslogsExport(Settings.Default.HotsLogsExportPath, baseFilter, adjFilter));
                });
            }
            else
            {
                loadTask = Task.Factory.StartNew(() => StatisticsCollection.DeserializeFromFile(Settings.Default.DraftDataPath));
            }

            loadTask.ContinueWith(r =>
            {
                Ready = true;
                if (r.IsFaulted)
                {
                    LoadError = "Failed to load: " + r.Exception.Message;
                }
                else if (r.IsCompleted)
                {
                    LoadError = null;
                    _stats    = r.Result;
                    ReInit();
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
コード例 #23
0
        protected override void PrintAgent()
        {
            base.PrintAgent();

            if (!this.LogStatistics)
            {
                return;
            }

            this.PrintStatistic("NumBackups", "/Learning/NumBackupsAvg.csv");

            var rewardQuantityList = new StatisticsCollection
            {
                //{"Reward", this.GetAgentQuantityAverage("Reward")},
                { "ExtrinsicReward", this.testStatisticsAvg["ExtrinsicReward"] },
                { "IntrinsicReward", this.testStatisticsAvg["IntrinsicReward"] }
            };

            rewardQuantityList.PrintAllQuantitiesToCSV(this.FilePath + "/STM/RewardAvg.csv");
        }
コード例 #24
0
ファイル: AxisBasedDelta.cs プロジェクト: veyvin/ChimeraClean
        /// <summary>
        /// Input axes will automatically be assigned to camera axes if no axis is specified.
        /// The ordering is as follows:
        /// 1st axis: x
        /// 2nd axis: y
        /// 3rd axis: z
        /// 4th axis: pitch
        /// 5th axis : yaw
        /// Specify null if you do not which to assign that axis.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="axes"></param>
        public AxisBasedDelta(string name, AxisConfig config, params IAxis[] axes)
        {
            Logger  = LogManager.GetLogger(name);
            mName   = name;
            mConfig = config;

            mTickListener = new Action(mCore_Tick);

            foreach (var axis in axes)
            {
                if (axis != null)
                {
                    AddAxis(axis);
                }
            }

#if DEBUG
            StatisticsCollection.AddStatistics(mStatistics, name);
#endif
        }
コード例 #25
0
        protected override void PrintPerformanceResults()
        {
            //prints agents' cumulative fitness
            this.WriteLine(@"Printing agents' performances...");

            if (this.TestsConfig.StoreIndividualAgentStats)
            {
                var agentsFitnessList = new StatisticsCollection();
                for (uint i = 0; i < this.TestsConfig.NumAgents; i++)
                {
                    agentsFitnessList.Add($"Agent{i}",
                                          this.testStatisticsAvg[this.GetAgentFitnessStatID(i)]);
                }

                agentsFitnessList.PrintAllQuantitiesToCSV($"{this.FilePath}/AgentsCumulativeFitnessAvg.csv");
                //agentsFitnessList.PrintAllQuantitiesToImage($"{this.FilePath}/AgentsCumulativeFitnessAvg.png");
            }

            //prints overall cumulative fitness
            this.SimulationScoreAvg.PrintStatisticsToCSV($"{this.FilePath}/CumulativeFitnessAvg.csv");
            this.FinalScores.PrintStatisticsToCSV($"{this.FilePath}/CumulativeFitnessValues.csv", false, true, ChartType.Column);
        }
コード例 #26
0
        protected virtual void AverageTestStatistics(Simulation simulation)
        {
            //stores and replaces ref to last simulation
            if (this.lastSimulation != null)
            {
                if (this.lastSimulation.Equals(simulation))
                {
                    return;
                }
                else
                {
                    this.lastSimulation.Dispose();
                }
            }
            this.lastSimulation = simulation;

            //adds cumulative (final) value to statistical variable
            this.FinalScores.Value = simulation.Score.Value;
            if (!this.LogStatistics)
            {
                return;
            }

            //stores or averages tests' statistics
            if (this.testStatisticsAvg == null)
            {
                this.testStatisticsAvg = this.GetTestStatistics(simulation);
            }
            else
            {
                this.testStatisticsAvg.AverageWith(this.GetTestStatistics(simulation));
            }

            //removes simulation from list
            this.currentSimulations.Remove(simulation);
        }
コード例 #27
0
        public Step(FlythroughState state, XmlNode node, Text subtitlesText, int subtitleTimeoutS, IMediaPlayer player)
        {
            if (node.Attributes["St››ep"] == null && !int.TryParse(node.Attributes["Step"].Value, out mStep))
            {
                throw new ArgumentException("Unable to load slideshow step. A valid 'Step' attribute must be supplied.");
            }

#if DEBUG
            if (sStatistics == null)
            {
                sStatistics = new TickStatistics();
                StatisticsCollection.AddStatistics(sStatistics, "Flythrough Steps");
            }
#endif

            mPlayer  = player;
            mManager = state.Manager;
            mStep    = GetInt(node, -1, "Step");
            if (mStep == -1)
            {
                throw new ArgumentException("Unable to load step ID. A valid Step attribute is expected.");
            }

            XmlAttribute voiceoverAttribute = node.Attributes["Voiceover"];
            if (voiceoverAttribute != null && File.Exists(Path.GetFullPath(voiceoverAttribute.Value)))
            {
                if (mPlayer != null)
                {
                    mVoiceoverFile = Path.GetFullPath(voiceoverAttribute.Value);
                }
                else
                {
                    Logger.Warn("Unable to load voiceover for flythrough step. No MediaPlayer supplied.");
                }
            }

            mSubtitlesText = subtitlesText;

            XmlNode newFontNode = node.SelectSingleNode("child::SubtitlesFont");
            if (newFontNode != null)
            {
                mNewSubtitlesFont = state.Manager.MakeText(newFontNode);
            }

            if (mSubtitlesText != null)
            {
                mTickListener     = new Action(mCoordinator_Tick);
                mSubtitleTimeoutS = subtitleTimeoutS;
                XmlNode subtitlesNode = node.SelectSingleNode("child::Subtitles");
                if (subtitlesNode != null)
                {
                    foreach (XmlNode child in subtitlesNode.ChildNodes)
                    {
                        if (child is XmlElement)
                        {
                            double time = child.Attributes["Time"] != null?double.Parse(child.Attributes["Time"].Value) : 0;

                            mSubtitles.Add(time, child.InnerText.Trim('\n', ' ', Environment.NewLine[0]).Replace("  ", ""));
                        }
                    }
                }
            }

            foreach (var featureNode in GetChildrenOfChild(node, "Features"))
            {
                IFeature feature = mManager.GetFeature(featureNode, "flythrough step " + (mStep + 1), null);
                if (feature != null)
                {
                    mFeatures.Add(feature);
                    state.AddFeature(feature);
                    feature.Active = false;
                }
            }
        }
コード例 #28
0
        /// <summary>
        /// Start the match
        /// </summary>
        public void Start(vmNewMatch newMatch)
        {
            if (Match == null)
            {
                Match = new TennisMatch();
            }

            //Set the properties of the new match
            Match.Type = newMatch.GetType();
            Match.NumberGamesPerSet = newMatch.GamesPerSet;
            Match.BestOutOf         = newMatch.GetBestOutOf();
            Match.TieBreakFinalSet  = newMatch.TiebreakFinalSet;
            Match.LogLevel          = newMatch.GetLogLevel();
            Match.Location          = newMatch.Location;
            Match.MatchSurface      = newMatch.GetSurface();

            TennisMatchVariant _variant = newMatch.MatchVariants[newMatch.SelectedMatchIndex];

            Match.DeuceSuddenDeath       = _variant.DeuceSuddenDeath;
            Match.FinalSetIsTiebreak     = _variant.FinalSetIsTiebreak;
            Match.FinalSetTieBreakLength = _variant.FinalSetTieBreakLength;
            Match.NumberGamesPerSet      = _variant.NumberGamesPerSet;
            Match.TieBreakAtSameScoreOf  = _variant.TieBreakAtSameScoreOf;
            Match.TieBreakFinalSet       = _variant.TieBreakFinalSet;
            Match.TieBreakLength         = _variant.TieBreakLength;

            StatisticsCollection.SetSource(Match);

            //Add the players
            Tennis_Statistics.Game_Logic.TennisPlayer Player1 = new Game_Logic.TennisPlayer();
            Player1.Name        = newMatch.Player1.Name;
            Player1.ID          = newMatch.Player1.ID;
            Player1.LocalPlayer = newMatch.Player1.LocalPlayer;
            Tennis_Statistics.Game_Logic.TennisPlayer Player2 = new Game_Logic.TennisPlayer();
            Player2.Name        = newMatch.Player2.Name;
            Player2.ID          = newMatch.Player2.ID;
            Player2.LocalPlayer = newMatch.Player2.LocalPlayer;

            Match.Contestant1.Players.Add(Player1);
            Match.Contestant2.Players.Add(Player2);

            //Add partners
            if (Match.Type == TennisMatch.MatchType.Doubles)
            {
                Tennis_Statistics.Game_Logic.TennisPlayer Partner1 = new Game_Logic.TennisPlayer();
                Partner1.Name        = newMatch.Player1Partner.Name;
                Partner1.ID          = newMatch.Player2Partner.ID;
                Partner1.LocalPlayer = newMatch.Player1Partner.LocalPlayer;
                Tennis_Statistics.Game_Logic.TennisPlayer Partner2 = new Game_Logic.TennisPlayer();
                Partner2.Name        = newMatch.Player2Partner.Name;
                Partner2.ID          = newMatch.Player2Partner.ID;
                Partner2.LocalPlayer = newMatch.Player2Partner.LocalPlayer;

                Match.Contestant1.Players.Add(Partner1);
                Match.Contestant2.Players.Add(Partner2);
            }

            CurrentPoint.LogLevel = Match.LogLevel;

            //Start the new set
            Match.StartNewSet();

            NewPoint();
        }
コード例 #29
0
        /// <summary>
        /// Process the action/choice of the user
        /// </summary>
        /// <param name="Method"></param>
        public void ProcessAction(string CommandMethod)
        {
            try
            {
                switch (CommandMethod)
                {
                case "CommandTerminate":

                    Match.Terminate();

                    break;

                case "CommandEnd":

                    Match.End(TennisMatch.MatchStatus.Terminated);

                    break;

                case "CommandResign":

                    Match.End(TennisMatch.MatchStatus.Resigned);

                    break;

                case "CommandUndo":

                    if (CurrentPoint == null || CurrentPoint.Point.Winner == 0 && CurrentPoint.Point.Serve != TennisPoint.PointServe.SecondServe)
                    {
                        //Undo the last played point if the current point is not present, or if it has not been played yet.
                        Match.Undo();
                    }

                    NewPoint();

                    break;

                case "CommandSwitchServer":

                    Match.SwitchServer();

                    NewPoint();

                    break;

                case "CommandExtend":

                    Match.Extend();

                    NewPoint();

                    break;

                default:

                    CurrentPoint.ProcessAction(CommandMethod);

                    if (CurrentPoint.PossibleActions.Count <= 1)
                    {
                        //no choices to make; start a new point
                        Match.Add(CurrentPoint.Point);

                        NewPoint();
                    }
                    break;
                }

                NotifyPropertyChanged("CurrentPoint");
                NotifyPropertyChanged("Duration");
                NotifyPropertyChanged("IsExtendPossible");
                NotifyPropertyChanged("SetScores");
                NotifyPropertyChanged("ScorePlayer1");
                NotifyPropertyChanged("ScorePlayer2");
                NotifyPropertyChanged("Server");
                NotifyPropertyChanged("InProgress");
                NotifyPropertyChanged("Winner");
                NotifyPropertyChanged("Completed");
                NotifyPropertyChanged("Undo");
                NotifyPropertyChanged("Sets");
                NotifyPropertyChanged("Switch");
                NotifyPropertyChanged("MatchType");
                NotifyPropertyChanged("Status");

                CurrentSetScore.Notify();
                TotalSets.Notify();
                StatisticsCollection.Notify();
            }
            catch (Exception e)
            {
                ExtendedEventArgs eaa = new ExtendedEventArgs();
                eaa.Error = "A fatal error occurred. Please try again or stop this match to preserve the statistics.";
                #if DEBUG
                eaa.Error = String.Format("A fatal error occurred. {1}:{0}", e.Message, e.Source);
                #endif
                OnFatalError(eaa);
            }
        }
コード例 #30
0
 public StatisticsCollectionPanel(StatisticsCollection collection, Core core)
     : this()
 {
     Init(collection, core);
 }