// tag::createBoard[] public Board CreateBoard(Square[,] grid) { Debug.Assert(grid != null); Board board = new Board(grid); int width = board.Width; int height = board.Height; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Square square = grid[x, y]; foreach (Direction dir in Direction.Values) { int dirX = (width + x + dir.DeltaX) % width; int dirY = (height + y + dir.DeltaY) % height; Square neighbour = grid[dirX, dirY]; square.Link(neighbour, dir); } } } return board; }
public void link(Square neighbour, Direction dir) { }
public Board(Square[,] grid) { }