public static void PrintPair(BloodLineMember a, BloodLineMember b) { if (a == null || b == null) { Console.WriteLine("NullPops given for printing"); return; } var relation = BloodLineManager.DeterminRelation(a, b); if (relation == null) { Console.WriteLine("Null relation"); return; } Console.WriteLine("---------------------------------------"); Console.WriteLine(string.Format("Subject: {0}, Target: {1}", a.PopInstance.Label, b.PopInstance.Label)); Console.WriteLine(string.Format("RelationChain: {0}", string.Join(" => ", relation.RelationTypeChain.Select(x => x.ToString())))); Console.WriteLine(string.Format("Term: {0}", relation.GetTerm())); if (relation.RelationDef != null) { Console.WriteLine(string.Format("TermChain: {0}", string.Join(" => ", relation.RelationDef.RelationTypeChain.Select(x => x.ToString())))); } Console.WriteLine("---------------------------------------"); }
public static void MatingTest() { Population = new List <BloodLineMember>(); var done = false; while (!done) { var tokens = Console.ReadLine().ToLower().Split(' '); switch (tokens[0]) { case "quit": done = true; break; case "select": if (tokens[1].ToLower().Equals("random")) { PrintPop(Population.OrderBy(x => Guid.NewGuid()).First()); } else { var pop = Population.Where(x => x.PopInstance.Label.ToLower() == tokens[1]).FirstOrDefault(); PrintPop(pop); } break; case "mate": var a = memberFromName(tokens[1]); var b = memberFromName(tokens[2]); if (a == null || b == null) { Console.WriteLine("one or more members count not be found"); break; } var newKid = new VillagerPop("NAME", new List <string> { "tag" }); Console.WriteLine("----------------------------------------------------"); Console.WriteLine(string.Format("{0} and {1} gave birth to {2}", a.Name, b.Name, newKid.Name)); Console.WriteLine("----------------------------------------------------"); break; case "chain": var pop1 = Population.Where(x => x.PopInstance.Label.ToLower() == tokens[1]).FirstOrDefault(); var pop2 = Population.Where(x => x.PopInstance.Label.ToLower() == tokens[2]).FirstOrDefault(); if (pop1 == null || pop2 == null) { Console.WriteLine("One or both pops are null"); } else { var relation = BloodLineManager.DeterminRelation(pop1, pop2); Console.WriteLine(string.Format("Chain from {0} to {1}", pop1.PopInstance.Label, pop2.PopInstance.Label)); foreach (var rel in relation.RelationTypeChain) { Console.Write(rel.ToString() + " -> "); } Console.WriteLine(); } break; case "pair": var popa = Population.Where(x => x.PopInstance.Label.ToLower() == tokens[1]).FirstOrDefault(); var popb = Population.Where(x => x.PopInstance.Label.ToLower() == tokens[2]).FirstOrDefault(); if (popa == null || popb == null) { Console.WriteLine("One or both pops are null"); } else { PrintPair(popa, popb); } break; case "add": AddNewPopulation(1); break; case "list": if (tokens.Length > 0 && tokens[1] == "all") { foreach (var pop in Population) { Console.Write(pop.Name + ", "); } } break; default: Console.WriteLine("Token not recongnized"); break; } } }