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

            //give reward/punishment if spells cost less/more than usual:
            float diff = (float)spell.Card.Cost - (float)spell.Cost;

            playerState.BiasValue += diff * 1.25f;

            string key = spell.Card.Name;

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

            else if (TyConst.LOG_UNKNOWN_SECRETS)
            {
                TyDebug.LogInfo("Unknown spell: " + task.FullPrint());
            }
        }
Пример #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");
            }
        }