/// <summary> /// Must enumerate every possible action to take from every possible state, where 1 action is a set of commands given to units. FOR NOW IT ONLY COMMANDS ONE UNIT!!!! /// </summary> /// <param name="c"></param> void InitializePolicy() { Commander c = commandersToControl[0]; Debug.Log("Creating policy..."); float initialQValue = 0.8f; policy = new List <Tuple <CommandListAbstract, float> > [stateSpace.states.Count]; //for (int s = 0; s < stateSpace.Length; s++) for (int s = 0; s < stateSpace.states.Count; s++) { List <Tuple <CommandListAbstract, float> > commandLists = new List <Tuple <CommandListAbstract, float> >(); // available options for each plane List <Maneuver>[] availableManeuvers = new List <Maneuver> [c.unitsOwned.Count]; // enumerate possible maneuvers for each plane controlled for (int unitIdx = 0; unitIdx < c.unitsOwned.Count; unitIdx++) { var aircraft = stateSpace.GetAircraftAtState(s); var potentialManeuvers = gameController.GetAvailableManeuvers(aircraft); availableManeuvers[unitIdx] = potentialManeuvers; } // get all possible combinations of maneuvers for ONE plane for (int unitIdx = 0; unitIdx < c.unitsOwned.Count; unitIdx++) { if (c.unitsOwned.Count > 1) { Debug.LogError("Whoops, did not implement Policy creation for commanding multiple units yet..."); } var maneuvers = availableManeuvers[unitIdx]; for (int maneuverIdx = 0; maneuverIdx < maneuvers.Count; maneuverIdx++) { CommandListAbstract action = new CommandListAbstract(); action.Add(unitIdx, maneuvers[maneuverIdx].id); commandLists.Add(new Tuple <CommandListAbstract, float>(action, initialQValue)); } } policy[s] = commandLists; //Debug.Log("Policy creation progress: " + s + "/" + stateSpace.states.Count); } Debug.Log("Policy creation finished!"); }