We will now implement two classes. The first one stores values in a dictionary for learning purposes and the second one actually holds the Q-learning algorithm. Go through the following steps to create the two classes:
- Create the QValueStore class:
using UnityEngine; using System.Collections.Generic; public class QValueStore : MonoBehaviour { private Dictionary<GameState, Dictionary<GameAction, float>> store; }
- Implement the constructor:
public QValueStore() { store = new Dictionary<GameState, Dictionary<GameAction, float>>(); }
- Define the function for getting the resulting value of taking an action in a game state. Carefully craft this so that an action cannot be taken in that particular state:
public virtual float ...