int[,] transitions; // transition[#s][#i] = #s public void Init(TeamRobot robot) { // Initialize the starting states Scan scan = new Scan(); scan.Init(ref robot); Offensive off = new Offensive(); off.Init(ref robot); Defensive def = new Defensive(); def.Init(ref robot); current = scan; // Initialize the event queue for handling events events = new Queue <Event>(); // Initialize and store the references to the states states = new List <State>(); states.Add(current); states.Add(off); states.Add(def); // Make transition table transitions = new int[states.Count, states.Count]; transitions[0, 0] = 0; // Scan + !enemyFound == Scan transitions[0, 1] = 1; // Scan + highEnergy == Offensive transitions[0, 2] = 2; // Scan + !highEnergy == Defensive transitions[1, 0] = 0; // Offensive + !enemyFound == Scan transitions[1, 1] = 1; // Offensive + highEnergy == Offensive transitions[1, 2] = 2; // Offensive + !highEnergy == Defensive transitions[2, 0] = 0; // Defensive + !enemyFound == Scan transitions[2, 1] = 1; // Defensive + highEnergy == Offensive transitions[2, 2] = 2; // Defensive + !highEnergy == Defensive }