当前位置: 首页>>代码示例>>C#>>正文


C# Zone.Select方法代码示例

本文整理汇总了C#中Zone.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Zone.Select方法的具体用法?C# Zone.Select怎么用?C# Zone.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zone的用法示例。


在下文中一共展示了Zone.Select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SelectZone

 public void SelectZone(Zone zone)
 {
     Debug.Log("SELECT ZONE1! " + zone);
     UnselectAllZones();
     Debug.Log("SELECT ZONE2! " + zone);
     selectedZones.Add(zone);
     Debug.Log("SELECT ZONE3! " + zone);
     zone.Select();
     Debug.Log("SELECT ZONE4! " + zone);
     Main.instance.dude.GotTo(zone);
 }
开发者ID:rowenar11,项目名称:digiforge,代码行数:11,代码来源:Grid.cs

示例2: 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;
    }
开发者ID:aquamoth,项目名称:CodeinGame,代码行数:73,代码来源:Program.cs


注:本文中的Zone.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。