/// <summary> /// Ejecuta un encuentro entre dos individuos. /// </summary> public void Encuentro(EstructuraIndividuo I, EstructuraIndividuo J) { EstructuraIndividuo[] Ind = new EstructuraIndividuo[2]; Historial H = new Historial(); if (r.Next(2) == 0) { Ind [0] = I; Ind [1] = J; } else { Ind [0] = J; Ind [1] = I; } H.Ind [0] = Ind [0].Indiv; H.Ind [1] = Ind [1].Indiv; if (Ind [0].Siguiendo || Ind [1].Siguiendo) { Console.Write(""); } // Ejecutar las rondas while (H.Actual < IteracionesPorEncuentro) { // H.Actual++; int a; int b; a = Ind [0].Indiv.Ejecutar(H); b = Ind [1].Indiv.Ejecutar(H.Invertir()); // Los jugadores escogen a y b respectivamente. //Agrega en el historial las últimas desiciones. H.AgregaTurno(a, b); // Modificar la puntuación Ind [0].Punt += Torneo.Puntuación(a, b) / IteracionesPorEncuentro; Ind [1].Punt += Torneo.Puntuación(b, a) / IteracionesPorEncuentro; } if (Ind [0].Siguiendo || Ind [1].Siguiendo) { Console.WriteLine(string.Format("{0}:{1}\n{2}:{3}", Ind [0].Indiv, H.ObtenerPuntuación(0), Ind [1].Indiv, H.ObtenerPuntuación(1))); if (Console.ReadLine() != "") { // Mostrar el historial for (int i = 0; i < 2; i++) { for (int j = 0; j < H.Count; j++) { Console.Write(H [i, j]); } Console.WriteLine(" - " + H.Ind [i]); } } } }
public float ObtenerPuntuación(int i) { if (i < 0 || i > 1) { throw new IndexOutOfRangeException(); } float ret = 0; for (int j = 0; j < Actual; j++) { ret += Torneo.Puntuación(this [i, j], this [1 - i, j]); } return(ret); }