示例#1
0
        public double GetReward(QQuadrant quadrant)
        {
            var    list         = GetPossibleActions(quadrant);
            double actionReward = list.Max(a => a.Reward);

            return(quadrant.Reward + (0.5 * actionReward));
        }
示例#2
0
        private static QQuadrant[,] BuildMapMatrix()
        {
            var aux = new string[5] {
                "A", "B", "C", "D", "E"
            };
            var matrix = new QQuadrant[5, 10];

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    matrix[i, j] = new QQuadrant(-1, aux[i] + j);
                }
            }

            matrix[3, 1].Reward = -100;
            matrix[3, 2].Reward = -100;
            matrix[3, 4].Reward = -100;
            matrix[3, 5].Reward = -100;
            matrix[3, 7].Reward = -100;
            matrix[1, 3].Reward = -100;
            matrix[1, 7].Reward = -100;

            for (int i = 0; i < 9; i++)
            {
                matrix[0, i].Reward = -100;
            }

            matrix[0, 9].Reward = 100;
            return(matrix);
        }
示例#3
0
        public QAction GetNextAction(QQuadrant quadrant, bool includeRandomization = true)
        {
            var possibleActions = GetPossibleActions(quadrant);

            if (new Random().Next(0, 100) > 70 && includeRandomization)
            {
                var randomAction = new Random().Next(0, 100) % possibleActions.Count;
                return(possibleActions[randomAction]);
            }
            else
            {
                var bestAction = possibleActions[0];
                foreach (var action in possibleActions)
                {
                    if (bestAction.Reward < action.Reward)
                    {
                        bestAction = action;
                    }
                }

                return(bestAction);
            }
        }
示例#4
0
 public IList <QAction> GetPossibleActions(QQuadrant quadrant)
 => Actions.Where(a => a.Current.Equals(quadrant)).ToList();
示例#5
0
 public QAction(double reward, QQuadrant current, QQuadrant target)
 {
     Reward  = reward;
     Current = current;
     Target  = target;
 }
示例#6
0
 public QEntry(int reward, QQuadrant current, QQuadrant target)
 {
     Reward  = reward;
     Current = current;
     Target  = target;
 }