public override double CalculateCost(PlaceRoute.Searchspace space, PlaceRoute.SolutionGrader grader) { double cost = 0; var above = space.CalculateCollisions(Position).Where((b) => !(b is UndergroundFlow)) .Where((b) => b != this); foreach (var contender in above) { var productionContender = contender as ProductionBuilding; var flowContender = contender as FlowBuilding; if (productionContender != null) { var recipe = productionContender.Recipe; if (!recipe.Ingredients.Where((i) => i.Item == Item.Item).Any() && !recipe.Results.Where((i) => i.Item == Item.Item).Any()) { cost += grader.CollisionCost; } } else if (flowContender != null) { if (flowContender.Item.Item != Item.Item) { cost += grader.CollisionCost; } } else { cost += grader.CollisionCost; } } return(cost); }
public override double CalculateCost(PlaceRoute.Searchspace space, PlaceRoute.SolutionGrader grader) { var cost = base.CalculateCost(space, grader); var forward = space.CalculateCollisions(Position + Rotation.ToVector()).OfType <Belt>(); if (forward.Where((b) => b.Item.Item == Item.Item && b.Rotation == Rotation.Invert()).Any()) { cost += grader.CollisionCost; } if (this.SolidLeaks(space).Any()) { cost += grader.TouchLeakCost; } for (int i = 0; i < 4; i++) { var dir = ((BuildingRotation)i); var buildings = space.CalculateCollisions(Position + dir.ToVector()).OfType <FlowBuilding>(); foreach (var building in buildings) { if (building.SolidLeaks(space).Contains(this)) { cost += grader.TouchLeakCost; } } } return(cost); }
public double CalculateCost(PlaceRoute.Searchspace space, PlaceRoute.SolutionGrader grader) { var collisions = space.CalculateCollisions(Position, Size).Where((b) => b != this); double cost = 0; var flows = collisions.Where((c) => c is UndergroundFlow).Cast <UndergroundFlow>().Where((f) => f.FlowDepth == FlowDepth); var wells = collisions.Where((c) => c is GroundToUnderground).Cast <GroundToUnderground>().Where((w) => w.FlowDepth == FlowDepth); cost += flows.Where((f) => f.Rotation == Rotation || f.Rotation == Rotation.Invert()).Count() * grader.CollisionCost; cost += wells.Where((f) => f.Rotation == Rotation || f.Rotation == Rotation.Invert()).Count() * grader.CollisionCost; return(cost); }
public override double CalculateCost(PlaceRoute.Searchspace space, PlaceRoute.SolutionGrader grader) { var collisions = space.CalculateCollisions(Position, Size).OfType <UndergroundFlow>(); var sameDepth = collisions.Where((b) => b.FlowDepth == FlowDepth); var sameDir = sameDepth.Where((f) => f.Rotation == Rotation || f.Rotation == Rotation.Invert()); double cost = base.CalculateCost(space, grader) + grader.CollisionCost * sameDir.Count(); if (IsUpward) { if (this.SolidLeaks(space).Any()) { cost += grader.TouchLeakCost; } } return(cost); }
public override double CalculateCost(PlaceRoute.Searchspace space, PlaceRoute.SolutionGrader grader) { #warning No leak cost taken into account yet var cost = 0.0; var collisions = space.CalculateCollisions(Position, Size).Where((b) => b != this && !(b is UndergroundFlow)); foreach (var collision in collisions) { var belt = collision as Belt; if (belt != null) { if (belt.Item.Item != Item.Item || belt.Rotation != Rotation) { cost += grader.CollisionCost; } } else { cost += grader.CollisionCost; } } return(cost); }
public virtual double CalculateCost(PlaceRoute.Searchspace space, PlaceRoute.SolutionGrader grader) { var collisions = space.CalculateCollisions(Position, Size).Where((b) => b != this && !(b is UndergroundFlow)); return(collisions.Count() * grader.CollisionCost); }