コード例 #1
0
        private static LifeBoard GetCuboidLifeBoard()
        {
            Console.Clear();

            int width  = GetInt32("Enter width [3]: ", 3);
            int height = GetInt32("Enter height [3]: ", 3);
            int depth  = GetInt32("Enter depth [3]: ", 3);
            IEnumerable <Position> alivePositions = GetAlivePositions();

            return(CuboidLifeBoard.Create(width, height, depth, alivePositions));
        }
コード例 #2
0
        private static async Task CreateGameFromParameters(Options options)
        {
            if (options.GameFilePath != null)
            {
                await LoadGame(options.GameFilePath).ConfigureAwait(false);
            }
            else
            {
                List <Position> alivePositions = new List <Position>();

                for (int i = 0; i < (options.AlivePositions.Length - 1); i += 2)
                {
                    alivePositions.Add(new Position(options.AlivePositions[i], options.AlivePositions[i + 1]));
                }

                if (Rules.IsValid(options.Rules))
                {
                    Rules rules = new Rules(options.Rules);

                    LifeBoard lifeBoard = null;
                    switch (options.Board)
                    {
                    case Options.BoardType.Toroid:
                        lifeBoard = ToroidLifeBoard.Create(options.Width, options.Height, alivePositions);
                        break;

                    case Options.BoardType.Cuboid:
                        lifeBoard = CuboidLifeBoard.Create(options.Width, options.Height, options.Depth, alivePositions);
                        break;
                    }

                    if (lifeBoard != null)
                    {
                        await CreateGame(rules, lifeBoard);
                    }
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Creates a new instance of the see <see cref="CuboidLifeBoard"/>.
 /// </summary>
 /// <returns></returns>
 public LifeBoard Create()
 {
     return(CuboidLifeBoard.Create(Width, Height, Depth, new List <Position>()));
 }