private IEnumerator CrossOverMin(byte idSmallest, GameData gameData, double min = double.MinValue) { LogsManager.ins.AddLog("Strategia znaleziona: " + gameData.colStrategies[idSmallest].ToString()); GraphicalManager.ins.SelectLine(idSmallest, EColors.Red, true); yield return(LogsManager.Wait()); byte newID = 0; Vector strategyA_start = new Vector(0, gameData.matrix[0, idSmallest]); Vector strategyA_end = new Vector(1, gameData.matrix[1, idSmallest]); if (GraphicalManager.ins.highLine.Points.Length == 0) { GraphicalManager.ins.SetHighLinePoint(new Vector2((float)strategyA_start.Y, (float)strategyA_start.X)); } Vector strategyB_start, strategyB_end; Vector minIntersaction = new Vector(0, double.MaxValue); Vector intersaction; for (byte i = 0; i < gameData.matrix.GetLength(1); i++) { if (strategyA_start.Y > strategyA_end.Y) { break; } strategyB_start = new Vector(0, gameData.matrix[0, i]); strategyB_end = new Vector(1, gameData.matrix[1, i]); if (strategyA_start.Equals(strategyB_start) && strategyA_end.Equals(strategyB_end)) { continue; } bool actual = Vector.Intersect(strategyA_start, strategyA_end, strategyB_start, strategyB_end, out intersaction); if (actual && intersaction.Y < minIntersaction.Y && Math.Round(intersaction.Y, 2) > Math.Round(min, 2)) { minIntersaction = intersaction; newID = i; } } if (minIntersaction.Y < double.MaxValue) { Cross2x2 c = new Cross2x2(idSmallest, newID, minIntersaction); if (point == null || c.point.Y > point.point.Y) { point = c; } GraphicalManager.ins.SetHighLinePoint(new Vector2((float)point.point.Y, (float)point.point.X)); yield return(CrossOverMin(newID, gameData, minIntersaction.Y)); } else { GraphicalManager.ins.SetHighLinePoint(new Vector2((float)strategyA_end.Y, (float)strategyA_end.X)); GraphicalManager.ins.SelectLine(0, EColors.Default, true); } }
private IEnumerator CrossOverMax(byte idLargest, GameData gameData, double max = double.MaxValue) { LogsManager.ins.AddLog("Strategia znaleziona: " + gameData.rowStrategies[idLargest]); GraphicalManager.ins.SelectLine(idLargest, EColors.Red, true); yield return(LogsManager.Wait()); byte newID = 0; Vector strategyA_start = new Vector(gameData.matrix[idLargest, 0], 0); Vector strategyA_end = new Vector(gameData.matrix[idLargest, 1], 1); if (GraphicalManager.ins.highLine.Points.Length == 0) { GraphicalManager.ins.SetHighLinePoint(new Vector2((float)strategyA_start.X, (float)strategyA_start.Y)); } Vector strategyB_start, strategyB_end; Vector maxIntersaction = new Vector(double.MinValue, 0); Vector intersection; for (byte i = 0; i < gameData.matrix.GetLength(0); i++) { if (strategyA_start.X < strategyA_end.X) { break; } strategyB_start = new Vector(gameData.matrix[i, 0], 0); strategyB_end = new Vector(gameData.matrix[i, 1], 1); if (strategyA_start.Equals(strategyB_start) && strategyA_end.Equals(strategyB_end)) { continue; } bool actual = Vector.Intersect(strategyA_start, strategyA_end, strategyB_start, strategyB_end, out intersection); if (actual && intersection.X > maxIntersaction.X && Math.Round(intersection.X, 2) < Math.Round(max, 2)) { maxIntersaction = intersection; newID = i; } } if (maxIntersaction.X > double.MinValue) { Cross2x2 c = new Cross2x2(idLargest, newID, maxIntersaction); if (point == null || c.point.X < point.point.X) { point = c; } GraphicalManager.ins.SetHighLinePoint(new Vector2((float)point.point.X, (float)point.point.Y)); yield return(CrossOverMax(newID, gameData, maxIntersaction.X)); } else { GraphicalManager.ins.SetHighLinePoint(new Vector2((float)strategyA_end.X, (float)strategyA_end.Y)); GraphicalManager.ins.SelectLine(0, EColors.Default, true); } }