コード例 #1
0
ファイル: Program.cs プロジェクト: aquamoth/CodeinGame
 private static IEnumerable<Entity> edible(Entity currentChip, Entity[] entities)
 {
     return entities.Except(new[] { currentChip })
         .Where(chip => chip.Radius < currentChip.Radius || chip.Player == currentChip.Player)
         .Where(chip => chip.DistanceTo(currentChip) < ATTACK_RANGE)
         .Where(chip => (chip.V - currentChip.V).Length < 50) //Don't hunt down propulsion droplets
         .ToArray();
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: aquamoth/CodeinGame
 private static Tuple<Entity, float> closestSiblingToEat(Entity currentChip, Entity[] myChips)
 {
     var siblings = myChips.Except(new[] { currentChip });
     var closestSibling = siblings
         .Where(chip => chip.State == ChipState.Waiting)
         .Select(sibling => new Tuple<Entity, float>(sibling, sibling.DistanceTo(currentChip)))
         .OrderBy(x => x.Item2)
         .FirstOrDefault();
     return closestSibling;
 }