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


C# Cell.Any方法代码示例

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


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

示例1: IsFull

        public static bool IsFull(Cell[] sodukuGameData)
        {
            //if any cells don't exist
            if (sodukuGameData.Any(c => c == null))
            {
                return false;
            }

            if (sodukuGameData.All(c => c != null && c.Value > 0))
            {
                return true;
            }

            return false;
        }
开发者ID:RyanBetker,项目名称:SodukuSolver,代码行数:15,代码来源:Program.cs

示例2: BfsDist

        public static double BfsDist(int startI, int startJ, int endI, int endJ, Cell[] forbidden)
        {
            if (_bfsDistMap == null)
                _bfsDistMap = new int[world.Height, world.Width];

            var q = new Queue<int>();
            q.Enqueue(endI);
            q.Enqueue(endJ);

            for (var i = 0; i < world.Height; i++)
                for (var j = 0; j < world.Width; j++)
                    _bfsDistMap[i, j] = Infinity;

            _bfsDistMap[endI, endJ] = 0;
            while (q.Count > 0)
            {
                var curI = q.Dequeue();
                var curJ = q.Dequeue();
                var cur = new Cell(curI, curJ);

                EnumerateNeigbours(cur, to =>
                {
                    if (!CanPass(cur.I, cur.J, to.I, to.J) || forbidden.Any(x => x.Equals(to.I, to.J)))
                        return;

                    var distTo = _bfsDistMap[cur.I, cur.J] + 1;
                    if (distTo < _bfsDistMap[to.I, to.J])
                    {
                        _bfsDistMap[to.I, to.J] = distTo;
                        q.Enqueue(to.I);
                        q.Enqueue(to.J);
                    }
                });
            }

            if (_bfsDistMap[startI, startJ] == Infinity)
            {
                if (forbidden.Length == 0)
                    throw new Exception("bfs path not found");
                return BfsDist(startI, startJ, endI, endJ, new Cell[] {});
            }

            return _bfsDistMap[startI, startJ];
        }
开发者ID:znsoft,项目名称:AiCup,代码行数:44,代码来源:FindPath.cs

示例3: DijkstraNextCell

        public static Cell DijkstraNextCell(int startI, int startJ, int endI, int endJ, Cell[] forbidden)
        {
            if (_distMap == null)
            {
                _distMap = new double[world.Height, world.Width];
                _distPrev = new Cell[world.Height, world.Width];
            }

            var q = new PriorityQueue<Pair<double, Cell>>();
            q.Push(new Pair<double, Cell>(0.0, new Cell(endI, endJ)));
            for (var i = 0; i < world.Height; i++)
                for (var j = 0; j < world.Width; j++)
                    _distMap[i, j] = Infinity;
            _distMap[endI, endJ] = 0;
            while (q.Count > 0)
            {
                var cur = q.Top().Second;
                var minDist = -q.Top().First;
                q.Pop();

                if (minDist > _distMap[cur.I, cur.J])
                    continue;

                EnumerateNeigbours(cur, to =>
                {
                    if (!CanPass(cur.I, cur.J, to.I, to.J) || forbidden.Any(x => x.Equals(to.I, to.J)))
                        return;

                    var distTo = _distMap[cur.I, cur.J] + GetCost(to);
                    if (distTo < _distMap[to.I, to.J])
                    {
                        _distMap[to.I, to.J] = distTo;
                        _distPrev[to.I, to.J] = cur;
                        q.Push(new Pair<double, Cell>(-distTo, to));
                    }
                });
            }

            if (_distPrev[startI, startJ] == null)
            {
                if (forbidden.Length == 0)
                    throw new Exception("path not found");
                return DijkstraNextCell(startI, startJ, endI, endJ, new Cell[] {});
            }

            return _distPrev[startI, startJ];
        }
开发者ID:znsoft,项目名称:AiCup,代码行数:47,代码来源:FindPath.cs


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