Esempio n. 1
0
    /// <summary>
    /// θの初期値を取得
    /// </summary>
    /// <returns></returns>
    public MatrixUtil GetInitialThetaMatrix()
    {
        MatrixUtil matrix = MatrixUtil.Arange(fieldSize * fieldSize, actionNum);

        for (int state = 0; state < matrix.shape[0]; state++)
        {
            for (int action = 0; action < matrix.shape[1]; action++)
            {
                int i = state % fieldSize;
                int j = state / fieldSize;
                switch (action)
                {
                case 0:
                    matrix.Set(state, action, activeLines_line[i, j + 1] ? 0 : 1);
                    break;

                case 1:
                    matrix.Set(state, action, activeLines_row[i + 1, j] ? 0 : 1);
                    break;

                case 2:
                    matrix.Set(state, action, activeLines_line[i, j] ? 0 : 1);
                    break;

                case 3:
                    matrix.Set(state, action, activeLines_row[i, j] ? 0 : 1);
                    break;
                }
            }
        }
        return(matrix);
    }
Esempio n. 2
0
 public void Init(MainModel model, int fieldSize, MatrixUtil initialTheta)
 {
     this.model      = model;
     this.fieldSize  = fieldSize;
     this.eta        = this.model.eta;
     this.gamma      = this.model.gamma;
     this.epsilon    = this.model.epsilon;
     this.shrinkRate = this.model.shrinkRate;
     this.episodeMax = this.model.episodeMax;
     this.limit      = this.model.limit;
     this.stateNum   = initialTheta.shape[0];
     this.actionNum  = initialTheta.shape[1];
     r = new System.Random();
     Q = MatrixUtil.Arange(stateNum, actionNum);
     MatrixUtil.UniFuncArangeAll(Q, () => (float)(r.NextDouble()));
     Q = Q.Multiply(initialTheta);
 }