public void SubmitRatings() { RatingSystem.SubmitRatings(); // IMPORTANT: Use the new List<bool> isStarred to determine which LSystem's have been selected by the player // the index in isStarred corresponds to the index in lSystems //Debug.Log("creating wrapper list..."); List <LSystemWrapper> wrappers = new List <LSystemWrapper>(); for (int i = 0; i < RatingSystem.lSystems.Count; i++) { //Debug.Log("in loop i=" + i); LSystem lSystem = RatingSystem.lSystems[i]; //Debug.Log("got lSystem"); LSystemWrapper wrapper = new LSystemWrapper(); string[] axiomAndRules = LSystem.Encode(lSystem).Split('~'); //Debug.Log("created axiomAndRules"); wrapper.Axiom = axiomAndRules[0]; //Debug.Log("set Axiom"); wrapper.Rules = axiomAndRules[1]; // Debug.Log("set Rules"); wrapper.IsStarred = RatingSystem.isStarred[i]; //Debug.Log("set isStarred"); wrapper.PopulationId = SqlConnection.PopulationId.Value; // Debug.Log("set PopulationId"); wrappers.Add(wrapper); } //Debug.Log("finished creating wrapper list"); Debug.Log("started coroutine"); SqlManager.SqlManagerInstance.StartCoroutine(SqlConnection.PostRating(wrappers.ToArray(), () => { // keep some levels (starred ones?) for (int i = 0; i < RatingSystem.MAX_LSYSTEMS; ++i) { // add starred level to kept list if (RatingSystem.isStarred[i]) { RatingSystem.keptForEvolution.Add(new RatingSystem.LSystemEvolution(RatingSystem.lSystems[i])); } } // TODO: MUST HAVE A BACKUP PLAN IF PLAYER DOES NOT STAR ENOUGH LEVELS int numLSystemsNeeded = RatingSystem.MAX_LSYSTEMS - RatingSystem.keptForEvolution.Count; SqlManager.SqlManagerInstance.StartCoroutine(SqlConnection.GetPopulation((int)(numLSystemsNeeded * 0.8f), GetPopulationCallBack)); })); }
static void Main(string[] args) { //File path for level xml string path = "../../levels/level-04.xml"; Dictionary <string, string> materialKey = new Dictionary <string, string> { { "W", "wood" }, { "S", "stone" }, { "I", "ice" }, { "A", "air" } }; Dictionary <string, Tuple <List <string>, List <double> > > rules1 = new Dictionary <string, Tuple <List <string>, List <double> > > { { "1", new Tuple <List <string>, List <double> >(new List <string> { "1", "212" }, new List <double> { 0.80, 0.20 }) }, { "4", new Tuple <List <string>, List <double> >(new List <string> { "4", "141" }, new List <double> { 0.60, 0.40 }) }, { "2", new Tuple <List <string>, List <double> >(new List <string> { "2", "26262" }, new List <double> { 0.20, 0.80 }) } }; Dictionary <string, Tuple <List <string>, List <double> > > rules2 = new Dictionary <string, Tuple <List <string>, List <double> > > { { "2", new Tuple <List <string>, List <double> >(new List <string> { "2", "234" }, new List <double> { 0.80, 0.20 }) }, { "4", new Tuple <List <string>, List <double> >(new List <string> { "654", "34652" }, new List <double> { 0.60, 0.40 }) }, { "6", new Tuple <List <string>, List <double> >(new List <string> { "6", "64574" }, new List <double> { 0.20, 0.80 }) } }; //LSystem r1 = new LSystem(rules1, 3, 5); LSystem r1 = new LSystem(6, 10); //LSystem r2 = new LSystem(rules2, 3, 5); LSystem r2 = new LSystem(6, 10); LSystem r3 = LSystem.Crossover(r1, r2); //Iterate through L-system r3.Iterate(3); //Start writing in level file StartFile(path); WriteBlocksToFile(r3, path); EndFile(path); foreach (string axiom in r3.iterations) { Console.WriteLine(axiom); } Console.WriteLine(LSystem.Encode(r3)); Console.ReadKey(); }