コード例 #1
0
 public ActionResult Evolution(PopulationOfHaikus p)
 {
     try
     {
         p.DeserializeXml();
         //interactive evolution of haiku poems will be performed
         if (p.Generation < 7)
         {
             if (ModelState.IsValid)
             {
                 //reevaluate- add human evaluation
                 for (int i = 0; i < p.Population.Count; i++)
                 {
                     var choice = p.Population[i].HumanFitness;
                     p.Population[i].write();
                 }
                 p.Replace();
                 p.SerializeXml();
             }
             return(View(p));
         }
         //interactive evolution of haiku poems will stop in 10th generation and results will be shown to user
         else
         {
             return(RedirectToAction("ThankYou"));
         }
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Error", ex.Message));
     }
 }
コード例 #2
0
 public ActionResult Evolution()
 {
     try
     {
         PopulationOfHaikus p = new PopulationOfHaikus(); //initial population of haiku poems
         p.Replace();
         p.SerializeXml();
         return(View(p));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Error", ex.Message));
     }
 }