public double GetReward(QQuadrant quadrant) { var list = GetPossibleActions(quadrant); double actionReward = list.Max(a => a.Reward); return(quadrant.Reward + (0.5 * actionReward)); }
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); }
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); } }
public IList <QAction> GetPossibleActions(QQuadrant quadrant) => Actions.Where(a => a.Current.Equals(quadrant)).ToList();
public QAction(double reward, QQuadrant current, QQuadrant target) { Reward = reward; Current = current; Target = target; }
public QEntry(int reward, QQuadrant current, QQuadrant target) { Reward = reward; Current = current; Target = target; }