Example #1
0
        public void CreateRandomBlow()
        {
            Random rand = new Random();

            int bellabs = rand.Next(1, 14);

            if (bellabs == 1)
            {
                Bell = "1";
            }
            else if (bellabs == 2)
            {
                Bell = "2s";
            }
            else
            {
                Bell = BellConv.BellStr(bellabs - 1);
            }

            ChangeStr     = string.Empty;
            IsTestBell    = true;
            IsHighlighted = false;

            BellActual   = Bell;
            RowNum       = 1;
            Place        = 1;
            IsHandstroke = false;
            BellSound    = "/audio/tws" + BellActual + ".mp3";
            AudioId      = "audio1";
        }
Example #2
0
        public void CreateRandomChange()
        {
            Random rand = new Random();

            int i = 1;
            int j;

            do
            {
                if (i == Stage)
                {
                    ChangeArr[i] = i;
                    i           += 1;
                }
                else
                {
                    // i is less than Stage
                    j = rand.Next(0, Stage / 2);

                    if (j == 0)
                    {
                        // Make a place at i
                        ChangeArr[i] = i;
                        i           += 1;
                    }
                    else
                    {
                        // Cross at i and i+1
                        ChangeArr[i]     = i + 1;
                        ChangeArr[i + 1] = i;
                        i += 2;
                    }
                }
            }while (i <= Stage);

            // Create a string with the change
            ChangeStr = string.Empty;

            for (i = 1; i <= Stage; i++)
            {
                if (ChangeArr[i] == i)
                {
                    ChangeStr += BellConv.BellStr(i);
                }
            }

            if (ChangeStr == string.Empty)
            {
                ChangeStr = "x";
            }

            // If Stage is odd, add a place to the Change array for the tenor behind
            if (Stage < NumBells)
            {
                ChangeArr[NumBells] = NumBells;
            }
        }
Example #3
0
        public void CreateRandomRow()
        {
            // Initialize rounds for the stage
            int[] rounds = new int[Stage + 1];

            // Put numbers 1 - stage in an array with the same indices
            for (int i = 1; i <= Stage; i++)
            {
                rounds[i] = i;
            }

            int    place = 1;
            Random rand  = new Random();

            for (int i = Stage; i >= 2; i--)
            {
                // Pick a random number from 1 to i
                int j = rand.Next(1, i + 1);

                // Put that bell into the row array
                RowArr[place] = BellConv.BellStr(rounds[j]);

                // Move the bells with higher indices down one position
                for (int k = j + 1; k <= i; k++)
                {
                    rounds[k - 1] = rounds[k];
                }

                // Delete the bell in ith's place
                rounds[i] = 0;

                // Increment rowPos
                place++;
            }

            // Put last remaining bell into row
            RowArr[place] = BellConv.BellStr(rounds[1]);

            // Populate RowStr
            RowStr = string.Empty;

            for (int i = 1; i <= Stage; i++)
            {
                RowStr += RowArr[i];
            }

            // If Stage is odd, add a bell to the RowArr array for the tenor behind
            if (Stage < NumBells)
            {
                RowArr[NumBells] = BellConv.BellStr(NumBells);
            }
        }
        public static string DeriveBellActual(int stage, int tenorWeight, string bell)
        {
            string bellActual;

            int bellnum = BellConv.BellInt(bell);

            switch (stage)
            {
            case 5:
            case 6:
                bellActual = BellConv.BellStr(bellnum + 2);
                break;

            case 7:
            case 8:
                if (tenorWeight == 23)
                {
                    bellActual = BellConv.BellStr(bellnum + 4);
                }
                else
                {
                    if (bellnum == 2)
                    {
                        bellActual = "2s";
                    }
                    else
                    {
                        bellActual = BellConv.BellStr(bellnum);
                    }
                }
                break;

            case 9:
            case 10:
                bellActual = BellConv.BellStr(bellnum + 2);
                break;

            case 11:
            case 12:
                bellActual = BellConv.BellStr(bellnum);
                break;

            default:
                bellActual = BellConv.BellStr(bellnum);
                break;
            }

            return(bellActual);
        }
Example #5
0
        public void CalculateRow(Row prevRow)
        {
            for (int i = 1; i <= Stage; i++)
            {
                RowArr[i] = prevRow.RowArr[ChangeArr[i]];
            }

            // Populate RowStr
            RowStr = string.Empty;

            for (int i = 1; i <= Stage; i++)
            {
                RowStr += RowArr[i];
            }

            // If Stage is odd, add a bell to the RowArr array for the tenor behind
            if (Stage < NumBells)
            {
                RowArr[NumBells] = BellConv.BellStr(NumBells);
            }
        }