Beispiel #1
0
        /// <summary>
        /// Fully initialises this schedule's team statistics for the given team based on the given round. Note that
        /// the player counts per round should be updated separately.
        /// </summary>
        /// <param name="teamIndex"></param>
        /// <param name="roundIndex"></param>
        private void UpdateTeamStats(int teamIndex, int roundIndex)
        {
            ScheduleTeamStatistics teamStats = _teamStats[teamIndex];
            RoundPlanning          round     = this.Rounds[roundIndex];

            // Update team statistics for each event and match in which the given team participates
            foreach (Event e in round.Events)
            {
                // Determine the opponent's team ID
                bool givenTeamIsTeamOne = e.TeamOneId == teamIndex;
                bool givenTeamIsTeamTwo = e.TeamTwoId == teamIndex;
                int  opponentId         = givenTeamIsTeamOne ? e.TeamTwoId : e.TeamOneId;
                // Continue if the given team is not involved in this event.
                if (!givenTeamIsTeamOne && !givenTeamIsTeamTwo)
                {
                    continue;
                }

                // The team is involved in the event, so update all relevant statistics
                teamStats.UpdateAfterEventAddition(opponentId, roundIndex);
                foreach (SportsMatch match in e.Matches)
                {
                    teamStats.UpdateAfterSportsMatchAddition(match, roundIndex);
                }
            }
        }
Beispiel #2
0
        public BallStarsSchedule Clone()
        {
            // Construct deep copies of the required array objects
            var roundsClone = new RoundPlanning[Rounds.Length];

            for (int i = 0; i < Rounds.Length; i++)
            {
                roundsClone[i] = Rounds[i].Clone();
            }

            var teamStatsClone = new ScheduleTeamStatistics[_teamStats.Length];

            for (int i = 0; i < _teamStats.Length; i++)
            {
                teamStatsClone[i] = _teamStats[i].Clone();
            }

            return(new BallStarsSchedule(roundsClone, _amountOfTeams, _avgPlayersPerTeam, teamStatsClone));
        }
Beispiel #3
0
        /// <summary>
        /// Constructs an empty BallStarsSchedule with an initialised, but undefined array of a given number of rounds.
        /// </summary>
        /// <param name="amountOfRounds"></param>
        /// <param name="amountOfTeams"></param>
        /// <param name="avgPlayersPerTeam"></param>
        public BallStarsSchedule(int amountOfRounds, int amountOfTeams, int avgPlayersPerTeam)
        {
            this.Rounds = new RoundPlanning[amountOfRounds];

            _amountOfTeams     = amountOfTeams;
            _avgPlayersPerTeam = avgPlayersPerTeam;

            _teamStats = new ScheduleTeamStatistics[amountOfTeams];
            for (int i = 0; i < amountOfTeams; i++)
            {
                _teamStats[i] = new ScheduleTeamStatistics(amountOfTeams, amountOfRounds);
            }

            _mutationMethodProbabilities = new Dictionary <Action, double>()
            {
                { SwapSportsMatches, 0.85 },
                // { SwapEvents, 0.7 },
                { RemoveSportsMatch, 0.9 },
                { IncrementRandomSportsMatchPlayerAmount, 0.7 },
                { DecrementRandomSportsMatchPlayerAmount, 0.7 },
                // { ReplaceEventTeam, 0.5 },
            };
        }