本文整理汇总了C#中Zone.Where方法的典型用法代码示例。如果您正苦于以下问题:C# Zone.Where方法的具体用法?C# Zone.Where怎么用?C# Zone.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zone
的用法示例。
在下文中一共展示了Zone.Where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: solve
static Command solve(IEnumerable<Drone> myDrones, Zone[] zones, bool IsFirstLoop = true)
{
if (!myDrones.Any())
return null;
var drone = myDrones.First();
Command bestCommand = null;
foreach (var zone in zones.Where(z => z.RequiredDrones > 0))
{
//log("Testing drone #{0} at zone #{1}", drone.Index, zone.Index);
var oldZoneTurns = zone.Turns;
zone.RequiredDrones--;
var overTakesZone = zone.RequiredDrones == 0;
zone.Turns = Math.Max(zone.Turns, drone.SquareDistanceTo(zone) / 10000 - 1);
var nextCommand = solve(myDrones.Skip(1), zones, false);
var isBest = bestCommand == null;
if (!isBest)
{
var bestCommandArray = flatten(bestCommand);
var bestOverTakenZones = bestCommandArray.Select(c => c.OvertakesZone).Count();
var commandArray = flatten(nextCommand);
var overTakenZones = commandArray.Select(c => c.OvertakesZone).Count();
isBest = overTakenZones > bestOverTakenZones;
if (overTakenZones == bestOverTakenZones)
{
var bestScore = bestCommandArray.Where(c => c.OvertakesZone).Sum(c => c.Turns);
var score = commandArray.Where(c => c.OvertakesZone).Sum(c => c.Turns);
isBest = score > bestScore;
}
}
if (isBest)
{
//log("Choosing drone #{0} to zone #{1}", drone.Index, zone.Index);
bestCommand = new Command
{
Drone = drone,
Zone = zone,
Destination = zone, //TODO: Move to the outer rim of the zone
OvertakesZone = overTakesZone,
Turns = overTakesZone ? zone.Turns : 0,
Next = nextCommand
};
}
zone.RequiredDrones++;
zone.Turns = oldZoneTurns;
}
if (bestCommand == null) //There are NO zones to win
{
//TODO: Also choose this if the best zone still can't be captured
//log("No zone to win for drone #{0}.", drone.Index);
//TODO: Move to a strategic position instead
var centerOfZones = new Point
{
X = (int)zones.Select(z => z.X).Average(),
Y = (int)zones.Select(z => z.Y).Average()
};
bestCommand = new Command
{
Drone = drone,
Destination = centerOfZones,
Next = solve(myDrones.Skip(1), zones, false)
};
}
return bestCommand;
}
示例2: LoadZoneInternal
private void LoadZoneInternal(Zone zone)
{
var nameServers = zone.OfType<NsRecord>().Where(x => x.Name == DomainName.Root).Select(x => x.NameServer);
RootServers = zone.Where(x => x.RecordType == RecordType.A || x.RecordType == RecordType.Aaaa).Join(nameServers, x => x.Name, x => x, (x, y) => ((IAddressRecord) x).Address).ToList();
RootKeys = zone.OfType<DnsKeyRecord>().Where(x => (x.Name == DomainName.Root) && x.IsSecureEntryPoint).Select(x => new DsRecord(x, x.TimeToLive, DnsSecDigestType.Sha256)).ToList();
}