示例#1
0
    IEnumerator spawnningSpawner()
    {
        while (this.states == state.alive)
        {
            yield return(new WaitForSeconds(10f));

            string _word;
            bool   same;
            do
            {
                same  = false;
                _word = WordGenerator.RandomizeWord();
                foreach (Word Xword in GameManager.GetList())
                {
                    if ((_word == Xword.word))
                    {
                        same = true;
                    }
                }
            } while (_word.Length > 4 || same);

            Word word = new Word(_word, spawnChild(), 1);
            GameManager.UpdateWordList(word);
        }
    }
示例#2
0
 IEnumerator spawningShotgun()
 {
     while (this.states == state.alive)
     {
         string _word;
         bool   same;
         float  _deg = 85f;
         for (int i = 0; i < 5; i++)
         {
             do
             {
                 same  = false;
                 _word = WordGenerator.RandomizeWordAlphabet();
                 foreach (Word Xword in GameManager.GetList())
                 {
                     if ((_word == Xword.word))
                     {
                         same = true;
                     }
                 }
             } while (same);
             Word word = new Word(_word, spawnChildShotgun(_deg), 2);
             _deg -= 42.5f;
             GameManager.UpdateWordList(word);
         }
         yield return(new WaitForSeconds(30f));
     }
 }
示例#3
0
    // Generates words and adds them to list
    public void AddWord(GameObject worldObject)
    {
        Word word = new Word(WordGenerator.GetRandomWord(words, startChars), wordSpawner.SpawnWord(worldObject), worldObject);

        startChars.Add(word.word[0]);
        words.Add(word);
    }
示例#4
0
        public static string Generate(Options args)
        {
            WordGenerator       generator           = new WordGenerator();
            LoremIpsumGenerator loremIpsumGenerator = new LoremIpsumGenerator();

            return(loremIpsumGenerator.Next(args.ParagraphCount, args.MaxSentenceInParagraph));
        }
示例#5
0
        private async Task ScheduleNewEvent(DateTime mondayInWeekToScheduleEvent)
        {
            _logger.Debug("Creating new event...");

            var eventId     = WordGenerator.GetRandomWordString(3);
            var timeOfEvent = GetTimeOfNextEvent(mondayInWeekToScheduleEvent);
            var toInvite    = await FindPeopleToInvite(_config.PizzaRoom.Room, _config.InvitesPerEvent, new List <Person>());

            var newPlan = new PizzaPlan()
            {
                Id          = eventId,
                TimeOfEvent = timeOfEvent,
                Invited     = toInvite.ToList(),
                Channel     = _config.PizzaRoom.Room,
                City        = _config.PizzaRoom.City
            };
            var inviteList = toInvite.Select(i => new Invitation()
            {
                EventId   = eventId,
                UserId    = i.UserId,
                UserName  = i.UserName,
                EventTime = timeOfEvent,
                Room      = newPlan.Channel,
                City      = newPlan.City
            }).ToList();

            _pizzaInviter.Invite(inviteList);

            _activityLog.Log($"Created a new Pizza Plan '{newPlan.Id}' for {inviteList.Count} participants.");
            _activePlans.Add(newPlan);
            _storage.SaveArray(ACTIVEEVENTSFILE, _activePlans.ToArray());
        }
示例#6
0
        public void GetsAWordFromList()
        {
            var word = WordGenerator.GetRandomWord();

            Assert.IsNotNull(word);
            Assert.Greater(word.Length, 0);
        }
示例#7
0
    public void AddWord()
    {
        Word word = new Word(WordGenerator.GetRandomWord(), wordSpawner.SpawnWord());

        Debug.Log("New letter is : " + word.word);
        words.Add(word);
    }
        public void WordGen_EachWordIsRandom()
        {
            var word1 = WordGenerator.Generate();
            var word2 = WordGenerator.Generate();

            Assert.NotEqual(word1, word2);
        }
示例#9
0
    public void AddWord()
    {
        Word newWord = new Word(WordGenerator.GetRandomWord());

        //Debug.Log(newWord.word);
        mWords.Add(newWord);
    }
示例#10
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome!");

            //var filter = new Kata5BloomFilter();
            var    filter   = new Kata5BloomFilter(1024, 1024 * 1024);
            string filePath = "wordlist_few.txt";

            Console.WriteLine();
            Console.WriteLine($"Loading SpellChecker Dictionary Words from {filePath}...");

            // Adding words from file
            AddWordsToBloomFilter(filter, filePath);

            Console.WriteLine();
            Console.WriteLine("Verifying if words exist in SpellChecker.");
            VerifyWordsExist(filter, "verify.txt");

            // Generate Words
            Console.WriteLine();
            Console.WriteLine("Generating Words.");
            List <string> generatedWords = WordGenerator.GenerateWords(6);

            foreach (var word in generatedWords)
            {
                CheckWordExists(filter, word);
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
        public void T_ResetSubchains_NoOptions()
        {
            WordGenerator wordGenerator = InitSimpleWordGen();

            Assert.Throws(typeof(Exceptions.NoPossibleElements),
                          delegate { wordGenerator.ResetSubchains(new ChainCondition(ck => ck.Words[0] == "DoestNotExist")); });
        }
        public void T_GetNext_SimpleLongChain()
        {
            ChainGenerator chainGenerator = TestUtils.Create2WordGen(_simpleSentence);
            WordGenerator  wordGenerator  = InitSimpleWordGen();

            wordGenerator.ResetSubchains(new ChainCondition(ck => ck.Words[0] == null && ck.Words[1] == null), null);

            chainGenerator.GenerateChains();
            ChainMap origChains = chainGenerator.Chains;

            StringBuilder sb = new StringBuilder();

            sb.Append(wordGenerator.CurrentWord);
            for (int i = 0; i < 200; i++)
            {
                sb.Append(" ");
                sb.Append(wordGenerator.GetNextWord());
            }

            chainGenerator = TestUtils.Create2WordGen(sb.ToString());
            chainGenerator.GenerateChains();
            ChainMap resultChains = chainGenerator.Chains;

            //When we get to the end we should start from the beginning
            origChains.AddToChain(new ChainKey(new string[] { "two", "?" }), "hello");
            origChains.AddToChain(new ChainKey(new string[] { "?", "hello" }), "world");

            TestUtils.CompareChainTablesNoDuplicates(origChains, resultChains);
        }
示例#13
0
 private static IEnumerable <Category> GetRandomData()
 {
     return
         (new DomainGenerator()
          .With <Category>(g => g.For(category => category.Id, 0, val => val + 1))
          .With <Category>(g => g.For(category => category.Title, new StringGenerator(5, 10, 'H', 'a', 'l')))
          .With <Category>(
              g => g.For(category => category.Description,
                         new StringBuilderGenerator()
                         .Append("Not many", "Lots of", "Some")
                         .Space()
                         .Append("big", "small", "dangerous", "volatile", "futile")
                         .Space()
                         .Append("paintbrushes", "camels", "radio antaennas")
                         .Period(),
                         new NumericStringGenerator(4, 12)))
          .OneToMany <Category, Product>(3, 7, (c, p) => c.Products.Add(p))
          .With <Product>(g => g.For(product => product.Id, 0, val => val + 1))
          .With <Product>(g => g.For(product => product.Title, "title1", "title2", "Another title"))
          .With <Product>(
              g => g.For(product => product.Description,
                         new StringBuilderGenerator()
                         .Append(WordGenerator.FromFile("Adjectives.txt")).Space()
                         .Space().Dot().Dot().Dot().Space().Question(),
                         new StringBuilderGenerator()
                         .Append(WordGenerator.FromFile("Colours.txt")).Space()
                         .Append(WordGenerator.FromFile("Adjectives.txt")).Space()
                         .Append(WordGenerator.FromFile("Nouns.txt"))
                         .Period()))
          .With <Product>(g => g.For(product => product.Price, val => Math.Round(val, 2)))
          .With <Product>(g => g.For(product => product.Created, 31.December(2009), val => val.AddDays(1)))
          .Many <Category>(4, 8));
 }
        public void T_GetSubChain()
        {
            WordGenerator gen = InitSimpleWordGen();

            //Should give me both "hello world one" and "hello world two"
            ChainMap tempMap    = gen.GetSubChain(new ChainCondition(cw => cw.Words[0] == "hello", w => w.Length == 3));
            ChainMap correctMap = new ChainMap();

            correctMap.AddToChain(new ChainKey(new string[] { "hello", "world" }), "one");
            correctMap.AddToChain(new ChainKey(new string[] { "hello", "world" }), "two");
            TestUtils.CompareChainTables(correctMap, tempMap);

            //Should give me just "hello world one"
            tempMap    = gen.GetSubChain(new ChainCondition(cw => cw.Words[0] == "hello", w => w.StartsWith("o")));
            correctMap = new ChainMap();
            correctMap.AddToChain(new ChainKey(new string[] { "hello", "world" }), "one");
            TestUtils.CompareChainTables(correctMap, tempMap);

            //If passed in condition is null nothing should change
            tempMap = gen.GetSubChain(new ChainCondition(null, null));
            TestUtils.CompareChainTables(gen.Chains, tempMap);

            //If impossible condition is passed in exception should be thrown
            Assert.Throws(typeof(Exceptions.NoPossibleElements), delegate
                          { gen.GetSubChain(new ChainCondition(null, w => w == "Does not exist")); });
        }
示例#15
0
    public void AddWord()
    {
        Word word = new Word(WordGenerator.GetRandomWord(), spawner.SpawnWord());

        Debug.Log(word.word);
        words.Add(word);
    }
        public void T_GetRandomKey_WithParams()
        {
            WordGenerator gen    = InitSimpleWordGen();
            ChainMap      subMap = new ChainMap();
            ChainKey      key1   = new ChainKey(new string[] { "key1", "key2", "key3" });
            ChainKey      key2   = new ChainKey(new string[] { "key1", "key2", "key4" });

            subMap.AddToChain(key1, "val1");
            subMap.AddToChain(key2, "val2");
            bool key1Found, key2Found;

            key1Found = key2Found = false;

            for (int i = 0; i < 10; i++)
            {
                ChainKey currKey = gen.GetRandomKey(subMap);
                if (key1.Equals(currKey))
                {
                    key1Found = true;
                }
                else if (key2.Equals(currKey))
                {
                    key2Found = true;
                }
                else
                {
                    Assert.Fail("Invalid key returned");
                }
            }
            if (!(key1Found && key2Found))
            {
                Assert.Fail("GetRandomKey is not random");
            }
        }
        public void T_GetNext_NoOptions()
        {
            WordGenerator wordGenerator = InitSimpleWordGen();

            Assert.Throws(typeof(Exceptions.NoPossibleElements),
                          delegate { wordGenerator.GetNextWord(w => w == "DoestNotExist"); });
        }
示例#18
0
        public void CreandoData()
        {
            var numbers = new Random(-1);
            var fixture = new Fixture();

            fixture.Behaviors.OfType <ThrowingRecursionBehavior>()
            .ToList().ForEach(b => fixture.Behaviors.Remove(b));

            WordGenerator       generator           = new WordGenerator();
            LoremIpsumGenerator loremIpsumGenerator = new LoremIpsumGenerator();

            fixture.Behaviors.Add(new OmitOnRecursionBehavior(1));
            var clientes = fixture.Build <Cliente>()
                           .Without(p => p.Reservas)
                           .With(p => p.Nombre, loremIpsumGenerator.Next(1, 1))
                           .With(p => p.NombreUsuario, generator.Next() + Guid.NewGuid().ToString())
                           .With(p => p.ContactoCargo, generator.Next())
                           .With(p => p.ContactoNombre, generator.Next())
                           //.With(p => p.Direccion, loremIpsumGenerator.Next(1,1))
                           .CreateMany(100);

            var context = new EFVirtualOfficeRepository();


            foreach (var cliente in clientes)
            {
                context.ClienteRepository.Add(cliente);
            }

            context.Commit();
        }
示例#19
0
        public static Comment GetRandomSentence()
        {
            Random        rand      = new Random();
            WordGenerator generator = new WordGenerator();
            StringBuilder sb        = new StringBuilder();

            for (int i = 0; i < rand.Next(5, 20); i++)
            {
                sb.Append(generator.Next());
                sb.Append(" ");
                if (rand.Next(0, 5) == 0)
                {
                    sb.Append("the ");
                }
                if (rand.Next(0, 6) == 0)
                {
                    sb.Append("a ");
                }
            }
            Comment newComment = new Comment();

            newComment.Text                 = sb.ToString();
            newComment.TimeStamp            = DateTime.Now;
            newComment.LengthOfConversation = rand.Next(500, 1500) * newComment.Text.Split(' ').Length;
            newComment.User                 = users[rand.Next(0, users.Length - 1)];
            return(newComment);
        }
示例#20
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         Debug.Log(WordGenerator.GenarateName());
     }
 }
示例#21
0
        /// <summary>
        /// Creates a random Employee array
        /// </summary>
        /// <returns>An employee array</returns>
        public static Employee[] CreateEmployees(int numEmployees = 100)
        {
            string[] names    = { "María", "Juan", "Pepe", "Luis", "Carlos", "Miguel", "Cristina" };
            string[] surnames = { "Díaz", "Pérez", "Hevia", "García", "Rodríguez", "Pérez", "Sánchez" };

            Employee[] listing = new Employee[numEmployees];
            Random     random  = new Random();

            for (int i = 0; i < numEmployees; i++)
            {
                listing[i] = new Employee
                {
                    Name          = names[random.Next(0, names.Length)],
                    FirstSurname  = surnames[random.Next(0, surnames.Length)],
                    SecondSurname = surnames[random.Next(0, surnames.Length)],
                    NIF           = random.Next(9000000, 90000000) + "-" + (char)random.Next('A', 'Z'),
                    NumberOfHours = i % 2 == 0 ? ContractType.Full : ContractType.Partial,
                    ID            = i,
                    BirthDate     = RandomDate(),
                    Comments      = WordGenerator.GenerateRandomText()
                }
            }
            ;

            return(listing);
        }
    }
示例#22
0
        public async Task When_Available_Breadth_Changes()
        {
            var template    = (DataTemplate)_testsResources["When_Available_Breadth_Changes_Template"];
            var itemsSource = Enumerable.Range(0, 15).Select(_ => WordGenerator.GetRandomWordSequence(17, new Random(6754))).ToArray();
            var SUT         = new ListView
            {
                ItemTemplate       = template,
                ItemContainerStyle = NoSpaceContainerStyle,
                ItemsSource        = itemsSource,
                MaxHeight          = 500
            };

            var hostGrid = new Grid
            {
                Width    = 196,
                Children =
                {
                    SUT
                }
            };

            WindowHelper.WindowContent = hostGrid;
            await WindowHelper.WaitForLoaded(SUT);

            var container = SUT.ContainerFromIndex(2) as ListViewItem;

            var border = container.FindFirstChild <Border>(b => b.Name == "ContainerBorder");

            Assert.AreEqual(196, border.ActualWidth, delta: 1);

            hostGrid.Width = 244;
            await WindowHelper.WaitForEqual(244, () => border.ActualWidth);
        }
示例#23
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            MainActivity._instance = this;
            _Random = new Random(
#if DEBUG
                //                    1
#endif
                );
            try
            {
                CreateLayout();
            }
            catch (Exception ex)
            {
                SetContentView(Resource.Layout.content_main);
                var layout = FindViewById <RelativeLayout>(Resource.Id.container);
                var textv  = new TextView(this)
                {
                    Text = ex.ToString()
                };
                layout.AddView(textv);

                return;
            }
            _wordGen = new WordGenerator(_Random);
            BtnNew_Click(_btnNew, null);
            //Android.Support.V7.Widget.Toolbar toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            //SetSupportActionBar(toolbar);

            //FloatingActionButton fab = FindViewById<FloatingActionButton>(Resource.Id.fab);
            //fab.Click += FabOnClick;
        }
    public void AddWord()
    {
        Word word = new Word(WordGenerator.GetRandomWord(), wordSpawner.SpawnWord());

        words.Add(word);
        //Debug.Log("MY DEBUG LINE 1: " + word.word); // The letters of the word that just spawned
        //Debug.Log("MY DEBUG LINE 2: " + word.damage); //The damage of the word that just spawned
    }
示例#25
0
    public void AddWord()
    {
        palabras = WordGenerator.GetRandomWord().Split('.');

        Word word = new Word(palabras[0], palabras[1], wordSpawner.SpawnWord());

        words.Add(word);
    }
示例#26
0
    public void AddWord()
    {
        Word word = new Word(WordGenerator.ReadWords(), wordSpawner.SpawnWord());

        Debug.Log(word.word);

        words.Add(word);
    }
    /// <summary>
    /// Generates a email address based on a number of words
    /// </summary>
    /// <param name="numberOfWords"></param>
    /// <param name="separator"></param>
    /// <returns></returns>
    public static string GenerateEmailAddressWithWords(int numberOfWords = 3, string separator = ".")
    {
        string userName   = string.Join(separator, WordGenerator.GenerateWords(numberOfWords));
        string domainName = WordGenerator.GenerateWord(4, 9);
        string domain     = StringGenerator.GetAlphabeticLower(2, 5);

        return(GetEmailAddress(userName, domainName, domain));
    }
示例#28
0
    public void AddWord()
    {
        Word word = new Word(WordGenerator.GetWord(), wordSpawner.SpawnWord());

        words.Add(word);
        Debug.Log(word.word);
        Counter++;
    }
示例#29
0
        public void GenerateWordsWithoutDoubledLetters_WordContainNoOccurences_ReturnsEmpty()
        {
            var generator = new WordGenerator(null);

            var result = generator.GenerateWordsWithoutDoubledLetters("cat");

            result.Should().BeEmpty();
        }
示例#30
0
 public SelectWordConsumer(ILogger <SelectWordConsumer> logger,
                           IOptions <RabbitMQConfiguration> rmqOption,
                           WordGenerator wordGenerator)
 {
     rmqConfig          = rmqOption.Value;
     this.logger        = logger;
     this.wordGenerator = wordGenerator;
 }
示例#31
0
 public FileContentResult GenerateWordDocument()
 {
     //It's a sample, so no DI just the bits to let it works
       var values = new Dictionary<string, string>
              {
                {"Title", "Foo title"},
                {"Cell1", "123"},
                {"Cell2", "asd"},
                {"Header", "my header"},
                {"Footer", "my footer"}
              };
       IDocumentGenerator genereator = new WordGenerator();
       var result = genereator.GenerateDocument(values, Server.MapPath("~/Content/Files/WordTest.docx"));
       return File(result, ("application/vnd.openxmlformats-officedocument.wordprocessingml.document"), "WordTest.docx");
 }