Example #1
0
        /// <summary>
        /// Fill field with random tokens without solutions
        /// </summary>
        public void InitField()
        {
            rnd = new Random(Seed);

            for (int x = 0; x < sizeL; x++)
            {
                for (int y = 0; y < sizeH; y++)
                {
                    Data[x, y] = new GameToken(rnd.Next(1, TheGame.maxIndex));
                }
            }
            TotalTokens = sizeH * sizeL;
            Fill(true);
        }
Example #2
0
        /// <summary>
        /// Fill holes on a field with random tokens
        /// </summary>
        /// <param name="nolines">ensure filled tokens never result a ready solution</param>
        public void Fill(bool nolines = false)
        {
            TokenEventArgs ea = new TokenEventArgs();

            bool loop = false;

            do
            {
                loop = false;
                for (int x = 0; x < sizeL; x++)
                {
                    for (int y = 0; y < sizeH; y++)
                    {
                        if (InRange(x, y))
                        {
                            if (!Data[x, y].Alive)
                            {
                                //GameToken t = ;
                                Data[x, y] = new GameToken(NextSeed);
                                ea.Tokens.Add(new GameTokenData(x, y, Data[x, y]));
                                TotalTokens++;
                            }
                        }
                    }
                }

                while (nolines && GetLines())
                {
                    Slide();
                    loop = true;
                }
            } while (loop);
            if (ea.Tokens.Count > 0)
            {
                OnTokensAdded(ea);
            }
        }
Example #3
0
 private void AddToken(int x, int y, TokenEventArgs ea)
 {
     Data[x, y] = new GameToken(NextSeed);
     ea.Tokens.Add(new GameTokenData(x, y, Data[x, y]));
     TotalTokens++;
 }