Пример #1
0
        public static void CalculateValues(TyState playerState, TyState opponentState, Controller player, Controller opponent)
        {
            if (_secretDictionary == null)
            {
                Init();
            }

            for (int i = 0; i < player.SecretZone.Count; i++)
            {
                Spell  secret = player.SecretZone[i];
                string key    = secret.Card.Name;

                if (_secretDictionary.ContainsKey(key))
                {
                    Action <TyState, TyState, Controller, Controller, Spell> action = _secretDictionary[key];
                    action(playerState, opponentState, player, opponent, secret);
                }

                else
                {
                    if (TyConst.LOG_UNKNOWN_SECRETS)
                    {
                        TyDebug.LogWarning("Unknown secret: " + secret.Card.FullPrint());
                    }

                    playerState.BiasValue += secret.Card.Cost * SECRET_VALUE_FACTOR;
                }
            }
        }
Пример #2
0
        private void OnMyTurnEnd()
        {
            _isTurnBegin = true;

            double timeNeeded = TyUtility.GetSecondsSinceStart() - _turnTimeStart;

            if (AdjustEpisodeMultiplier && UsedAlgorithm == Algorithm.SearchTree)
            {
                const double MAX_DIFF = 4.0;
                double       diff     = Math.Min(TyConst.DECREASE_SIMULATION_TIME - timeNeeded, MAX_DIFF);
                double       factor   = 0.05;

                //reduce more if above the time limit:
                if (diff <= 0.0f)
                {
                    factor = 0.2;
                }

                //simulate at max this value * _defaultEpisodeMultiplier:
                const int MAX_EPISODE_MULTIPLIER = 4;
                _curEpisodeMultiplier = Math.Clamp(_curEpisodeMultiplier + (int)(factor * diff * _defaultEpisodeMultiplier),
                                                   _defaultEpisodeMultiplier,
                                                   _defaultEpisodeMultiplier * MAX_EPISODE_MULTIPLIER);
            }

            if (PrintTurnTime)
            {
                TyDebug.LogInfo("Turn took " + timeNeeded.ToString("0.000") + "s");
            }

            if (timeNeeded >= TyConst.MAX_TURN_TIME)
            {
                TyDebug.LogWarning("Turn took " + timeNeeded.ToString("0.000") + "s");
            }
        }
Пример #3
0
        /// <summary> False if there is not enough time left to do simulations. </summary>
        private bool IsAllowedToSimulate(double startTime, int curEpisode, int maxEpisode, int options)
        {
            double time = TyUtility.GetSecondsSinceStart() - startTime;

            if (time >= TyConst.MAX_SIMULATION_TIME)
            {
                TyDebug.LogWarning("Stopped simulations after " + time.ToString("0.000") + "s and " + curEpisode + " of " + maxEpisode + " episodes. Having " + options + " options.");
                return(false);
            }

            return(true);
        }
Пример #4
0
        private static void RemoveMinion(Minion minion, TyState ownerState, TyState opponentState, PlayerTask task)
        {
            //remove the minion value from the overall minion values and remove it from the board
            ownerState.MinionValues -= TyMinionUtil.ComputeMinionValue(minion);
            ownerState.NumMinionsOnBoard--;

            if (minion.HasDeathrattle)
            {
                if (!CorrectForSummonAndEquip(minion.Card, ownerState, opponentState) && TyConst.LOG_UNKNOWN_CORRECTIONS)
                {
                    TyDebug.LogError("Unknown deathrattle from " + minion.Card.FullPrint());
                    TyDebug.LogWarning("After task " + task.FullPrint());
                }
            }
        }