示例#1
0
    private static void FindBismAllahEqualsAlFatihaIndex(Client client, string extra)
    {
        if (client == null) return;
        if (client.Book == null) return;
        if (client.NumerologySystem == null) return;

        NumerologySystem backup_numerology_system = new NumerologySystem(client.NumerologySystem);

        long target_difference;
        try
        {
            target_difference = long.Parse(extra);
        }
        catch
        {
            target_difference = 0L;
        }

        // zero difference between Value(BismAllah) and ValueIndex(Al-Fatiha)
        List<ZeroDifferenceNumerologySystem> good_numerology_systems = new List<ZeroDifferenceNumerologySystem>();

        NumberType[] number_types = (NumberType[])Enum.GetValues(typeof(NumberType));
        foreach (NumberType number_type in number_types)
        {
            if (
                (number_type == NumberType.Prime) ||
                (number_type == NumberType.AdditivePrime) ||
                (number_type == NumberType.PurePrime) ||
                (number_type == NumberType.Composite) ||
                (number_type == NumberType.AdditiveComposite) ||
                (number_type == NumberType.PureComposite)
               )
            {
                NumerologySystemScope[] numerology_system_scopes = (NumerologySystemScope[])Enum.GetValues(typeof(NumerologySystemScope));
                foreach (NumerologySystemScope numerology_system_scope in numerology_system_scopes)
                {
                    switch (numerology_system_scope)
                    {
                        case NumerologySystemScope.Book:
                            {
                                client.BuildNumerologySystem(client.Book.Text);
                            }
                            break;
                        case NumerologySystemScope.Selection:
                            {
                                client.BuildNumerologySystem(client.Book.Chapters[0].Text);
                            }
                            break;
                        case NumerologySystemScope.HighlightedText:
                            {
                                client.BuildNumerologySystem(client.Book.Verses[0].Text);
                            }
                            break;
                        default:
                            break;
                    }

                    // Quran 74:30 "Over It Nineteen."
                    int PERMUTATIONS = 524288; // 2^19
                    for (int i = 0; i < PERMUTATIONS; i++)
                    {
                        client.NumerologySystem.AddToLetterLNumber = ((i & 262144) != 0);
                        client.NumerologySystem.AddToLetterWNumber = ((i & 131072) != 0);
                        client.NumerologySystem.AddToLetterVNumber = ((i & 65536) != 0);
                        client.NumerologySystem.AddToLetterCNumber = ((i & 32768) != 0);
                        client.NumerologySystem.AddToLetterLDistance = ((i & 16384) != 0);
                        client.NumerologySystem.AddToLetterWDistance = ((i & 8192) != 0);
                        client.NumerologySystem.AddToLetterVDistance = ((i & 4096) != 0);
                        client.NumerologySystem.AddToLetterCDistance = ((i & 2048) != 0);
                        client.NumerologySystem.AddToWordWNumber = ((i & 1024) != 0);
                        client.NumerologySystem.AddToWordVNumber = ((i & 512) != 0);
                        client.NumerologySystem.AddToWordCNumber = ((i & 256) != 0);
                        client.NumerologySystem.AddToWordWDistance = ((i & 128) != 0);
                        client.NumerologySystem.AddToWordVDistance = ((i & 64) != 0);
                        client.NumerologySystem.AddToWordCDistance = ((i & 32) != 0);
                        client.NumerologySystem.AddToVerseVNumber = ((i & 16) != 0);
                        client.NumerologySystem.AddToVerseCNumber = ((i & 8) != 0);
                        client.NumerologySystem.AddToVerseVDistance = ((i & 4) != 0);
                        client.NumerologySystem.AddToVerseCDistance = ((i & 2) != 0);
                        client.NumerologySystem.AddToChapterCNumber = ((i & 1) != 0);

                        long alfatiha_value = client.CalculateValue(client.Book.Chapters[0]);
                        int alfatiha_value_index = -1;
                        switch (number_type)
                        {
                            case NumberType.Prime:
                                {
                                    alfatiha_value_index = Numbers.IndexOfPrime(alfatiha_value);
                                }
                                break;
                            case NumberType.AdditivePrime:
                                {
                                    alfatiha_value_index = Numbers.IndexOfAdditivePrime(alfatiha_value);
                                }
                                break;
                            case NumberType.PurePrime:
                                {
                                    alfatiha_value_index = Numbers.IndexOfPurePrime(alfatiha_value);
                                }
                                break;
                            case NumberType.Composite:
                                {
                                    alfatiha_value_index = Numbers.IndexOfComposite(alfatiha_value);
                                }
                                break;
                            case NumberType.AdditiveComposite:
                                {
                                    alfatiha_value_index = Numbers.IndexOfAdditiveComposite(alfatiha_value);
                                }
                                break;
                            case NumberType.PureComposite:
                                {
                                    alfatiha_value_index = Numbers.IndexOfPureComposite(alfatiha_value);
                                }
                                break;
                            default:
                                break;
                        }

                        if (alfatiha_value_index != -1)
                        {
                            long bismAllah_value = client.CalculateValue(client.Book.Chapters[0].Verses[0]);

                            long difference = bismAllah_value - (long)alfatiha_value_index;
                            if (Math.Abs(difference) <= target_difference)
                            {
                                ZeroDifferenceNumerologySystem good_numerology_system = new ZeroDifferenceNumerologySystem();
                                good_numerology_system.NumerologySystem = new NumerologySystem(client.NumerologySystem);
                                good_numerology_system.NumberType = number_type;
                                good_numerology_system.BismAllahValue = bismAllah_value;
                                good_numerology_system.AlFatihaValue = alfatiha_value;
                                good_numerology_system.AlFatihaValueIndex = alfatiha_value_index;
                                good_numerology_systems.Add(good_numerology_system);
                            }
                        }

                    } // next PERMUTATION

                } // next NumerologySystemScope

                string filename = "FindBismAllahEqualsAlFatiha" + number_type.ToString() + "IndexSystem" + Globals.OUTPUT_FILE_EXT;
                string path = Globals.RESEARCH_FOLDER + "/" + filename;

                StringBuilder str = new StringBuilder();
                str.AppendLine("TextMode" +
                        "\t" + "LetterOrder" +
                        "\t" + "LetterValues" +
                        "\t" + "Scope" +
                        "\t" + "AddToLetterLNumber" +
                        "\t" + "AddToLetterWNumber" +
                        "\t" + "AddToLetterVNumber" +
                        "\t" + "AddToLetterCNumber" +
                        "\t" + "AddToLetterLDistance" +
                        "\t" + "AddToLetterWDistance" +
                        "\t" + "AddToLetterVDistance" +
                        "\t" + "AddToLetterCDistance" +
                        "\t" + "AddToWordWNumber" +
                        "\t" + "AddToWordVNumber" +
                        "\t" + "AddToWordCNumber" +
                        "\t" + "AddToWordWDistance" +
                        "\t" + "AddToWordVDistance" +
                        "\t" + "AddToWordCDistance" +
                        "\t" + "AddToVerseVNumber" +
                        "\t" + "AddToVerseCNumber" +
                        "\t" + "AddToVerseVDistance" +
                        "\t" + "AddToVerseCDistance" +
                        "\t" + "AddToChapterCNumber" +
                        "\t" + "BismAllahValue" +
                        "\t" + "AlFatihaIndex"
                    );
                foreach (ZeroDifferenceNumerologySystem good_numerology_system in good_numerology_systems)
                {
                    str.Append(good_numerology_system.NumerologySystem.ToTabbedString());
                    str.Append("\t" + good_numerology_system.BismAllahValue.ToString());
                    str.Append("\t" + good_numerology_system.AlFatihaValueIndex.ToString());
                    str.AppendLine();
                }
                PublicStorage.SaveText(path, str.ToString());
                PublicStorage.DisplayFile(path);

                // clear for next NumberType
                good_numerology_systems.Clear();

            } // if NumberType

        } // next NumberType

        client.NumerologySystem = backup_numerology_system;
    }