示例#1
0
        public static TyStateWeights GetDefault()
        {
            TyStateWeights p = new TyStateWeights(1.0f);

            p.SetWeight(WeightType.HealthFactor, 8.7f);
            return(p);
        }
示例#2
0
 public TyStateWeights(TyStateWeights other)
     : this()
 {
     for (int i = 0; i < _weights.Length; i++)
     {
         _weights[i] = other._weights[i];
     }
 }
示例#3
0
        public static TyStateWeights operator -(TyStateWeights lhs, TyStateWeights rhs)
        {
            TyStateWeights p = new TyStateWeights();

            for (int i = 0; i < p._weights.Length; i++)
            {
                p._weights[i] = lhs._weights[i] - rhs._weights[i];
            }

            return(p);
        }
示例#4
0
        public static TyStateWeights operator /(TyStateWeights lhs, float rhs)
        {
            TyStateWeights p = new TyStateWeights();

            for (int i = 0; i < p._weights.Length; i++)
            {
                p._weights[i] = lhs._weights[i] / rhs;
            }

            return(p);
        }
示例#5
0
        public static TyStateWeights UniformLerp(TyStateWeights lhs, TyStateWeights rhs, float t)
        {
            TyStateWeights p = new TyStateWeights();

            for (int i = 0; i < p._weights.Length; i++)
            {
                p._weights[i] = TyUtility.Lerp(lhs._weights[i], rhs._weights[i], t);
            }

            return(p);
        }
示例#6
0
        private TycheAgent(TyStateWeights weights, bool heroBasedWeights, int episodeMultiplier, bool adjustEpisodeMultiplier)
        {
            _defaultEpisodeMultiplier = episodeMultiplier;
            _curEpisodeMultiplier     = episodeMultiplier;
            _heroBasedWeights         = heroBasedWeights;

            _analyzer = new TyStateAnalyzer(weights);
            _simTree  = new TySimTree();
            _random   = new Random();

            AdjustEpisodeMultiplier = adjustEpisodeMultiplier;
        }
示例#7
0
        /// <summary> Called the first round (might be second round game wise) this agents is able to see the game and his opponent. </summary>
        private void CustomInit(POGame.POGame initialState)
        {
            _hasInitialized = true;

            _playerId             = initialState.CurrentPlayer.PlayerId;
            _analyzer.OwnPlayerId = _playerId;

            if (_heroBasedWeights)
            {
                _analyzer.Weights = TyStateWeights.GetHeroBased(initialState.CurrentPlayer.HeroClass, initialState.CurrentOpponent.HeroClass);
            }
        }
示例#8
0
        public static TyStateWeights UniformRandLerp(TyStateWeights lhs, TyStateWeights rhs, System.Random random, float tMin, float tMax)
        {
            TyStateWeights p = new TyStateWeights();

            for (int i = 0; i < p._weights.Length; i++)
            {
                float t = random.RandFloat(tMin, tMax);
                p._weights[i] = TyUtility.Lerp(lhs._weights[i], rhs._weights[i], t);
            }

            return(p);
        }
示例#9
0
        public static TyStateWeights NonUniformLerp(TyStateWeights lhs, TyStateWeights rhs, float[] tValues)
        {
            System.Diagnostics.Debug.Assert(tValues.Length >= (int)WeightType.Count);

            TyStateWeights p = new TyStateWeights();

            for (int i = 0; i < p._weights.Length; i++)
            {
                p._weights[i] = TyUtility.Lerp(lhs._weights[i], rhs._weights[i], tValues[i]);
            }

            return(p);
        }
示例#10
0
        public static TycheAgent GetTrainingAgent(float biasFactor = -1.0f, bool useSecrets = false)
        {
            const bool ADJUST_EPISODES    = false;
            const bool HERO_BASED_WEIGHTS = false;

            var weights = TyStateWeights.GetDefault();

            if (biasFactor >= 0.0f)
            {
                weights.SetWeight(TyStateWeights.WeightType.BiasFactor, biasFactor);
            }

            var agent = new TycheAgent(weights, HERO_BASED_WEIGHTS, 0, ADJUST_EPISODES);

            agent.UsedAlgorithm = Algorithm.Greedy;
            agent._analyzer.EstimateSecretsAndSpells = useSecrets;

            return(agent);
        }
示例#11
0
 public TycheAgent()
     : this(TyStateWeights.GetDefault(), true, DEFAULT_NUM_EPISODES_MULTIPLIER, true)
 {
 }
示例#12
0
 public static TycheAgent GetSearchTreeAgent(int episodeMultiplier)
 {
     return(new TycheAgent(TyStateWeights.GetDefault(), true, episodeMultiplier, true));
 }
示例#13
0
 public static TycheAgent GetLearningAgent(TyStateWeights weights)
 {
     return(new TycheAgent(weights, false, LEARNING_NUM_EPISODES_MULTIPLIER, false));
 }
 public TyStateAnalyzer(TyStateWeights weights)
 {
     Weights = weights;
 }