Exemplo n.º 1
0
 /// <summary>
 /// Creates a new <see cref="PercentageOfLastReceivedMoveDamageCalculator"/> instance.
 /// </summary>
 /// <param name="percentage">The percentage of damage to deal.</param>
 /// <param name="actionHistory">The action history.</param>
 public PercentageOfLastReceivedMoveDamageCalculator(
     int percentage,
     IActionHistory actionHistory)
 {
     _percentage    = percentage;
     _actionHistory = actionHistory;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Sets the built damage action to target the user of the move
 /// containing the action that last affected the user.
 /// </summary>
 /// <param name="builder">The damage action builder.</param>
 /// <param name="actionHistory">The action history.</param>
 public static DamageActionBuilder Retaliates(
     this DamageActionBuilder builder,
     IActionHistory actionHistory)
 {
     return(builder.WithActionTargetCalculator(new RetaliationActionTargetCalculator(actionHistory))
            .WithTag(DamageTags.Retaliation));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Sets the built damage action to use percentage-of-last-received-move damage.
 /// </summary>
 /// <param name="builder">The damage action builder.</param>
 /// <param name="percentage">The percentage of damage to deal.</param>
 /// <param name="actionHistory">The action history.</param>
 public static DamageActionBuilder PercentageOfLastReceivedMoveDamage(
     this DamageActionBuilder builder,
     int percentage,
     IActionHistory actionHistory)
 {
     return(builder.WithDamageCalculator(new PercentageOfLastReceivedMoveDamageCalculator(percentage, actionHistory)));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Sets the built damage action to use percentage-of-last-received-move damage.
 /// </summary>
 /// <param name="builder">The damage action builder.</param>
 /// <param name="startingBasePower">The starting base power.</param>
 /// <param name="linearFactor">The linear factor.</param>
 /// <param name="random">The random number generator.</param>
 /// <param name="actionHistory">The action history.</param>
 public static DamageActionBuilder BasePowerIncreasesLinearlyWithUses(
     this DamageActionBuilder builder,
     int startingBasePower,
     int linearFactor,
     IRandom random,
     IActionHistory actionHistory)
 {
     return(builder.WithDamageCalculator(new BasePowerIncreasesLinearlyWithUsesDamageCalculator(startingBasePower, linearFactor, random, actionHistory)));
 }
Exemplo n.º 5
0
 public ActionManager(String[] labels, MyModuleParams setup)
 {
     this.m_setup = setup;
     Actions      = new List <MyMotivatedAction>();
     for (int i = 0; i < labels.Length; i++)
     {
         Actions.Add(new MyMotivatedAction(labels[i], 0, setup));
     }
     this.AcitonHistory = new MyActionHistory(this, setup);
     this.AcitonHistory.AddAllCurrentActions();
 }
Exemplo n.º 6
0
 public ActionManager(int noPrimitiveActions, MyModuleParams setup)
 {
     this.m_setup = setup;
     Actions      = new List <MyMotivatedAction>();
     for (int i = 0; i < noPrimitiveActions; i++)
     {
         Actions.Add(new MyMotivatedAction("" + i, 0, setup));
     }
     this.AcitonHistory = new MyActionHistory(this, setup);
     this.AcitonHistory.AddAllCurrentActions();
 }
 /// <summary>
 /// Creates a new <see cref="TurnBasedBattle"/> instance.
 /// </summary>
 /// <param name="moveProcessor">The move processor.</param>
 /// <param name="actionHistory">The action history.</param>
 /// <param name="gameOutput">The game output.</param>
 /// <param name="characters">The characters in the battle.</param>
 public TurnBasedBattle(
     MoveProcessor moveProcessor,
     IActionHistory actionHistory,
     IGameOutput gameOutput,
     IEnumerable <Character> characters)
 {
     _moveProcessor = moveProcessor;
     _actionHistory = actionHistory;
     _gameOutput    = gameOutput;
     _characters    = characters;
 }
 /// <summary>
 /// Creates a new <see cref="BasePowerIncreasesLinearlyWithUsesDamageCalculator"/> instance.
 /// </summary>
 /// <param name="startingBasePower">The starting amount of damage to deal.</param>
 /// <param name="linearFactor">The linear factor.</param>
 /// <param name="random">The random number generator.</param>
 /// <param name="actionHistory">The action history.</param>
 public BasePowerIncreasesLinearlyWithUsesDamageCalculator(
     int startingBasePower,
     int linearFactor,
     IRandom random,
     IActionHistory actionHistory)
 {
     _startingBasePower = startingBasePower;
     _linearFactor      = linearFactor;
     _random            = random ?? throw new ArgumentNullException(nameof(random));
     _actionHistory     = actionHistory ?? throw new ArgumentNullException(nameof(actionHistory));
 }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            IActionHistory v3 = ActionHistory_V3.Instance;

            v3.AddAction("hello 1");
            v3.Save();

            foreach (var item in v3.RetriveAllActions())
            {
                Console.WriteLine(item);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a new <see cref="DecreasesLinearlyWithUsesSuccessCalculator"/> instance.
 /// </summary>
 /// <param name="baseSuccessRate">The starting chance of success.</param>
 /// <param name="linearFactor">The linear factor.</param>
 /// <param name="minimumSuccessRate">The minimum success rate</param>
 /// <param name="random">The random number generator.</param>
 /// <param name="failureResult">The failure result.</param>
 /// <param name="actionHistory">The action history.</param>
 public DecreasesLinearlyWithUsesSuccessCalculator(
     int baseSuccessRate,
     int linearFactor,
     int minimumSuccessRate,
     Character user,
     IRandom random,
     MoveUseResult failureResult,
     IActionHistory actionHistory)
 {
     _baseSuccessRate    = baseSuccessRate;
     _linearFactor       = linearFactor;
     _minimumSuccessRate = minimumSuccessRate;
     _user          = user;
     _random        = random ?? throw new ArgumentNullException(nameof(random));
     _failureResult = failureResult;
     _actionHistory = actionHistory ?? throw new ArgumentNullException(nameof(actionHistory));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Sets the built move's success rate to decrease linearly each
 /// time it is used.
 /// </summary>
 /// <param name="builder">The move builder.</param>
 /// <param name="baseSuccess">The base success rate.</param>
 /// <param name="linearFactor">The linear factor.</param>
 /// <param name="minimumSuccessRate">The minimum success rate.</param>
 /// <param name="random">The random number generator.</param>
 /// <param name="failureResult">The result to return in the case of failure.</param>
 /// <param name="actionHistory">The action history.</param>
 public static MoveBuilder SuccessDecreasesLinearlyWithUses(
     this MoveBuilder builder,
     int baseSuccess,
     int linearFactor,
     int minimumSuccessRate,
     Character user,
     IRandom random,
     MoveUseResult failureResult,
     IActionHistory actionHistory)
 {
     return(builder.WithSuccessCalculatorFactory(
                () => new DecreasesLinearlyWithUsesSuccessCalculator(
                    baseSuccess,
                    linearFactor,
                    minimumSuccessRate,
                    user,
                    random,
                    failureResult,
                    actionHistory
                    )
                ));
 }
        protected override int[] ChooseActions()
        {
            IActionHistory ah = m_rds.ActionManager.AcitonHistory;

            Dictionary <int, float> importances = new Dictionary <int, float>();
            int   action;
            float w;

            for (int i = 0; i < m_learningParams.ActionLength; i++)
            {
                action = ah.GetActionExecutedBefore(i);
                if (action != -1)
                {
                    w = 1.0f - ((float)i / (float)m_learningParams.ActionLength);

                    if (importances.ContainsKey(action))
                    {
                        importances[action] += w;
                    }
                    else
                    {
                        importances.Add(action, w);
                    }
                }
            }

            List <int> chosen = new List <int>();

            foreach (var item in importances)
            {
                if (item.Value >= m_learningParams.ActionSubspacingThreshold)
                {
                    chosen.Add(item.Key);
                }
            }
            return(chosen.ToArray());
        }
 /// <summary>
 /// Creates a new <see cref="RetaliationActionTargetCalculator"/> instance.
 /// </summary>
 /// <param name="actionHistory">The action history.</param>
 public RetaliationActionTargetCalculator(IActionHistory actionHistory)
 {
     _actionHistory = actionHistory;
 }
Exemplo n.º 14
0
        } // History

        #endregion

        #region Constructor

        static ActionManager()
        {
            History = new SimpleHistory();
        } // ActionManager