コード例 #1
0
ファイル: Example.cs プロジェクト: kidroca/Students-Generator
        static void Main()
        {
            var generator = new SimpleGenerator();

            IList<Student> students = generator.Genereate(10);

            Console.WriteLine("Working with this set of students:\n");

            foreach (var s in students)
            {
                Console.WriteLine(s);
                Console.WriteLine("Group: {0}\n", s.GroupNumber);
            }

            var textDocParser = new TextDocumentParser();

            IList<XcelStudent> xcelStudents =
                textDocParser.Genereate(10, 10).Cast<XcelStudent>().ToList();

            foreach (var s in xcelStudents)
            {
                Console.WriteLine(s);
                Console.WriteLine("Type: {0}\n", s.StudentType);
            }
        }
コード例 #2
0
ファイル: Example.cs プロジェクト: kidroca/Students-Generator
        static void Main()
        {
            var generator = new SimpleGenerator();

            IList <Student> students = generator.Genereate(10);

            Console.WriteLine("Working with this set of students:\n");

            foreach (var s in students)
            {
                Console.WriteLine(s);
                Console.WriteLine("Group: {0}\n", s.GroupNumber);
            }

            var textDocParser = new TextDocumentParser();

            IList <XcelStudent> xcelStudents =
                textDocParser.Genereate(10, 10).Cast <XcelStudent>().ToList();

            foreach (var s in xcelStudents)
            {
                Console.WriteLine(s);
                Console.WriteLine("Type: {0}\n", s.StudentType);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: CopperPenguin96/GemBlocks
        static void Main(string[] args)
        {
            try
            {
                /*
                 * Determine the type of generator
                 * either by SimpleGenerator(WorldKinds)
                 * or by FlatGenerator(Layers)
                 */
                IGenerator gen = new SimpleGenerator(WorldKinds.Default);

                /*
                 * Name the world,
                 * assign the generator to the level,
                 * set the gamemode,
                 * set the spawn point
                 */
                Level level = new Level("SimpleWorld", gen)
                {
                    GameMode = GameMode.Creative, SpawnPoint = new Position(0, 50, 0)
                };

                // Load the level into a world
                World world = new World(level);

                // If I have to explain this one we have issues.
                world.Save();
            }
            finally
            {
                Console.WriteLine("Finished!");
            }
        }
コード例 #4
0
        private IList <long> GetIds(int number)
        {
            var ids = new List <long>(number);

            for (int i = 0; i < number; i++)
            {
                ids.Add(SimpleGenerator.NextLong());
            }

            return(ids);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            var gen = new SimpleGenerator(
                "WorkManager.Data",
                "localhost",
                "WorkManager", "sa", "123456",
                "Models", "WorkContext",
                "../../../../WorkManager.Data");

            gen.Regen(args);
        }
コード例 #6
0
        public void SimpleGenerator_When_Size4Seed123_Then_MovedDesk()
        {
            var desk = _helper.GenerateDesk(4);

            int?[,] newDesk = _helper.GetNewDeskWithSize4();

            var simpleGenerator = new SimpleGenerator();

            simpleGenerator.MoveCells(desk, 1, 123);

            Assert.NotEqual(desk.GetDesk(), newDesk);
        }
コード例 #7
0
ファイル: BuildGameHandler.cs プロジェクト: tdav/syzygy
        public BuildGameHandler(NetServer server, PlayerLookup players, PlayerConnectionLookup connections, Id <Player> ownID)
            : base(server, players, ownID, new ServerBehaviourProvider(server, connections))
        {
            this.stateBuilder = new StateContainer.Builder
            {
                Server      = server,
                Players     = players,
                Connections = connections,
            };
            var generator = new SimpleGenerator();

            var instructions = generator.Generate(players.Select(p => p.ID).ToList());

            // instructions may want to be spaced out in time in the future,
            // to prevent packet loss, and thus longer building time
            foreach (var instruction in instructions)
            {
                // build own game
                this.executeInstruction(instruction);

                if (connections.Count > 0)
                {
                    // instruct clients how to build game
                    var message = server.CreateMessage();
                    instruction.WriteMessage(message);
                    server.SendMessage(message, connections, NetDeliveryMethod.ReliableOrdered, 0);
                }
            }

            // send finish message and finish
            this.finish(this.stateBuilder);

            if (connections.Count > 0)
            {
                var finishMessage = server.CreateMessage();
                finishMessage.Write((byte)GenerationMessageType.FinishGenerating);
                server.SendMessage(finishMessage, connections, NetDeliveryMethod.ReliableOrdered, 0);
            }
        }
コード例 #8
0
 public void DoGenerator()
 {
     UId = SimpleGenerator.NextLong();
 }
コード例 #9
0
        static void Main(string[] args)
        {
            int    count    = 1;
            string fileName = "default.json";

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "--count":
                case "-c":
                    i++;
                    if (args.Length == i)
                    {
                        Error("オプションの値がありません.");
                    }

                    if (!int.TryParse(args[i], out count))
                    {
                        Error("回数が数値ではありません.");
                    }
                    break;

                default:
                    fileName = args[i];
                    break;
                }
            }

            WordGeneratorOption option = null;

            try
            {
                using (var stream = File.OpenText(fileName))
                {
                    option = JsonConvert.DeserializeObject <WordGeneratorOption>(stream.ReadToEnd());
                }
            }
            catch (Exception ex)
            {
                Error("設定ファイルの読み込みに失敗しました.", ex);
            }

            IGenerator generator = null;

            switch (option.Type)
            {
            case "Simple":
                generator = new SimpleGenerator();
                break;

            case "Replacement":
                generator = new ReplacementGenerator();
                break;

            case "Transition":
                generator = new TransitionGenerator();
                break;

            case "ReplacementTransition":
                generator = new ReplacementTransitionGenerator();
                break;

            default:
                generator = new SimpleGenerator();
                break;
            }

            try
            {
                generator.Settings = option.GeneratorOptions;

                List <string> list = new List <string>();
                int           i    = 0;
                while (i < count)
                {
                    string result = generator.Create();

                    if (!list.Contains(result))
                    {
                        list.Add(result);
                        i++;
                    }
                    if (result == "" && list.Contains(""))
                    {
                        break;
                    }
                }

                foreach (var item in list)
                {
                    Console.WriteLine(item);
                }
            }
            catch (Exception ex)
            {
                Error("単語文字列の作成に失敗しました.", ex);
            }
        }
コード例 #10
0
 public StudentTests(ConsoleMio consoleMio, SimpleGenerator studentsGenerator)
 {
     this.ConsoleMio        = consoleMio;
     this.StudentsGenerator = studentsGenerator;
     this.TestStudents      = this.StudentsGenerator.Generate(7);
 }