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


C# IGrid类代码示例

本文整理汇总了C#中IGrid的典型用法代码示例。如果您正苦于以下问题:C# IGrid类的具体用法?C# IGrid怎么用?C# IGrid使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GridEventManager

    public GridEventManager(ISetting setting, IGrid grid, IGroupFactory groupFactory)
    {
        _grid = grid;
        _groupFactory = groupFactory;

        _setting = setting;
    }
开发者ID:Mojopon,项目名称:ThreeSeven,代码行数:7,代码来源:GridEventManager.cs

示例2: Run

        public void Run(ref IGrid grid, SelectionFunction SelectionFunction)
        {
            var startAt = grid.GetRandomCell;
            active = new Stack<Cell>();
            active.Push(startAt);

            while(active.Any())
            {
                var cell = SelectionFunction(active);  
                var availableNeighbors = cell.Neighbors.Where(x => x.Links.Count == 0);

                if (availableNeighbors.Any())
                {
                    var neighbor = availableNeighbors.Sample();
                    cell.Link(neighbor);
                    active.Push(neighbor);
                }
                else
                {
                    var list = active.ToList();
                    list.Remove(cell);
                    active = new Stack<Cell>(list);
                }
            }
        }
开发者ID:davidjeet,项目名称:MazesCSharp,代码行数:25,代码来源:GrowingTree.cs

示例3: GetEmptySquares

 public IEnumerable<Point> GetEmptySquares(IGrid grid)
 {
     for (int x = 0; x < grid.Size; x++)
         for (int y = 0; y < grid.Size; y++)
             if (grid[x, y].Content == TileContent.Empty)
                 yield return new Point(x, y);
 }
开发者ID:Tirinst,项目名称:NeuralNetworksAndMachineLearning,代码行数:7,代码来源:ValidMoveGetter.cs

示例4: GridPagingSettings

 public GridPagingSettings(IGrid grid)
 {
     this.grid = grid;
     Style = GridPagerStyles.NextPreviousAndNumeric;
     CurrentPage = 1;
     PageSizesInDropDown = new[] {5, 10, 20, 50};            
 }
开发者ID:akhuang,项目名称:Asp.net-MVC-3,代码行数:7,代码来源:GridPagingSettings.cs

示例5: GridGroupingSettings

        public GridGroupingSettings(IGrid grid)
        {
            this.grid = grid;

            Groups = new List<GroupDescriptor>();
            Visible = true;
        }
开发者ID:vialpando09,项目名称:RallyPortal2,代码行数:7,代码来源:GridGroupingSettings.cs

示例6: Scene

        public Scene(float bandLambda, float breakingThreshold, float timeStep, int stepSize, IGrid grid)
        {
            TimeStep = timeStep;
            StepSize = stepSize;
            Stopwatch = new Stopwatch();

            var center = new Vector2(grid.Width, grid.Height) / 2;
            var offset = -center;

            Nodes = grid.Vertices.Select(v => new Node(v + offset)).ToArray();

            var edges = grid.Edges;
            Bands = new Band[edges.Count];

            for (int i = 0; i < edges.Count; i++)
            {
                var edge = edges[i];
                float length = Vector2.Distance(Nodes[edge.Index1].Position, Nodes[edge.Index2].Position);
                float restLength = 0.95f * length;
                Bands[i] = new Band(edge.Index1, edge.Index2, bandLambda, restLength, restLength * breakingThreshold);
            }

            BandCount = edges.Count;
            Impulses = new Vector2[Nodes.Length];
            PreviousImpulses = new Vector2[Nodes.Length];
        }
开发者ID:Jorenkv,项目名称:Tearing,代码行数:26,代码来源:Scene.cs

示例7: PrintLabirynth

        /// <summary>
        /// Prints the labyrinth to the console
        /// </summary>
        /// <param name="grid">the playfield</param>
        public void PrintLabirynth(IGrid grid)
        {
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine(" " + new string('\u2593', (grid.TotalRows * 2) + 3));

            for (int row = 0; row < grid.TotalRows; row++)
            {
                Console.Write("{0,2}", "\u2593");
                for (int col = 0; col < grid.TotalCols; col++)
                {
                    var currentCell = grid.GetCell(row, col);
                    if (currentCell == GlobalConstants.PlayerSignSymbol)
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                    }

                    Console.Write("{0,2}", currentCell);
                }

                Console.Write("{0,2}", "\u2593");
                Console.WriteLine();
            }
            Console.WriteLine(" " + new string('\u2593', (grid.TotalCols * 2) + 3));
        }
开发者ID:TeamLabyrinth5-Telerik,项目名称:Labyrinth,代码行数:32,代码来源:ConsoleRenderer.cs

示例8: plant_mines_on

        public void plant_mines_on(IGrid grid)
        {
            var coordinates = _random_coordinate_picker.pick_coordinates_from(_game_difficulty.minefield_size, _game_difficulty.number_of_mines);

            foreach(var coordinate in coordinates)
                grid.plant_mine_at(coordinate);
        }
开发者ID:elbandit,项目名称:CQRS-Minesweeper,代码行数:7,代码来源:MinePlanter.cs

示例9: Game

    public Game(IGrid grid, ISetting setting)
    {
        _setting = setting;
        _grid = grid;

        currentControl = _grid;
    }
开发者ID:Mojopon,项目名称:ThreeSeven,代码行数:7,代码来源:Game.cs

示例10: GetWinner

 public Piece GetWinner(IGrid grid)
 {
     foreach (var p in new[] { Piece.X, Piece.O })
         if (GetWinnableLines(grid.Size).Any(line => line.All(pos => p == grid[pos].Content)))
             return p;
     return null;
 }
开发者ID:Tirinst,项目名称:NeuralNetworksAndMachineLearning,代码行数:7,代码来源:WinDectector.cs

示例11: MoveRover

        private static void MoveRover(IGrid grid, string locationLine, string movesLine)
        {
            IDirectionParser directionParser = (IDirectionParser)container[typeof(IDirectionParser)];
            ILocationParser locationParser = (ILocationParser)container[typeof(ILocationParser)];

            Direction direction = directionParser.GetDirection(locationLine);
            Point location = locationParser.GetLocation(locationLine);
            IMoveSupplier supplier = (IMoveSupplier)container[typeof(IMoveSupplier)];

            supplier.Init(movesLine);
            Rover rover = new Rover(direction, location, grid, supplier);
            try
            {
                rover.ExecuteMoves();
            }
            catch (InvalidLocationException ex)
            {
                Console.WriteLine(MarsRover.IllegalLocation);
            }
            Console.WriteLine(String.Format("{0} {1} {2}", rover.Location.X, rover.Location.Y, rover.Direction));

            container.Release(supplier);
            container.Release(directionParser);
            container.Release(locationParser);
        }
开发者ID:stimms,项目名称:MarsRover,代码行数:25,代码来源:Program.cs

示例12: On

        public IGrid<Cell> On(IGrid<Cell> grid, Cell startAt = null)
        {
            if (startAt == null)
            {
                startAt = grid.RandomCell();
            }

            var stack = new Stack<Cell>();
            stack.Push(startAt);

            while (stack.Count != 0)
            {
                var current = stack.Peek();
                var neighbours = current.Neighbours().Where(n => n.Links.Count == 0).ToList();
                if (neighbours.Count == 0)
                {
                    stack.Pop();
                }
                else
                {
                    var neighbour = neighbours[rand.Next(neighbours.Count)];
                    current.Link(neighbour);
                    stack.Push(neighbour);
                }


            }

            return grid;
        }
开发者ID:euang,项目名称:Maze-in-csharp,代码行数:30,代码来源:RecursiveBackTracker.cs

示例13: SmartCPUBehaviour

    public SmartCPUBehaviour(IGrid grid, ISetting setting, CPUMode difficulty)
    {
        _grid = grid;
        _gridSimulator = new GridSimulator(grid, setting);
        _outputter = new OutputBestMovement(_gridSimulator);
        _grid.OnGroupAdd += new OnGroupAddEventHandler(OnGroupAddEvent);

        Debug.Log("difficulty " + difficulty + "set");
        switch(difficulty)
        {
            case CPUMode.Easy:
                timeBeforeAction = 0.5f;
                timeBetweenActions = 0.5f;
                break;
            case CPUMode.Normal:
                timeBeforeAction = 0.5f;
                timeBetweenActions = 0.3f;
                break;
            case CPUMode.Hard:
                timeBeforeAction = 0.2f;
                timeBetweenActions = 0.1f;
                break;
            case CPUMode.Kusotuyo:
                timeBeforeAction = 0f;
                timeBetweenActions = 0f;
                break;
        }
    }
开发者ID:Mojopon,项目名称:ThreeSeven,代码行数:28,代码来源:SmartCPUBehaviour.cs

示例14: GenerateGrid

        /// <summary>
        /// Generete game field
        /// </summary>
        /// <param name="grid">Field member</param>
        /// <param name="player"Player member></param>
        /// <returns>Genereted game filed</returns>
        public IGrid GenerateGrid(IPlayer player, IGrid grid)
        {
            DefaultRandomGenerator random = DefaultRandomGenerator.Instance();
            int percentageOfBlockedCells = random.Next(GlobalConstants.MinimumPercentageOfBlockedCells, GlobalConstants.MaximumPercentageOfBlockedCells);

            for (int row = 0; row < grid.TotalRows; row++)
            {
                for (int col = 0; col < grid.TotalCols; col++)
                {
                    int num = random.Next(0, 100);
                    if (num < percentageOfBlockedCells)
                    {
                        grid.SetCell(row, col, GlobalConstants.BlockedCellSymbol);
                    }
                    else
                    {
                        grid.SetCell(row, col, GlobalConstants.FreeCellSymbol);
                    }
                }
            }

            grid.SetCell(grid.TotalRows / 2, grid.TotalCols / 2, GlobalConstants.PlayerSignSymbol);

            this.MakeAtLeastOneExitReachable(grid, player);
            return grid;
        }
开发者ID:TeamLabyrinth5-Telerik,项目名称:Labyrinth,代码行数:32,代码来源:Initializer.cs

示例15: Run

        public void Run(ref IGrid grid)
        {
            var current = grid.GetRandomCell;

            while(current != null)
            {
                var unvisitedNeighbors = current.Neighbors.Where(x => x.Links.Count == 0); // get all neighbors of cell that does not have any links (yet)

                if (unvisitedNeighbors.Count() > 0)
                {
                    var neighbor = unvisitedNeighbors.Sample<Cell>();
                    current.Link(neighbor);
                    current = neighbor;
                }
                else
                {
                    current = null;
                }

                foreach(var cell in grid)
                {
                    var visitedNeighbors = cell.Neighbors.Where(x => x.Links.Count() > 0);
                    if ((cell.Links.Count == 0 || cell.Links== null) && visitedNeighbors.Count() > 0)
                    {
                        current = cell;

                        var neighbor = visitedNeighbors.Sample<Cell>();
                        current.Link(neighbor);

                        break;
                    }
                }
            }
        }
开发者ID:davidjeet,项目名称:MazesCSharp,代码行数:34,代码来源:HuntAndKill.cs


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