private void DetermineWall(BoolGrid ramp, BoolGrid unPathable) { BoolGrid rampAdjacent = unPathable.GetAdjacent(ramp); BoolGrid rampSides = unPathable.GetConnected(rampAdjacent, 5); List <BoolGrid> sides = rampSides.GetGroups(); BoolGrid shrunkenStart = StartArea.Shrink(); List <Point2D> building1Positions = Placable(sides[0], shrunkenStart).ToList(); List <Point2D> building2Positions = Placable(sides[1], shrunkenStart).ToList(); float wallScore = 1000; foreach (Point2D p1 in building1Positions) { foreach (Point2D p2 in building2Positions) { if (System.Math.Abs(p1.X - p2.X) < 3 && System.Math.Abs(p1.Y - p2.Y) < 3) { continue; } float newScore = SC2Util.DistanceGrid(p1, p2); if (newScore >= wallScore) { continue; } for (float i = -2.5f; i < 3; i++) { if (CheckPylon(SC2Util.Point(p1.X + 2.5f, p1.Y + i), p1, p2)) { wallScore = newScore; building1 = p1; building2 = p2; building3 = SC2Util.Point(p1.X + 2.5f, p1.Y + i); } if (CheckPylon(SC2Util.Point(p1.X - 2.5f, p1.Y + i), p1, p2)) { wallScore = newScore; building1 = p1; building2 = p2; building3 = SC2Util.Point(p1.X - 2.5f, p1.Y + i); } if (CheckPylon(SC2Util.Point(p1.X + i, p1.Y + 2.5f), p1, p2)) { wallScore = newScore; building1 = p1; building2 = p2; building3 = SC2Util.Point(p1.X + i, p1.Y + 2.5f); } if (CheckPylon(SC2Util.Point(p1.X + i, p1.Y - 2.5f), p1, p2)) { wallScore = newScore; building1 = p1; building2 = p2; building3 = SC2Util.Point(p1.X + i, p1.Y - 2.5f); } } } } }