Example #1
0
    /// <summary>
    /// Constructor for XML
    /// </summary>
    /// <param name="stateExtractor"></param>
    /// <param name="mower"></param>
    /// <param name="paramSet"></param>

    public QLearner(StateExtractor stateExtractor, Mower mower, ParamSet paramSet)
        : this(stateExtractor,
               mower,
               paramSet.FloatParam(ParamSet.ParamGroupQLearner, ParamSet.ParamGreediness),
               paramSet.FloatParam(ParamSet.ParamGroupQLearner, ParamSet.ParamDiscountValue),
               paramSet.FloatParam(ParamSet.ParamGroupQLearner, ParamSet.ParamLearnRate),
               paramSet.FloatParam(ParamSet.ParamGroupQLearner, ParamSet.ParamInitialQValue),
               paramSet.StringParam(ParamSet.ParamGroupQLearner, ParamSet.ParamQTableDeserialiaztionFile),
               paramSet.StringParam(ParamSet.ParamGroupQLearner, ParamSet.ParamQTableSerialiaztionFile),
               paramSet.BoolParam(ParamSet.ParamGroupMower, ParamSet.ParamEligTraces),
               paramSet.FloatParam(ParamSet.ParamGroupMower, ParamSet.ParamGamma),
               paramSet.StringParam(ParamSet.ParamGroupMower, ParamSet.ParamEligibilityTableDeserialiaztionFile),
               paramSet.StringParam(ParamSet.ParamGroupMower, ParamSet.ParamEligibilityTableSerialiaztionFile),
               paramSet.BoolParam(ParamSet.ParamGroupMower, ParamSet.ParamModelPlanning),
               paramSet.BoolParam(ParamSet.ParamGroupMower, ParamSet.ParamModelPlanningRefined),
               paramSet.StringParam(ParamSet.ParamGroupMower, ParamSet.ParamModelTableDeserialiaztionFile),
               paramSet.StringParam(ParamSet.ParamGroupMower, ParamSet.ParamModelTableSerialiaztionFile),
               paramSet.IntParam(ParamSet.ParamGroupMower, ParamSet.ParamN),
               paramSet.BoolParam(ParamSet.ParamGroupSetupManager, ParamSet.ParamShow)
               )
    {
    }
Example #2
0
    /// <summary>
    /// Initializes a new instance of the <see cref="Mower"/> class.
    /// </summary>
    /// <param name="x">The x coordinate of the start position.</param>
    /// <param name="y">The y coordinate of the start position.</param>
    /// <param name="garden">The <see cref="T:Garden"/> this mower operates in.</param>
    /// <param name="paramSet">The <see cref="T:ParamSet"/> of the project which contains the neccessary parameters for the mower.</param>
    public Mower(uint x, uint y, Garden garden, ParamSet paramSet)
        : base(x, y)
    {
        this.Garden            = garden;
        this.PossibleMovements = MovementAction.VonNeumannNeighbourhoodMovements();
        this.MowReward         = paramSet.FloatParam(ParamSet.ParamGroupMower, ParamSet.ParamMowReward);
        this.NotMownReward     = paramSet.FloatParam(ParamSet.ParamGroupMower, ParamSet.ParamNotMownReward);
        string learnerParam = paramSet.StringParam(ParamSet.ParamGroupMower,
                                                   ParamSet.ParamLearnerType);

        if (learnerParam.Equals(QLearner.LearnerType))
        {
            this.learner = new QLearner(new StateExtractor(this), this, paramSet);
        }
        else if (learnerParam.Equals(RandomLearner.LearnerType))
        {
            this.learner = new RandomLearner(new StateExtractor(this));
        }
        else
        {
            throw new Exception("Unknown LearnerType detected.");
        }
        EpisodeManager.AddEpisodeChangesReceiver(this);
    }