/// <summary> /// Randomly generates a task with the given grammar /// </summary> /// <param name="grammarName">The name of the grammar to generate the task</param> /// <param name="tier">The maximum difficulty degree allowed to produce the task</param> /// <returns></returns> public Task GenerateTask(string grammarName, DifficultyDegree tier) { for (int i = 0; i < 3; ++i) { try { string taskPrototype = GetTaskPrototype(grammarName); WildcardReplacer replacer = new WildcardReplacer(this, tier); if (String.IsNullOrEmpty(taskPrototype)) { return(null); } return(replacer.GetTask(taskPrototype)); } catch { continue; } } return(null); }
/// <summary> /// Randomly generates a task with the requested difficulty degree /// </summary> /// <param name="tier">The maximum difficulty degree allowed to produce the task</param> /// <returns></returns> public Task GenerateTask(DifficultyDegree tier) { for (int i = 0; i < 3; ++i) { try { TaskNode root = GetTaskPrototype(tier); string taskPrototype = root.Render(); WildcardReplacer replacer = new WildcardReplacer(this, tier); if (String.IsNullOrEmpty(taskPrototype)) { return(null); } Task t = replacer.GetTask(taskPrototype); t.Tree = root; return(t); } catch { continue; } } return(null); }