Exemplo n.º 1
0
 public void Load(BinaryReader b)
 {
     prevState = new T();
     prevState.Load(b);
     nextState = new T();
     //nextState.Load(b);
     action = b.ReadInt32();
     reward = b.ReadDouble();
 }
Exemplo n.º 2
0
 public override int GetBestActionIndex(QState state)
 {
     //Make sure we have action for this state, if not, create new with random value
     if (!qData.ContainsKey(state))
     {
         //create random state
         double[] d = new double[Actions.Length];
         d.RandomFill();
         qData[state] = d;
     }
     // found return best reqard index
     double[] aData = qData[state];
     return(Array.IndexOf(aData, aData.Max()));
 }
Exemplo n.º 3
0
        public virtual int GetActionIndex(QState state)
        {
            int ret = 0;

            data.prevState = state;
            double r = rand.NextDouble();

            if (r < option.epsilon)
            {
                ret = RandomActionIndex();
            }
            else
            {
                // find max action for this state
                ret = GetBestActionIndex(state);
            }
            data.action = ret;
            return(ret);
        }
Exemplo n.º 4
0
 public virtual int GetBestActionIndex(QState state)
 {
     throw new NotImplementedException("GetBestActionIndex");
 }
Exemplo n.º 5
0
 public virtual int GetBestAction(QState state)
 {
     return(GetActionFromIndex(GetActionIndex(state)));
 }