Thread: srand slows down my program to a crawl

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    308

    srand slows down my program to a crawl

    Here is my program:

    Code:
    #include <cstdlib>
    #include <ctime>
    #include <iostream>
    #include <windows.h> // WinApi header
    #include <cstdio>
    #include <string>
    #include <time.h>
    #include <fstream>
    
    using namespace std;
    
    int findSmallestRemainingElement (int array[], int size, int index);
    void swap (int array[], int first_index, int second_index);
    
    void sort (int array[], int size)
    {
        for ( int i = 0; i < size; i++ )
        {
            int index = findSmallestRemainingElement( array, size, i );
            swap( array, i, index );
        }
    }
    
    int findSmallestRemainingElement (int array[], int size, int index)
    {
        int index_of_smallest_value = index;
        for (int i = index + 1; i < size; i++)
        {
            if ( array[ i ] < array[ index_of_smallest_value ] )
            {
                index_of_smallest_value = i;
            }
        }
        return index_of_smallest_value;
    }
    
    void swap (int array[], int first_index, int second_index)
    {
        int temp = array[ first_index ];
        array[ first_index ] = array[ second_index ];
        array[ second_index ] = temp;
    }
    
    // small helper method to display the before and after arrays
    void displayArray (int array[], int size)
    {
        cout << "{";
        for ( int i = 0; i < size; i++ )
        {
            // you'll see this pattern a lot for nicely formatting
            // lists--check if we're past the first element, and
            // if so, append a comma
            if ( i != 0 )
            {
                cout << ", ";
            }
            cout << array[ i ];
        }
        cout << "}";
    }
    
    void set_array_value_to_zero ( int array[] )
    {
        for ( int i = 0; i < 9; i++ )
        {
            array[ i ] = 0;
        }
    }
    
    void set_one_string_array_equal_to_another_string_array ( string array[], string array2[] )
    {
        for ( int i = 0; i < 4; i++ )
        {
            array[ i ] = array2[ i ];
        }
    }
    
    void set_one_int_array_equal_to_another_int_array ( int array[], int array2[] )
    {
        for ( int i = 0; i < 9; i++ )
        {
            array[ i ] = array2[ i ];
        }
    }
    
    void newSwitch (int array[], int size, int subtracting_this_many_array_elements, int *high, int *medium, int *low)
    {
        for ( int i = size; i-- > subtracting_this_many_array_elements; )
        {
    
            switch(array[i])
            {
                case 8:
                case 7:
                case 6:
                    //cout << "Input: " << i << " too high\n";
                    *high += 1;
                    break;
                case 5:
                case 4:
                case 3:
                    //cout << "Input: " << i << " might be good\n";
                    *medium += 1;
                    break;
                case 2:
                case 1:
                case 0:
                    //cout << "Input: " << i << " is good\n";
                    *low += 1;
                    break;
            }
        }
    }
    
    int which_value_is_largest (int high, int medium, int low)
    {
        int value = 0;
    
        if ( high > medium && high > low && medium > low )
        {
            value = 13;
        }
    
        else if ( high > medium && high > low && medium == low )
        {
            value = 12;
        }
    
        else if ( high > medium && high > low && low > medium )
        {
            value = 11;
        }
    
        else if ( medium > high && medium > low && high > low )
        {
            value = 10;
        }
    
        else if ( medium > high && medium > low && high == low )
        {
            value = 9;
        }
    
        else if ( medium > high && medium > low && low > high )
        {
            value = 8;
        }
    
        else if ( low > medium && low > high && high > medium )
        {
            value = 7;
        }
    
        else if ( low > medium && low > high && high == medium )
        {
            value = 6;
        }
    
        else if ( low > medium && low > high && medium > high )
        {
            value = 5;
        }
    
        else if ( medium == low && high < medium )
        {
            value = 4;
        }
        else if ( high == low && medium < high )
        {
            value = 3;
        }
        else if ( high == medium && low < medium )
        {
            value = 2;
        }
        else
        {
            value = 1;
        }
    
        return value;
    }
    
    int side (int array[], int size, int subtracting_this_many_array_elements)
    {
        int too_high = 0;
        int might_be_good = 0;
        int good_stuff = 0;
    
        int value = 0;
    
        //cout << "____________________________________\n";
    
        //cout << "Original array: ";
        //displayArray( array, size );
        //cout << '\n';
    
        sort( array, size );
    
        //cout << "Sorted array: ";
        //displayArray( array, size );
       // cout << '\n';
        //cout << '\n';
    
        newSwitch( array, size, subtracting_this_many_array_elements, &too_high, &might_be_good, &good_stuff );
    
        //cout << '\n';
    
        //cout << "high counter = " << too_high << '\n';
        //cout << "medium counter = " << might_be_good << '\n';
        //cout << "low counter = " << good_stuff << '\n';
    
        //cout << '\n';
    
        value = which_value_is_largest (too_high, might_be_good, good_stuff);
        //interpreting_whichValueIsLargest(value);
    
        //cout << '\n';
    
        return value;
    }
    
    void randomizing_array_elements ( int array[], int size)
    {
        srand( time( NULL ) );
    
        for ( int i = 0; i < size; i++ )
        {
            // keep the numbers small so they're easy to read
            array[ i ] = rand() % 9;
        }
    }
    
    int  do_this_if_left_or_right_is_greater(int array[], string left_or_right[], int *I_took_a_step, int left_side, int right_side, int subtracting_this_many_array_elements, int which_string_element)
    {
        int value = 0;
        //cout << "____________________________________\n";
    
        //cout << "Left side value is: " << left_side << '\n';
        //cout << "Right side value is: " << right_side << '\n';
        //cout << '\n';
    
        if ( left_side > right_side )
        {
            for ( int i = 0; i < 8; i++ )
            {
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
    
                subtracting_this_many_array_elements++;
                left_side = side( array, 9, subtracting_this_many_array_elements );
                //cout << "Left side value is: " << left_side << '\n';
    
                if (left_side <= 3)
                {
                    //cout << "____________________________________\n";
    
                    //cout << "Took a step\n";
                    value = 1;
                    *I_took_a_step += 1;
                    Beep(1568, 500);
    
                    break;
                }
                else
                {
                    value = 0;
                }
                //cout << '\n';
            }
            left_or_right [ which_string_element ] = "left";
        }
        else if ( right_side > left_side )
        {
            for ( int i = 0; i < 8; i++ )
            {
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
    
                subtracting_this_many_array_elements++;
                right_side = side( array, 9, subtracting_this_many_array_elements );
                //cout << "Right side value is: " << right_side << '\n';
    
                if (right_side <= 3)
                {
                    //cout << "____________________________________\n";
                    //cout << "Took a step\n";
                    value = 1;
                    *I_took_a_step += 1;
                    Beep(523,500); // 523 hertz (C5) for 500 milliseconds
                    break;
                }
                else
                {
                    value = 0;
                }
    
                //cout << '\n';
            }
            left_or_right [ which_string_element ] = "right";
        }
    
        return value;
    }
    
    int testing_four_directions(int counter[], string left_or_right[], int which_string_element)
    {
        int array[ 9 ];
    
        int I_took_a_step = 0;
    
        int subtracting_this_many_array_elements = 0;
    
        for ( int i = 0; i < 9; i++ )
        {
            set_array_value_to_zero( array );
    
            randomizing_array_elements(array, 9);
            int left_side = side( array, 9 , subtracting_this_many_array_elements);
    
            set_array_value_to_zero( array );
    
            randomizing_array_elements(array, 9);
            int right_side = side( array, 9, subtracting_this_many_array_elements );
    
            while ( left_side == right_side )
            {
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
                left_side = side( array, 9 , subtracting_this_many_array_elements);
    
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
                right_side = side( array, 9, subtracting_this_many_array_elements );
            }
    
            int step_counter = do_this_if_left_or_right_is_greater(array, left_or_right, &I_took_a_step, left_side, right_side, subtracting_this_many_array_elements, which_string_element);
            counter[ i ] = step_counter;
        }
        return I_took_a_step;
    }
    
    
    int which_direction_is_lowest(string lowest_value_feeler[], int north, int south, int east, int west, int feeler, int element)
    {
        int direction_value = 0;
        if ( north < south && north < east && north < west )
        {
            lowest_value_feeler[ element ] = "north";
            direction_value = 1;
        }
        else if ( south < north && south < east && south < west )
        {
            lowest_value_feeler[ element ] = "south";
            direction_value = 2;
        }
        else if ( east < north && east < south && east < west )
        {
            lowest_value_feeler[ element ] = "east";
            direction_value = 3;
        }
        else if ( west < north && west < south && west < east )
        {
            lowest_value_feeler[ element ] = "west";
            direction_value = 4;
        }
        else if ( north == south && north == east && north == west )
        {
            lowest_value_feeler[ element ] = "no_lowest_direction.";
            direction_value = 5;
        }
        else if ( north == east && north == south )
        {
            lowest_value_feeler[ element ] = "north_east_south.";
            direction_value = 6;
        }
        else if ( east == south && east == west )
        {
            lowest_value_feeler[ element ] = "east_south_west.";
            direction_value = 7;
        }
        else if ( south == west && south == north )
        {
            lowest_value_feeler[ element ] = "south_west_north.";
            direction_value = 8;
        }
        else if ( west == north && west == east )
        {
            lowest_value_feeler[ element ] = "west_north_east.";
            direction_value = 9;
        }
        else if ( north == east )
        {
            lowest_value_feeler[ element ] = "north_east.";
            direction_value = 10;
        }
        else if ( east == south )
        {
            lowest_value_feeler[ element ] = "east_south.";
            direction_value = 11;
        }
        else if ( south == west )
        {
            lowest_value_feeler[ element ] = "south_west.";
            direction_value = 12;
        }
        else if ( west == north )
        {
            lowest_value_feeler[ element ] = "west_north.";
            direction_value = 13;
        }
        else if ( west == east )
        {
            lowest_value_feeler[ element ] = "west_east.";
            direction_value = 14;
        }
        else if ( north == south )
        {
            lowest_value_feeler[ element ] = "north_south.";
            direction_value = 15;
        }
        else if ( north == east && north > south && north > west )
        {
            lowest_value_feeler[ element ] = "north_east";
            direction_value = 16;
        }
    
        else if ( north == west && north > east && north > south )
        {
            lowest_value_feeler[ element ] = "north_west";
            direction_value = 17;
        }
        else if ( north == south && north > east && north > west )
        {
            lowest_value_feeler[ element ] = "north_south";
            direction_value = 18;
        }
        else if ( east == west && east > north && east > south )
        {
            lowest_value_feeler[ element ] = "east_west";
            direction_value = 19;
        }
        else if ( east == south && east > north && east > west )
        {
            lowest_value_feeler[ element ] = "east_south";
            direction_value = 20;
        }
        else if ( west == south && west > north && west > east )
        {
            lowest_value_feeler[ element ] = "west_south";
            direction_value = 21;
        }
    
        return direction_value;
    }
    
    void displaying_which_direction_is_lowest( int lowest_value_array[], int direction_value, int feeler )
    {
    
        if ( direction_value == 1 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 2 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 3 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 4 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 5 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south, east, west direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south, east, west direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 6 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east, south direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east, south direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 7 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south, west direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south, west direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 8 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south, west, north direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south, west, north direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 9 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, north, east direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, north, east direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 10 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 11 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 12 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south, west direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south, west direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 13 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, north direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, north direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 14 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, east direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, east direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 15 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 16 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 17 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, west direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, west direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 18 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 19 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, west direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, west direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 20 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 21 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, south direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, south direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
    }
    
    void direction_value_array_transfer_value_to_new_array (int lowest_value_array[],
                                                           string *lowest_value_array_direction,
                                                                      int north[],
                                                                      int south[],
                                                                      int east[],
                                                                      int west[],
                                                                      int *direction_value)
    {
    
        switch( *direction_value )
        {
            case 1:
            case 5:
            case 6:
            case 10:
            case 17:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, north );
                *lowest_value_array_direction = "north";
                break;
    
            case 2:
            case 8:
            case 12:
            case 15:
            case 18:
            case 20:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, south );
                *lowest_value_array_direction = "south";
                break;
    
            case 3:
            case 7:
            case 11:
            case 16:
            case 19:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, east );
                *lowest_value_array_direction = "east";
                break;
    
            case 4:
            case 9:
            case 13:
            case 14:
            case 21:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, west );
                *lowest_value_array_direction = "west";
                break;
        }
    }
    
    void display_number_of_steps_message(int north, int south, int east, int west, int which_feeler)
    {
        cout << "Values with feeler "<< which_feeler << "\n";
        cout << "I tried to take 9 steps in the north direction, but I actual took " << north << " steps.\n";
        cout << "I tried to take 9 steps in the south direction, but I actual took " << south << " steps.\n";
        cout << "I tried to take 9 steps in the east direction, but I actual took " << east << " steps.\n";
        cout << "I tried to take 9 steps in the west direction, but I actual took " << west << " steps.\n";
    
        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
        if( file.fail() )
        {
            cout << "error while opening the file in the display_number_of_steps_message function" << endl;
        }
        else
        {
            file << endl;
            file << "Values with feeler "<< which_feeler << "\n";
            file << "I tried to take 9 steps in the north direction, but I actual took " << north << " steps.\n";
            file << "I tried to take 9 steps in the south direction, but I actual took " << south << " steps.\n";
            file << "I tried to take 9 steps in the east direction, but I actual took " << east << " steps.\n";
            file << "I tried to take 9 steps in the west direction, but I actual took " << west << " steps.\n";
            file << endl;
        }
    
        file.close();
    }
    
    void used_in_setting_feeler_to_new_value ( string left_or_right[],
                                               string lowest_value_feeler[],
                                               int lowest_value_array[],
                                               int north_array[],
                                               int south_array[],
                                               int east_array[],
                                               int west_array[],
                                               string *lowest_value_array_direction,
                                               int *north_count,
                                               int *south_count,
                                               int *east_count,
                                               int *west_count,
                                               int *left_or_right_1,
                                               int *left_or_right_2,
                                               int *left_or_right_3,
                                               int *left_or_right_4,
                                               int *feeler,
                                               int *element )
    {
        int direction_value = 0;
    
        set_array_value_to_zero( north_array );
    
        set_array_value_to_zero( south_array );
    
        set_array_value_to_zero( east_array );
    
        set_array_value_to_zero( west_array );
        set_array_value_to_zero( lowest_value_array );
    
        left_or_right[ *left_or_right_1 ] = "";
        left_or_right[ *left_or_right_2 ] = "";
        left_or_right[ *left_or_right_3 ] = "";
        left_or_right[ *left_or_right_4 ] = "";
    
        *north_count = testing_four_directions(north_array, left_or_right, *left_or_right_1);
        *south_count = testing_four_directions(south_array, left_or_right, *left_or_right_2);
        *east_count = testing_four_directions(east_array, left_or_right, *left_or_right_3);
        *west_count = testing_four_directions(west_array, left_or_right, *left_or_right_4);
        direction_value = which_direction_is_lowest(lowest_value_feeler,
                                                    *north_count,
                                                    *south_count,
                                                    *east_count,
                                                    *west_count,
                                                    *feeler, *element);
    
        direction_value_array_transfer_value_to_new_array ( lowest_value_array,
                                                           lowest_value_array_direction,
                                                            north_array,
                                                            south_array,
                                                            east_array,
                                                            west_array,
                                                            &direction_value);
    
        displaying_which_direction_is_lowest( lowest_value_array, direction_value, *feeler );
    
    
    }
    
    void fourth_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_6[],
                                                              int lowest_value_array_feeler_2_try_6[],
                                                              int north_array_2_try_6_one_and_odd[],
                                                              int south_array_2_try_6_one_and_odd[],
                                                              int east_array_2_try_6_one_and_odd[],
                                                              int west_array_2_try_6_one_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_6_one_and_odd,
                                                              int *south_count_array_2_try_6_one_and_odd,
                                                              int *east_count_array_2_try_6_one_and_odd,
                                                              int *west_count_array_2_try_6_one_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_6,
                                                  lowest_value_array_feeler_2_try_6,
                                                  north_array_2_try_6_one_and_odd,
                                                  south_array_2_try_6_one_and_odd,
                                                  east_array_2_try_6_one_and_odd,
                                                  west_array_2_try_6_one_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_6_one_and_odd,
                                                  south_count_array_2_try_6_one_and_odd,
                                                  east_count_array_2_try_6_one_and_odd,
                                                  west_count_array_2_try_6_one_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_6[ 0 ] == 1)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    
    
    }
    
    void third_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_5[],
                                                              int lowest_value_array_feeler_2_try_5[],
                                                              int north_array_2_try_5_one_and_odd[],
                                                              int south_array_2_try_5_one_and_odd[],
                                                              int east_array_2_try_5_one_and_odd[],
                                                              int west_array_2_try_5_one_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_5_one_and_odd,
                                                              int *south_count_array_2_try_5_one_and_odd,
                                                              int *east_count_array_2_try_5_one_and_odd,
                                                              int *west_count_array_2_try_5_one_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_5,
                                                  lowest_value_array_feeler_2_try_5,
                                                  north_array_2_try_5_one_and_odd,
                                                  south_array_2_try_5_one_and_odd,
                                                  east_array_2_try_5_one_and_odd,
                                                  west_array_2_try_5_one_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_5_one_and_odd,
                                                  south_count_array_2_try_5_one_and_odd,
                                                  east_count_array_2_try_5_one_and_odd,
                                                  west_count_array_2_try_5_one_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_5[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    
    
    }
    
    int setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( string left_or_right[],
                                                               string lowest_value_feeler_2_try_4[],
                                                               int lowest_value_array_feeler_2_try_4[],
                                                               int north_array_2_try_4_zero_and_even[],
                                                               int south_array_2_try_4_zero_and_even[],
                                                               int east_array_2_try_4_zero_and_even[],
                                                               int west_array_2_try_4_zero_and_even[],
                                                               string *feeler_1_lowest_value_array_direction,
                                                               string *feeler_2_lowest_value_array_direction,
                                                               string *did_second_feeler_work,
                                                               int *north_count_array_2_try_4_zero_and_even,
                                                               int *south_count_array_2_try_4_zero_and_even,
                                                               int *east_count_array_2_try_4_zero_and_even,
                                                               int *west_count_array_2_try_4_zero_and_even,
                                                               int *left_or_right_1,
                                                               int *left_or_right_2,
                                                               int *left_or_right_3,
                                                               int *left_or_right_4,
                                                               int *feeler,
                                                               int *element,
                                                               int *the_number_of_loops)
    {
        int counter = 0;
        while ( 1 )
        {
            counter = counter + 1;
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                      lowest_value_feeler_2_try_4,
                                                      lowest_value_array_feeler_2_try_4,
                                                      north_array_2_try_4_zero_and_even,
                                                      south_array_2_try_4_zero_and_even,
                                                      east_array_2_try_4_zero_and_even,
                                                      west_array_2_try_4_zero_and_even,
                                                      feeler_2_lowest_value_array_direction,
                                                      north_count_array_2_try_4_zero_and_even,
                                                      south_count_array_2_try_4_zero_and_even,
                                                      east_count_array_2_try_4_zero_and_even,
                                                      west_count_array_2_try_4_zero_and_even,
                                                      left_or_right_1,
                                                      left_or_right_2,
                                                      left_or_right_3,
                                                      left_or_right_4,
                                                      feeler,
                                                      element );
    
                if ( lowest_value_array_feeler_2_try_4[ 0 ] == 0)
                {
                    if ( *feeler_2_lowest_value_array_direction ==  *feeler_1_lowest_value_array_direction )
                    {
                        *the_number_of_loops += 1;
                        *did_second_feeler_work = "elements_are_equal";
    
                        return counter;
                    }
                }
                else
                {
                   *the_number_of_loops += 1;
                   *did_second_feeler_work = "elements_are_unequal";
                }
        }
    }
    
    void second_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                               string lowest_value_feeler_2_try_3[],
                                                               int lowest_value_array_feeler_2_try_3[],
                                                               int north_array_2_try_3_zero_and_odd[],
                                                               int south_array_2_try_3_zero_and_odd[],
                                                               int east_array_2_try_3_zero_and_odd[],
                                                               int west_array_2_try_3_zero_and_odd[],
                                                               string *feeler_1_lowest_value_array_direction,
                                                               string *feeler_2_lowest_value_array_direction,
                                                               string *did_second_feeler_work,
                                                               int *north_count_array_2_try_3_zero_and_odd,
                                                               int *south_count_array_2_try_3_zero_and_odd,
                                                               int *east_count_array_2_try_3_zero_and_odd,
                                                               int *west_count_array_2_try_3_zero_and_odd,
                                                               int *left_or_right_1,
                                                               int *left_or_right_2,
                                                               int *left_or_right_3,
                                                               int *left_or_right_4,
                                                               int *feeler,
                                                               int *element,
                                                               int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_3,
                                                  lowest_value_array_feeler_2_try_3,
                                                  north_array_2_try_3_zero_and_odd,
                                                  south_array_2_try_3_zero_and_odd,
                                                  east_array_2_try_3_zero_and_odd,
                                                  west_array_2_try_3_zero_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_3_zero_and_odd,
                                                  south_count_array_2_try_3_zero_and_odd,
                                                  east_count_array_2_try_3_zero_and_odd,
                                                  west_count_array_2_try_3_zero_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_3[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
    
            }
        }
    }
    
    void first_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_2[],
                                                              int lowest_value_array_feeler_2_try_2[],
                                                              int north_array_2_try_2_zero_and_odd[],
                                                              int south_array_2_try_2_zero_and_odd[],
                                                              int east_array_2_try_2_zero_and_odd[],
                                                              int west_array_2_try_2_zero_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_2_zero_and_odd,
                                                              int *south_count_array_2_try_2_zero_and_odd,
                                                              int *east_count_array_2_try_2_zero_and_odd,
                                                              int *west_count_array_2_try_2_zero_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    
    
    
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_2,
                                                  lowest_value_array_feeler_2_try_2,
                                                  north_array_2_try_2_zero_and_odd,
                                                  south_array_2_try_2_zero_and_odd,
                                                  east_array_2_try_2_zero_and_odd,
                                                  west_array_2_try_2_zero_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_2_zero_and_odd,
                                                  south_count_array_2_try_2_zero_and_odd,
                                                  east_count_array_2_try_2_zero_and_odd,
                                                  west_count_array_2_try_2_zero_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                   *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    }
    
    void setting_feeler_one_element_zero_to_zero ( string left_or_right[],
                                                      string lowest_value_feeler[],
                                                      int lowest_value_array[],
                                                      int north_array_1_try_2_zero[],
                                                      int south_array_1_try_2_zero[],
                                                      int east_array_1_try_2_zero[],
                                                      int west_array_1_try_2_zero[],
                                                      string *feeler_1_lowest_value_array_direction,
                                                      string *feeler_2_lowest_value_array_direction,
                                                      string *did_second_feeler_work,
                                                      int *north_count_array_1_try_2_zero,
                                                      int *south_count_array_1_try_2_zero,
                                                      int *east_count_array_1_try_2_zero,
                                                      int *west_count_array_1_try_2_zero,
                                                      int *left_or_right_1,
                                                      int *left_or_right_2,
                                                      int *left_or_right_3,
                                                      int *left_or_right_4,
                                                      int *feeler,
                                                      int *element,
                                                      int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler,
                                                  lowest_value_array,
                                                  north_array_1_try_2_zero,
                                                  south_array_1_try_2_zero,
                                                  east_array_1_try_2_zero,
                                                  west_array_1_try_2_zero,
                                                  feeler_1_lowest_value_array_direction,
                                                  north_count_array_1_try_2_zero,
                                                  south_count_array_1_try_2_zero,
                                                  east_count_array_1_try_2_zero,
                                                  west_count_array_1_try_2_zero,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
    
    
            if ( lowest_value_array[ 0 ] == 0 )
            {
                break;
            }
        }
    }
    
    void direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest( string lowest_value_feeler[],
                                                                                                                                             int lowest_value_array[],
                                          int north_array[],
                                          int south_array[],
                                          int east_array[],
                                          int west_array[],
                                          string *lowest_value_array_direction,
                                          int *north_count,
                                          int *south_count,
                                          int *east_count,
                                          int *west_count,
                                          int *feeler,
                                          int *element,
                                          int *direction_value )
    {
    
        *direction_value = which_direction_is_lowest(lowest_value_feeler,
                                                    *north_count,
                                                    *south_count,
                                                    *east_count,
                                                    *west_count,
                                                    *feeler,
                                                    *element);
    
        direction_value_array_transfer_value_to_new_array ( lowest_value_array,
                                                           lowest_value_array_direction,
                                                            north_array,
                                                            south_array,
                                                            east_array,
                                                            west_array,
                                                            direction_value);
    
        displaying_which_direction_is_lowest( lowest_value_array, *direction_value, *feeler );
    
    }
    
    void the_master_function_part_one ( string lowest_value_feeler_1_try_1[],
                                       string lowest_value_feeler_1_try_2[],
                                       string main_left_or_right[],
                                       int main_north_array[],
                                       int main_south_array[],
                                       int main_east_array[],
                                       int main_west_array[],
                                       string *feeler_one_element_zero_equal,
                                       string *feeler_1_lowest_value_array_direction,
                                       int *main_north_count,
                                       int *main_south_count,
                                       int *main_east_count,
                                       int *main_west_count,
                                       int *less_than_node)
    {
        string left_or_right[ 20 ];
        string lowest_value_feeler_2_try_1[ 9 ];
        string lowest_value_feeler_2_try_2[ 9 ];
        string lowest_value_feeler_2_try_3[ 9 ];
        string lowest_value_feeler_2_try_4[ 9 ];
        string lowest_value_feeler_2_try_5[ 9 ];
        string feeler_2_lowest_value_array_direction = "";
        string did_second_feeler_work = "";
        int lowest_value_array_feeler_1_try_1[ 9 ];
        int lowest_value_array_feeler_1_try_2[ 9 ];
        int lowest_value_array_feeler_2_try_1[ 9 ];
        int lowest_value_array_feeler_2_try_2[ 9 ];
        int lowest_value_array_feeler_2_try_4[ 9 ];
        int lowest_value_array_feeler_2_try_5[ 9 ];
        int direction_value = 0;
        int feeler = 0;
        int element = 0;
        int left_or_right_1 = 0;
        int left_or_right_2 = 0;
        int left_or_right_3 = 0;
        int left_or_right_4 = 0;
        int north_array_1[ 9 ];
        int south_array_1[ 9 ];
        int east_array_1[ 9 ];
        int west_array_1[ 9 ];
        int north_array_2[ 9 ];
        int south_array_2[ 9 ];
        int east_array_2[ 9 ];
        int west_array_2[ 9 ];
    
        int north_array_1_try_2_zero[ 9 ];
        int south_array_1_try_2_zero[ 9 ];
        int east_array_1_try_2_zero[ 9 ];
        int west_array_1_try_2_zero[ 9 ];
    
        int north_array_2_try_2_zero_and_odd[ 9 ];
        int south_array_2_try_2_zero_and_odd[ 9 ];
        int east_array_2_try_2_zero_and_odd[ 9 ];
        int west_array_2_try_2_zero_and_odd[ 9 ];
    
        int north_array_2_try_4_zero_and_even[ 9 ];
        int south_array_2_try_4_zero_and_even[ 9 ];
        int east_array_2_try_4_zero_and_even[ 9 ];
        int west_array_2_try_4_zero_and_even[ 9 ];
    
        int north_array_2_try_5_one_and_odd[ 9 ];
        int south_array_2_try_5_one_and_odd[ 9 ];
        int east_array_2_try_5_one_and_odd[ 9 ];
        int west_array_2_try_5_one_and_odd[ 9 ];
    
        int north_count_1 = 0;
        int south_count_1 = 0;
        int east_count_1 = 0;
        int west_count_1 = 0;
        int north_count_2 = 0;
        int south_count_2 = 0;
        int east_count_2 = 0;
        int west_count_2 = 0;
    
        int north_count_array_2_try_2_zero_and_odd = 0;
        int south_count_array_2_try_2_zero_and_odd = 0;
        int east_count_array_2_try_2_zero_and_odd = 0;
        int west_count_array_2_try_2_zero_and_odd = 0;
    
        int north_count_array_2_try_3_zero_and_odd = 0;
        int south_count_array_2_try_3_zero_and_odd = 0;
        int east_count_array_2_try_3_zero_and_odd = 0;
        int west_count_array_2_try_3_zero_and_odd = 0;
    
        int north_count_array_2_try_4_zero_and_even = 0;
        int south_count_array_2_try_4_zero_and_even = 0;
        int east_count_array_2_try_4_zero_and_even = 0;
        int west_count_array_2_try_4_zero_and_even = 0;
    
        int north_count_array_2_try_5_one_and_odd = 0;
        int south_count_array_2_try_5_one_and_odd = 0;
        int east_count_array_2_try_5_one_and_odd = 0;
        int west_count_array_2_try_5_one_and_odd = 0;
    
        int north_count_array_1_try_2_zero = 0;
        int south_count_array_1_try_2_zero = 0;
        int east_count_array_1_try_2_zero = 0;
        int west_count_array_1_try_2_zero = 0;
    
        int the_number_of_loops = 0;
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting step 1
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 1 begin
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        north_count_1 = testing_four_directions(north_array_1, left_or_right, 0);
        south_count_1 = testing_four_directions(south_array_1, left_or_right, 1);
        east_count_1 = testing_four_directions(east_array_1, left_or_right, 2);
        west_count_1 = testing_four_directions(west_array_1, left_or_right, 3);
    
        cout << '\n';
        feeler = 1;
        element = 0;
    
       direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_1_try_1,
        lowest_value_array_feeler_1_try_1,
        north_array_1,
        south_array_1,
        east_array_1,
        west_array_1,
        feeler_1_lowest_value_array_direction,
        &north_count_1,
        &south_count_1,
        &east_count_1,
        &west_count_1,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_1_try_1[ 0 ] == 0 )
        {
            *feeler_one_element_zero_equal = "feeler_one_element_zero_equal_zero";
    
            cout << '\n';
    
            display_number_of_steps_message(north_count_1,
                                            south_count_1,
                                            east_count_1,
                                            west_count_1,
                                            feeler);
    
            cout << "\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in  the the_master_function_part_one function" << endl;
            }
            else
            {
                file << "\n\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n\n";
            }
    
            file.close();
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_1_try_1[ 0 ] == 1 )
        {
            *feeler_one_element_zero_equal = "feeler_one_element_zero_equal_one";
    
            element = 2;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            setting_feeler_one_element_zero_to_zero ( left_or_right,
                                                         lowest_value_feeler_1_try_2,
                                                         lowest_value_array_feeler_1_try_2,
                                                         north_array_1_try_2_zero,
                                                         south_array_1_try_2_zero,
                                                         east_array_1_try_2_zero,
                                                         west_array_1_try_2_zero,
                                                         feeler_1_lowest_value_array_direction,
                                                         &feeler_2_lowest_value_array_direction,
                                                         &did_second_feeler_work,
                                                         &north_count_array_1_try_2_zero,
                                                         &south_count_array_1_try_2_zero,
                                                         &east_count_array_1_try_2_zero,
                                                         &west_count_array_1_try_2_zero,
                                                         &left_or_right_1,
                                                         &left_or_right_2,
                                                         &left_or_right_3,
                                                         &left_or_right_4,
                                                         &feeler,
                                                         &element,
                                                         &the_number_of_loops);
    
                cout << '\n';
    
                display_number_of_steps_message(north_count_array_1_try_2_zero,
                                                south_count_array_1_try_2_zero,
                                                east_count_array_1_try_2_zero,
                                                west_count_array_1_try_2_zero,
                                                feeler);
    
                cout << '\n';
    
                cout << "\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n";
    
                cout << '\n';
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "\n\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n\n";
                }
    
                file.close();
    
        }
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 1 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 2 begin
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        north_count_2 = testing_four_directions(north_array_2, left_or_right, 4);
        south_count_2 = testing_four_directions(south_array_2, left_or_right, 5);
        east_count_2 = testing_four_directions(east_array_2, left_or_right, 6);
        west_count_2 = testing_four_directions(west_array_2, left_or_right, 7);
    
        cout << '\n';
    
        feeler = 2;
        element = 1;
    
        direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_2_try_1,
        lowest_value_array_feeler_2_try_1,
        north_array_2,
        south_array_2,
        east_array_2,
        west_array_2,
        &feeler_2_lowest_value_array_direction,
        &north_count_2,
        &south_count_2,
        &east_count_2,
        &west_count_2,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_2_try_1[ 0 ] == 0 )
        {
    
            cout << '\n';
    
            display_number_of_steps_message(north_count_2,
                                            south_count_2,
                                            east_count_2,
                                            west_count_2,
                                            feeler);
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_2_try_1[ 0 ] == 1 )
        {
            while ( 1 )
            {
                element = 3;
                left_or_right_1 = 12;
                left_or_right_2 = 13;
                left_or_right_3 = 14;
                left_or_right_4 = 15;
                first_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                   lowest_value_feeler_2_try_2,
                                                                   lowest_value_array_feeler_2_try_2,
                                                                   north_array_2_try_2_zero_and_odd,
                                                                   south_array_2_try_2_zero_and_odd,
                                                                   east_array_2_try_2_zero_and_odd,
                                                                   west_array_2_try_2_zero_and_odd,
                                                                   feeler_1_lowest_value_array_direction,
                                                                   &feeler_2_lowest_value_array_direction,
                                                                   &did_second_feeler_work,
                                                                   &north_count_array_2_try_2_zero_and_odd,
                                                                   &south_count_array_2_try_2_zero_and_odd,
                                                                   &east_count_array_2_try_2_zero_and_odd,
                                                                   &west_count_array_2_try_2_zero_and_odd,
                                                                   &left_or_right_1,
                                                                   &left_or_right_2,
                                                                   &left_or_right_3,
                                                                   &left_or_right_4,
                                                                   &feeler,
                                                                   &element,
                                                                   &the_number_of_loops);
                if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
                {
                        break;
    
                }
            }
    
    
                display_number_of_steps_message(north_count_array_2_try_2_zero_and_odd,
                                                south_count_array_2_try_2_zero_and_odd,
                                                east_count_array_2_try_2_zero_and_odd,
                                                west_count_array_2_try_2_zero_and_odd,
                                                feeler);
        }
    
        //////////
    
        cout << '\n';
    
        //results = testing_if_feeler_one_lowest_value_is_same_direction_as_feeler_two_lowest_value ( lowest_value_feeler,
                                                                                          //&did_second_feeler_work,
                                                                                          //&version);
    
    
    
            if ( lowest_value_feeler_1_try_1[ 0 ] == lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_1[ 0 ] != lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_unequal";
    
            }
    
            else if ( lowest_value_feeler_1_try_2[ 0 ] == lowest_value_feeler_2_try_2 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_2[ 0 ] != lowest_value_feeler_2_try_2 [ 0 ] )
            {
               did_second_feeler_work = "elements_are_unequal";
            }
    
        // running the second feeler again if it didn't fix the block problem the first time.
    ////
        if ( did_second_feeler_work == "elements_are_equal" )
        {
            int north_array_2_try_3_zero_and_odd[ 9 ];
            int lowest_value_array_feeler_2_try_3[ 9 ];
            int south_array_2_try_3_zero_and_odd[ 9 ];
            int east_array_2_try_3_zero_and_odd[ 9 ];
            int west_array_2_try_3_zero_and_odd[ 9 ];
    
            feeler = 2;
            element = 4;
            left_or_right_1 = 16;
            left_or_right_2 = 17;
            left_or_right_3 = 18;
            left_or_right_4 = 19;
            second_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_3,
                                                                  lowest_value_array_feeler_2_try_3,
                                                                  north_array_2_try_3_zero_and_odd,
                                                                  south_array_2_try_3_zero_and_odd,
                                                                  east_array_2_try_3_zero_and_odd,
                                                                  west_array_2_try_3_zero_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_3_zero_and_odd,
                                                                  &south_count_array_2_try_3_zero_and_odd,
                                                                  &east_count_array_2_try_3_zero_and_odd,
                                                                  &west_count_array_2_try_3_zero_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            display_number_of_steps_message(north_count_array_2_try_3_zero_and_odd,
                                        south_count_array_2_try_3_zero_and_odd,
                                        east_count_array_2_try_3_zero_and_odd,
                                        west_count_array_2_try_3_zero_and_odd,
                                        feeler);
        }
    
    
        cout << '\n';
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting feeler 2 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << "The second feeler did something to unblock feeler 1\n\n";
        cout << "Step 1 ended = make feeler 1 and 2 unequal - gain control.\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in  the the_master_function_part_one function" << endl;
            }
            else
            {
                file << "The second feeler did something to unblock feeler 1\n\n";
                file << "Step 1 ended = make feeler 1 and 2 unequal - gain control.\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            }
    
            file.close();
        }
    
    ////
    
    // begin test here
    
    
    
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making the unequal equal again
    
    ////
            feeler = 2;
            element = 5;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            *less_than_node = setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_4,
                                                                lowest_value_array_feeler_2_try_4,
                                                                north_array_2_try_4_zero_and_even,
                                                                south_array_2_try_4_zero_and_even,
                                                                east_array_2_try_4_zero_and_even,
                                                                west_array_2_try_4_zero_and_even,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_4_zero_and_even,
                                                                &south_count_array_2_try_4_zero_and_even,
                                                                &east_count_array_2_try_4_zero_and_even,
                                                                &west_count_array_2_try_4_zero_and_even,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_4_zero_and_even,
                                        south_count_array_2_try_4_zero_and_even,
                                        east_count_array_2_try_4_zero_and_even,
                                        west_count_array_2_try_4_zero_and_even,
                                        feeler);
    
            cout << "Step 2 ended = make feeler 1 and 2 equal - lose control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "Step 2 ended = make feeler 1 and 2 equal - lose control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making equal unequal again.
    ////
            feeler = 3;
            element = 6;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            third_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_5,
                                                                lowest_value_array_feeler_2_try_5,
                                                                north_array_2_try_5_one_and_odd,
                                                                south_array_2_try_5_one_and_odd,
                                                                east_array_2_try_5_one_and_odd,
                                                                west_array_2_try_5_one_and_odd,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_5_one_and_odd,
                                                                &south_count_array_2_try_5_one_and_odd,
                                                                &east_count_array_2_try_5_one_and_odd,
                                                                &west_count_array_2_try_5_one_and_odd,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_5_one_and_odd,
                                        south_count_array_2_try_5_one_and_odd,
                                        east_count_array_2_try_5_one_and_odd,
                                        west_count_array_2_try_5_one_and_odd,
                                        feeler);
    
            cout << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    file << endl;
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << '\n';
    
        *main_north_count = north_count_1;
        *main_south_count = south_count_1;
        *main_east_count = east_count_1;
        *main_west_count = west_count_1;
    
        set_one_string_array_equal_to_another_string_array ( main_left_or_right, left_or_right );
    
        set_one_int_array_equal_to_another_int_array ( main_north_array, north_array_1 );
    
        set_one_int_array_equal_to_another_int_array ( main_south_array, south_array_1 );
    
        set_one_int_array_equal_to_another_int_array ( main_east_array, east_array_1 );
    
        set_one_int_array_equal_to_another_int_array ( main_west_array, west_array_1 );
    }
    
    void the_master_function_part_two ( string lowest_value_feeler_1_try_1[],
                                       string lowest_value_feeler_1_try_2[],
                                       string main_left_or_right[],
                                       int main_north_array[],
                                       int main_south_array[],
                                       int main_east_array[],
                                       int main_west_array[],
                                       string *feeler_one_element_zero_equal,
                                       string *feeler_1_lowest_value_array_direction,
                                       int *main_north_count,
                                       int *main_south_count,
                                       int *main_east_count,
                                       int *main_west_count,
                                       int *less_than_node,
                                       int *result_of_left_node_test)
    {
    
        string left_or_right[ 20 ];
        string lowest_value_feeler_2_try_1[ 9 ];
        string lowest_value_feeler_2_try_2[ 9 ];
        string lowest_value_feeler_2_try_3[ 9 ];
        string lowest_value_feeler_2_try_4[ 9 ];
        string lowest_value_feeler_2_try_6[ 9 ];
        string feeler_2_lowest_value_array_direction = "";
        string did_second_feeler_work = "";
        int lowest_value_array_feeler_2_try_1[ 9 ];
        int lowest_value_array_feeler_2_try_2[ 9 ];
    
        int lowest_value_array_feeler_2_try_4[ 9 ];
        int lowest_value_array_feeler_2_try_6[ 9 ];
        int direction_value = 0;
        int feeler = 0;
        int element = 0;
        int left_or_right_1 = 0;
        int left_or_right_2 = 0;
        int left_or_right_3 = 0;
        int left_or_right_4 = 0;
        int north_array_1[ 9 ];
        int south_array_1[ 9 ];
        int east_array_1[ 9 ];
        int west_array_1[ 9 ];
        int north_array_2[ 9 ];
        int south_array_2[ 9 ];
        int east_array_2[ 9 ];
        int west_array_2[ 9 ];
    
        int north_array_2_try_2_zero_and_odd[ 9 ];
        int south_array_2_try_2_zero_and_odd[ 9 ];
        int east_array_2_try_2_zero_and_odd[ 9 ];
        int west_array_2_try_2_zero_and_odd[ 9 ];
    
        int north_array_2_try_4_zero_and_even[ 9 ];
        int south_array_2_try_4_zero_and_even[ 9 ];
        int east_array_2_try_4_zero_and_even[ 9 ];
        int west_array_2_try_4_zero_and_even[ 9 ];
    
        int north_array_2_try_6_one_and_odd[ 9 ];
        int south_array_2_try_6_one_and_odd[ 9 ];
        int east_array_2_try_6_one_and_odd[ 9 ];
        int west_array_2_try_6_one_and_odd[ 9 ];
    
        int north_element_0[ 9 ];
        int south_element_0[ 9 ];
        int east_element_0[ 9 ];
        int west_element_0[ 9 ];
    
        int north_count_2 = 0;
        int south_count_2 = 0;
        int east_count_2 = 0;
        int west_count_2 = 0;
    
        int north_count_array_2_try_2_zero_and_odd = 0;
        int south_count_array_2_try_2_zero_and_odd = 0;
        int east_count_array_2_try_2_zero_and_odd = 0;
        int west_count_array_2_try_2_zero_and_odd = 0;
    
        int north_count_array_2_try_3_zero_and_odd = 0;
        int south_count_array_2_try_3_zero_and_odd = 0;
        int east_count_array_2_try_3_zero_and_odd = 0;
        int west_count_array_2_try_3_zero_and_odd = 0;
    
        int north_count_array_2_try_4_zero_and_even = 0;
        int south_count_array_2_try_4_zero_and_even = 0;
        int east_count_array_2_try_4_zero_and_even = 0;
        int west_count_array_2_try_4_zero_and_even = 0;
    
        int north_count_array_2_try_6_one_and_odd = 0;
        int south_count_array_2_try_6_one_and_odd = 0;
        int east_count_array_2_try_6_one_and_odd = 0;
        int west_count_array_2_try_6_one_and_odd = 0;
    
        int the_number_of_loops = 0;
        int greater_than_node = 0;
    
        set_array_value_to_zero( north_element_0 );
    
        set_array_value_to_zero( south_element_0 );
    
        set_array_value_to_zero( east_element_0 );
    
        set_array_value_to_zero( west_element_0 );
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting step 1
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        set_one_string_array_equal_to_another_string_array ( left_or_right, main_left_or_right );
    
        set_one_int_array_equal_to_another_int_array ( north_array_1, main_north_array );
    
        set_one_int_array_equal_to_another_int_array ( south_array_1, main_south_array );
    
        set_one_int_array_equal_to_another_int_array ( east_array_1, main_east_array );
    
        set_one_int_array_equal_to_another_int_array ( west_array_1, main_west_array );
    
    
        north_count_2 = testing_four_directions(north_array_2, left_or_right, 4);
        south_count_2 = testing_four_directions(south_array_2, left_or_right, 5);
        east_count_2 = testing_four_directions(east_array_2, left_or_right, 6);
        west_count_2 = testing_four_directions(west_array_2, left_or_right, 7);
        display_number_of_steps_message(north_count_2, south_count_2,east_count_2, west_count_2, 2);
    
        cout << '\n';
    
        feeler = 2;
        element = 1;
    
        direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_2_try_1,
        lowest_value_array_feeler_2_try_1,
        north_array_2,
        south_array_2,
        east_array_2,
        west_array_2,
        &feeler_2_lowest_value_array_direction,
        &north_count_2,
        &south_count_2,
        &east_count_2,
        &west_count_2,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_2_try_1[ 0 ] == 0 )
        {
    
            cout << '\n';
    
            display_number_of_steps_message(north_count_2,
                                            south_count_2,
                                            east_count_2,
                                            west_count_2,
                                            feeler);
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_2_try_1[ 0 ] == 1 )
        {
            while ( 1 )
            {
                element = 3;
                left_or_right_1 = 12;
                left_or_right_2 = 13;
                left_or_right_3 = 14;
                left_or_right_4 = 15;
                first_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                   lowest_value_feeler_2_try_2,
                                                                   lowest_value_array_feeler_2_try_2,
                                                                   north_array_2_try_2_zero_and_odd,
                                                                   south_array_2_try_2_zero_and_odd,
                                                                   east_array_2_try_2_zero_and_odd,
                                                                   west_array_2_try_2_zero_and_odd,
                                                                   feeler_1_lowest_value_array_direction,
                                                                   &feeler_2_lowest_value_array_direction,
                                                                   &did_second_feeler_work,
                                                                   &north_count_array_2_try_2_zero_and_odd,
                                                                   &south_count_array_2_try_2_zero_and_odd,
                                                                   &east_count_array_2_try_2_zero_and_odd,
                                                                   &west_count_array_2_try_2_zero_and_odd,
                                                                   &left_or_right_1,
                                                                   &left_or_right_2,
                                                                   &left_or_right_3,
                                                                   &left_or_right_4,
                                                                   &feeler,
                                                                   &element,
                                                                   &the_number_of_loops);
                if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
                {
                        break;
    
                }
            }
        }
    
        //////////
    
        cout << '\n';
    
        //results = testing_if_feeler_one_lowest_value_is_same_direction_as_feeler_two_lowest_value ( lowest_value_feeler,
                                                                                          //&did_second_feeler_work,
                                                                                          //&version);
    
    
    
            if ( lowest_value_feeler_1_try_1[ 0 ] == lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_1[ 0 ] != lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_unequal";
    
            }
    
            else if ( lowest_value_feeler_1_try_2[ 0 ] == lowest_value_feeler_2_try_2 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_2[ 0 ] != lowest_value_feeler_2_try_2 [ 0 ] )
            {
               did_second_feeler_work = "elements_are_unequal";
    
            }
    
        // running the second feeler again if it didn't fix the block problem the first time.
    ////
        if ( did_second_feeler_work == "elements_are_equal" )
        {
            int lowest_value_array_feeler_2_try_3[ 9 ];
            int north_array_2_try_3_zero_and_odd[ 9 ];
            int south_array_2_try_3_zero_and_odd[ 9 ];
            int east_array_2_try_3_zero_and_odd[ 9 ];
            int west_array_2_try_3_zero_and_odd[ 9 ];
    
            feeler = 2;
            element = 4;
            left_or_right_1 = 16;
            left_or_right_2 = 17;
            left_or_right_3 = 18;
            left_or_right_4 = 19;
            second_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_3,
                                                                  lowest_value_array_feeler_2_try_3,
                                                                  north_array_2_try_3_zero_and_odd,
                                                                  south_array_2_try_3_zero_and_odd,
                                                                  east_array_2_try_3_zero_and_odd,
                                                                  west_array_2_try_3_zero_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_3_zero_and_odd,
                                                                  &south_count_array_2_try_3_zero_and_odd,
                                                                  &east_count_array_2_try_3_zero_and_odd,
                                                                  &west_count_array_2_try_3_zero_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            display_number_of_steps_message(north_count_array_2_try_3_zero_and_odd,
                                        south_count_array_2_try_3_zero_and_odd,
                                        east_count_array_2_try_3_zero_and_odd,
                                        west_count_array_2_try_3_zero_and_odd,
                                        feeler);
        }
    
    
        cout << '\n';
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting feeler 2 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << "The second feeler did something to unblock feeler 1\n\n";
        cout << "Step 4 ended = make feeler 1 and 2 unequal - gain control.\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "The second feeler did something to unblock feeler 1\n\n";
                file << "Step 4 ended = make feeler 1 and 2 unequal - gain control.\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            }
    
            file.close();
        }
    
    ////
    
    // begin test here
    
    
    
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making the unequal equal again
    
    ////
            feeler = 2;
            element = 5;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            greater_than_node = setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_4,
                                                                lowest_value_array_feeler_2_try_4,
                                                                north_array_2_try_4_zero_and_even,
                                                                south_array_2_try_4_zero_and_even,
                                                                east_array_2_try_4_zero_and_even,
                                                                west_array_2_try_4_zero_and_even,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_4_zero_and_even,
                                                                &south_count_array_2_try_4_zero_and_even,
                                                                &east_count_array_2_try_4_zero_and_even,
                                                                &west_count_array_2_try_4_zero_and_even,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_4_zero_and_even,
                                        south_count_array_2_try_4_zero_and_even,
                                        east_count_array_2_try_4_zero_and_even,
                                        west_count_array_2_try_4_zero_and_even,
                                        feeler);
    
            cout << "Step 5 ended = make feeler 1 and 2 equal - lose control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "The second feeler did something to unblock feeler 1\n\n";
                    file << "Step 5 ended = make feeler 1 and 2 unequal - gain control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making equal unequal again.
    ////
            feeler = 3;
            element = 7;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            fourth_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_6,
                                                                  lowest_value_array_feeler_2_try_6,
                                                                  north_array_2_try_6_one_and_odd,
                                                                  south_array_2_try_6_one_and_odd,
                                                                  east_array_2_try_6_one_and_odd,
                                                                  west_array_2_try_6_one_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_6_one_and_odd,
                                                                  &south_count_array_2_try_6_one_and_odd,
                                                                  &east_count_array_2_try_6_one_and_odd,
                                                                  &west_count_array_2_try_6_one_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_6_one_and_odd,
                                        south_count_array_2_try_6_one_and_odd,
                                        east_count_array_2_try_6_one_and_odd,
                                        west_count_array_2_try_6_one_and_odd,
                                        feeler);
    
            cout << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "Step 6 ended = make feeler 1 and 2 unequal - regain control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << '\n';
    
        if ( greater_than_node > *less_than_node )
        {
            cout << "greater than node: " << greater_than_node << ", is greater than less than node: " << *less_than_node << '\n';
            cout << "Added left node, start turning.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is greater than less than node: " << *less_than_node << '\n';
                file << "Added left node, start turning.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 0;
        }
        else if( *less_than_node > greater_than_node )
        {
            cout << "greater than node: " << greater_than_node << ", is not greater than less than node: " << *less_than_node << '\n';
            cout << "Didn\'t add left node, no turning, go straight.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is not greater than less than node: " << *less_than_node << '\n';
                file << "Didn\'t add left node, no turning, go straight.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 1;
        }
        else
        {
            cout << "greater than node: " << greater_than_node << ", is equal to less than node: " << *less_than_node << '\n';
            cout << "Didn\'t add left node, no turning, go straight.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is equal to less than node: " << *less_than_node << '\n';
                file << "Didn\'t add left node, no turning, go straight.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 1;
        }
    }
    
    int main ()
    {
        string lowest_value_feeler_1_try_1[ 9 ];
        string lowest_value_feeler_1_try_2[ 9 ];
        string left_or_right[ 4 ];
        int north_array[ 9 ];
        int south_array[ 9 ];
        int east_array[ 9 ];
        int west_array[ 9 ];
        int compare_to_output_array_1[ 9 ];
        int compare_to_output_array_2[ 9 ];
        int the_random_list_generated_by_the_left_node_results_array[ 9 ];
        string feeler_1_lowest_value_array_direction = "";
        string feeler_one_element_zero_equal = "";
        int north_count_1 = 0;
        int south_count_1 = 0;
        int east_count_1 = 0;
        int west_count_1 = 0;
        int less_than_node = 0;
        int result_of_left_node_test = 0;
        int try_again = 0;
        int good_job = 0;
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            cout << "Starting program\n";
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "Starting program\n\n";
            }
            file.close();
        }
    
        srand( time( NULL ) );
        for ( int i = 0; i < 9; i++ )
        {
            // keep the numbers small so they're easy to read
            compare_to_output_array_1[ i ] = rand() % 2;
        }
    
        while ( 1 )
        {
            north_count_1 = 0;
            south_count_1 = 0;
            east_count_1 = 0;
            west_count_1 = 0;
            less_than_node = 0;
            result_of_left_node_test = 0;
            int counting_matching_array_elements_1 = 0;
            int counting_matching_array_elements_2 = 0;
            int counting_left_nodes_1 = 0;
            int counting_left_nodes_2 = 0;
    
            for ( int i = 0; i < 9; i++ )
            {
                the_master_function_part_one(lowest_value_feeler_1_try_1,
                                         lowest_value_feeler_1_try_2,
                                         left_or_right,
                                         north_array,
                                         south_array,
                                         east_array,
                                         west_array,
                                         &feeler_one_element_zero_equal,
                                         &feeler_1_lowest_value_array_direction,
                                         &north_count_1,
                                         &south_count_1,
                                         &east_count_1,
                                         &west_count_1,
                                         &less_than_node);
    
            the_master_function_part_two(lowest_value_feeler_1_try_1,
                                         lowest_value_feeler_1_try_2,
                                         left_or_right,
                                         north_array,
                                         south_array,
                                         east_array,
                                         west_array,
                                         &feeler_one_element_zero_equal,
                                         &feeler_1_lowest_value_array_direction,
                                         &north_count_1,
                                         &south_count_1,
                                         &east_count_1,
                                         &west_count_1,
                                         &less_than_node,
                                         &result_of_left_node_test);
    
            the_random_list_generated_by_the_left_node_results_array[ i ] = result_of_left_node_test;
            }
    
            srand( time( NULL ) );
            for ( int i = 0; i < 9; i++ )
            {
                // keep the numbers small so they're easy to read
                compare_to_output_array_2[ i ] = rand() % 2;
            }
    
            for ( int i = 0; i < 9; i++ )
            {
                // counting left nodes in the 2 arrays
                if ( compare_to_output_array_1[ i ] == 0 )
                {
                    counting_left_nodes_1 += 1;
                }
                if ( compare_to_output_array_2[ i ] == 0 )
                {
                    counting_left_nodes_2 += 1;
                }
    
                // comparing the elements of the two arrays to the results array to find matching elements
                if (compare_to_output_array_1[ i ] == the_random_list_generated_by_the_left_node_results_array [ i ] )
                {
                    counting_matching_array_elements_1 += 1;
                }
                if (compare_to_output_array_2[ i ] == the_random_list_generated_by_the_left_node_results_array[ i ] )
                {
                    counting_matching_array_elements_2 += 1;
                }
            }
    
            if ( counting_matching_array_elements_1 > counting_matching_array_elements_2 )
            {
                if ( counting_left_nodes_1 < counting_left_nodes_2 )
                {
    
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was met: Good job!.\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was met: Good job!.\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_1, 9 );
                    good_job += 1;
                    break;
                }
                else
                {
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was not met: Try again.\n\n";
    
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was not met: Try again.\n\n";
    
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_1, 9 );
    
                    try_again += 1;
                }
            }
            else if ( counting_matching_array_elements_2 > counting_matching_array_elements_1 )
            {
                if ( counting_left_nodes_2 < counting_left_nodes_1 )
                {
                    cout << "The goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was met: Good job!.\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "The goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was met: Good job!.\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_2, 9 );
                    good_job += 1;
                    break;
                }
                else
                {
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was not met: Try again.\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was not met: Try again.\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_2, 9 );
                    try_again += 1;
                }
            }
        }
    
        cout << '\n';
        cout << "generated input list 1\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated input list 1\n";
            }
    
            file.close();
        }
    
        displayArray( compare_to_output_array_1, 9 );
        cout << '\n';
        cout << "generated input list 2\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated input list 2\n";
            }
    
            file.close();
        }
    
        displayArray( compare_to_output_array_2, 9 );
        cout << '\n';
        cout << "generated results list\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated results list\n";
            }
    
            file.close();
        }
    
        displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
        cout << "\n\n";
    
        cout << "\n\nscore:\n";
        cout << "Number of times won = " << good_job << '\n';
        cout << "Number of tries until won = " << try_again << '\n';
    
        cout << "\nEnding program\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\n\n";
    
                file << "\n\nscore:\n";
                file << "Number of times won = " << good_job << '\n';
                file << "Number of tries until won = " << try_again << '\n';
    
                file << "\nEnding program\n";
            }
    
            file.close();
        }
    
    
    
        getchar();
    }
    In the randomizing_array_elements function on line 223 the srand makes the program slow right down. Take that line out and my program zips along.

    I'm hoping that you can give me some better code to use instead of srand.

    I know there are intel versions of srand like code and maybe a boost version too, but I looked on google and couldn't find any video or details of how to use those in codeblocks on windows 7.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by jeremy duncan
    In the randomizing_array_elements function on line 223 the srand makes the program slow right down. Take that line out and my program zips along.

    I'm hoping that you can give me some better code to use instead of srand.
    There is no better code to use than srand because you are using rand: you want to seed the pseudorandom number generator behind rand, and srand is the right tool for the job. The issue is that you are calling srand in the wrong place. Move that line to near the start of the main function such that it is called exactly once, before any call to rand (hence before the first call to randomizing_array_elements).
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    Thanks for the tip. I had one srand in the function on line 223 and 2 srand in the main function.

    Now I only have one srand in the program near the top of the main function.

    Code:
    #include <cstdlib>
    #include <ctime>
    #include <iostream>
    #include <windows.h> // WinApi header
    #include <cstdio>
    #include <string>
    #include <time.h>
    #include <fstream>
    
    using namespace std;
    
    int findSmallestRemainingElement (int array[], int size, int index);
    void swap (int array[], int first_index, int second_index);
    
    void sort (int array[], int size)
    {
        for ( int i = 0; i < size; i++ )
        {
            int index = findSmallestRemainingElement( array, size, i );
            swap( array, i, index );
        }
    }
    
    int findSmallestRemainingElement (int array[], int size, int index)
    {
        int index_of_smallest_value = index;
        for (int i = index + 1; i < size; i++)
        {
            if ( array[ i ] < array[ index_of_smallest_value ] )
            {
                index_of_smallest_value = i;
            }
        }
        return index_of_smallest_value;
    }
    
    void swap (int array[], int first_index, int second_index)
    {
        int temp = array[ first_index ];
        array[ first_index ] = array[ second_index ];
        array[ second_index ] = temp;
    }
    
    // small helper method to display the before and after arrays
    void displayArray (int array[], int size)
    {
        cout << "{";
        for ( int i = 0; i < size; i++ )
        {
            // you'll see this pattern a lot for nicely formatting
            // lists--check if we're past the first element, and
            // if so, append a comma
            if ( i != 0 )
            {
                cout << ", ";
            }
            cout << array[ i ];
        }
        cout << "}";
    }
    
    void set_array_value_to_zero ( int array[] )
    {
        for ( int i = 0; i < 9; i++ )
        {
            array[ i ] = 0;
        }
    }
    
    void set_one_string_array_equal_to_another_string_array ( string array[], string array2[] )
    {
        for ( int i = 0; i < 4; i++ )
        {
            array[ i ] = array2[ i ];
        }
    }
    
    void set_one_int_array_equal_to_another_int_array ( int array[], int array2[] )
    {
        for ( int i = 0; i < 9; i++ )
        {
            array[ i ] = array2[ i ];
        }
    }
    
    void newSwitch (int array[], int size, int subtracting_this_many_array_elements, int *high, int *medium, int *low)
    {
        for ( int i = size; i-- > subtracting_this_many_array_elements; )
        {
    
            switch(array[i])
            {
                case 8:
                case 7:
                case 6:
                    //cout << "Input: " << i << " too high\n";
                    *high += 1;
                    break;
                case 5:
                case 4:
                case 3:
                    //cout << "Input: " << i << " might be good\n";
                    *medium += 1;
                    break;
                case 2:
                case 1:
                case 0:
                    //cout << "Input: " << i << " is good\n";
                    *low += 1;
                    break;
            }
        }
    }
    
    int which_value_is_largest (int high, int medium, int low)
    {
        int value = 0;
    
        if ( high > medium && high > low && medium > low )
        {
            value = 13;
        }
    
        else if ( high > medium && high > low && medium == low )
        {
            value = 12;
        }
    
        else if ( high > medium && high > low && low > medium )
        {
            value = 11;
        }
    
        else if ( medium > high && medium > low && high > low )
        {
            value = 10;
        }
    
        else if ( medium > high && medium > low && high == low )
        {
            value = 9;
        }
    
        else if ( medium > high && medium > low && low > high )
        {
            value = 8;
        }
    
        else if ( low > medium && low > high && high > medium )
        {
            value = 7;
        }
    
        else if ( low > medium && low > high && high == medium )
        {
            value = 6;
        }
    
        else if ( low > medium && low > high && medium > high )
        {
            value = 5;
        }
    
        else if ( medium == low && high < medium )
        {
            value = 4;
        }
        else if ( high == low && medium < high )
        {
            value = 3;
        }
        else if ( high == medium && low < medium )
        {
            value = 2;
        }
        else
        {
            value = 1;
        }
    
        return value;
    }
    
    int side (int array[], int size, int subtracting_this_many_array_elements)
    {
        int too_high = 0;
        int might_be_good = 0;
        int good_stuff = 0;
    
        int value = 0;
    
        //cout << "____________________________________\n";
    
        //cout << "Original array: ";
        //displayArray( array, size );
        //cout << '\n';
    
        sort( array, size );
    
        //cout << "Sorted array: ";
        //displayArray( array, size );
       // cout << '\n';
        //cout << '\n';
    
        newSwitch( array, size, subtracting_this_many_array_elements, &too_high, &might_be_good, &good_stuff );
    
        //cout << '\n';
    
        //cout << "high counter = " << too_high << '\n';
        //cout << "medium counter = " << might_be_good << '\n';
        //cout << "low counter = " << good_stuff << '\n';
    
        //cout << '\n';
    
        value = which_value_is_largest (too_high, might_be_good, good_stuff);
        //interpreting_whichValueIsLargest(value);
    
        //cout << '\n';
    
        return value;
    }
    
    void randomizing_array_elements ( int array[], int size)
    {
    
        for ( int i = 0; i < size; i++ )
        {
            // keep the numbers small so they're easy to read
            array[ i ] = rand() % 9;
        }
    }
    
    int  do_this_if_left_or_right_is_greater(int array[], string left_or_right[], int *I_took_a_step, int left_side, int right_side, int subtracting_this_many_array_elements, int which_string_element)
    {
        int value = 0;
        //cout << "____________________________________\n";
    
        //cout << "Left side value is: " << left_side << '\n';
        //cout << "Right side value is: " << right_side << '\n';
        //cout << '\n';
    
        if ( left_side > right_side )
        {
            for ( int i = 0; i < 8; i++ )
            {
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
    
                subtracting_this_many_array_elements++;
                left_side = side( array, 9, subtracting_this_many_array_elements );
                //cout << "Left side value is: " << left_side << '\n';
    
                if (left_side <= 3)
                {
                    //cout << "____________________________________\n";
    
                    //cout << "Took a step\n";
                    value = 1;
                    *I_took_a_step += 1;
                    Beep(1568, 500);
    
                    break;
                }
                else
                {
                    value = 0;
                }
                //cout << '\n';
            }
            left_or_right [ which_string_element ] = "left";
        }
        else if ( right_side > left_side )
        {
            for ( int i = 0; i < 8; i++ )
            {
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
    
                subtracting_this_many_array_elements++;
                right_side = side( array, 9, subtracting_this_many_array_elements );
                //cout << "Right side value is: " << right_side << '\n';
    
                if (right_side <= 3)
                {
                    //cout << "____________________________________\n";
                    //cout << "Took a step\n";
                    value = 1;
                    *I_took_a_step += 1;
                    Beep(523,500); // 523 hertz (C5) for 500 milliseconds
                    break;
                }
                else
                {
                    value = 0;
                }
    
                //cout << '\n';
            }
            left_or_right [ which_string_element ] = "right";
        }
    
        return value;
    }
    
    int testing_four_directions(int counter[], string left_or_right[], int which_string_element)
    {
        int array[ 9 ];
    
        int I_took_a_step = 0;
    
        int subtracting_this_many_array_elements = 0;
    
        for ( int i = 0; i < 9; i++ )
        {
            set_array_value_to_zero( array );
    
            randomizing_array_elements(array, 9);
            int left_side = side( array, 9 , subtracting_this_many_array_elements);
    
            set_array_value_to_zero( array );
    
            randomizing_array_elements(array, 9);
            int right_side = side( array, 9, subtracting_this_many_array_elements );
    
            while ( left_side == right_side )
            {
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
                left_side = side( array, 9 , subtracting_this_many_array_elements);
    
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
                right_side = side( array, 9, subtracting_this_many_array_elements );
            }
    
            int step_counter = do_this_if_left_or_right_is_greater(array, left_or_right, &I_took_a_step, left_side, right_side, subtracting_this_many_array_elements, which_string_element);
            counter[ i ] = step_counter;
        }
        return I_took_a_step;
    }
    
    
    int which_direction_is_lowest(string lowest_value_feeler[], int north, int south, int east, int west, int feeler, int element)
    {
        int direction_value = 0;
        if ( north < south && north < east && north < west )
        {
            lowest_value_feeler[ element ] = "north";
            direction_value = 1;
        }
        else if ( south < north && south < east && south < west )
        {
            lowest_value_feeler[ element ] = "south";
            direction_value = 2;
        }
        else if ( east < north && east < south && east < west )
        {
            lowest_value_feeler[ element ] = "east";
            direction_value = 3;
        }
        else if ( west < north && west < south && west < east )
        {
            lowest_value_feeler[ element ] = "west";
            direction_value = 4;
        }
        else if ( north == south && north == east && north == west )
        {
            lowest_value_feeler[ element ] = "no_lowest_direction.";
            direction_value = 5;
        }
        else if ( north == east && north == south )
        {
            lowest_value_feeler[ element ] = "north_east_south.";
            direction_value = 6;
        }
        else if ( east == south && east == west )
        {
            lowest_value_feeler[ element ] = "east_south_west.";
            direction_value = 7;
        }
        else if ( south == west && south == north )
        {
            lowest_value_feeler[ element ] = "south_west_north.";
            direction_value = 8;
        }
        else if ( west == north && west == east )
        {
            lowest_value_feeler[ element ] = "west_north_east.";
            direction_value = 9;
        }
        else if ( north == east )
        {
            lowest_value_feeler[ element ] = "north_east.";
            direction_value = 10;
        }
        else if ( east == south )
        {
            lowest_value_feeler[ element ] = "east_south.";
            direction_value = 11;
        }
        else if ( south == west )
        {
            lowest_value_feeler[ element ] = "south_west.";
            direction_value = 12;
        }
        else if ( west == north )
        {
            lowest_value_feeler[ element ] = "west_north.";
            direction_value = 13;
        }
        else if ( west == east )
        {
            lowest_value_feeler[ element ] = "west_east.";
            direction_value = 14;
        }
        else if ( north == south )
        {
            lowest_value_feeler[ element ] = "north_south.";
            direction_value = 15;
        }
        else if ( north == east && north > south && north > west )
        {
            lowest_value_feeler[ element ] = "north_east";
            direction_value = 16;
        }
    
        else if ( north == west && north > east && north > south )
        {
            lowest_value_feeler[ element ] = "north_west";
            direction_value = 17;
        }
        else if ( north == south && north > east && north > west )
        {
            lowest_value_feeler[ element ] = "north_south";
            direction_value = 18;
        }
        else if ( east == west && east > north && east > south )
        {
            lowest_value_feeler[ element ] = "east_west";
            direction_value = 19;
        }
        else if ( east == south && east > north && east > west )
        {
            lowest_value_feeler[ element ] = "east_south";
            direction_value = 20;
        }
        else if ( west == south && west > north && west > east )
        {
            lowest_value_feeler[ element ] = "west_south";
            direction_value = 21;
        }
    
        return direction_value;
    }
    
    void displaying_which_direction_is_lowest( int lowest_value_array[], int direction_value, int feeler )
    {
    
        if ( direction_value == 1 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 2 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 3 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 4 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 5 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south, east, west direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south, east, west direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 6 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east, south direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east, south direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 7 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south, west direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south, west direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 8 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south, west, north direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south, west, north direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 9 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, north, east direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, north, east direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 10 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 11 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 12 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south, west direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south, west direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 13 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, north direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, north direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 14 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, east direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, east direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 15 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 16 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 17 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, west direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, west direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 18 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 19 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, west direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, west direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 20 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 21 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, south direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, south direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
    }
    
    void direction_value_array_transfer_value_to_new_array (int lowest_value_array[],
                                                           string *lowest_value_array_direction,
                                                                      int north[],
                                                                      int south[],
                                                                      int east[],
                                                                      int west[],
                                                                      int *direction_value)
    {
    
        switch( *direction_value )
        {
            case 1:
            case 5:
            case 6:
            case 10:
            case 17:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, north );
                *lowest_value_array_direction = "north";
                break;
    
            case 2:
            case 8:
            case 12:
            case 15:
            case 18:
            case 20:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, south );
                *lowest_value_array_direction = "south";
                break;
    
            case 3:
            case 7:
            case 11:
            case 16:
            case 19:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, east );
                *lowest_value_array_direction = "east";
                break;
    
            case 4:
            case 9:
            case 13:
            case 14:
            case 21:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, west );
                *lowest_value_array_direction = "west";
                break;
        }
    }
    
    void display_number_of_steps_message(int north, int south, int east, int west, int which_feeler)
    {
        cout << "Values with feeler "<< which_feeler << "\n";
        cout << "I tried to take 9 steps in the north direction, but I actual took " << north << " steps.\n";
        cout << "I tried to take 9 steps in the south direction, but I actual took " << south << " steps.\n";
        cout << "I tried to take 9 steps in the east direction, but I actual took " << east << " steps.\n";
        cout << "I tried to take 9 steps in the west direction, but I actual took " << west << " steps.\n";
    
        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
        if( file.fail() )
        {
            cout << "error while opening the file in the display_number_of_steps_message function" << endl;
        }
        else
        {
            file << endl;
            file << "Values with feeler "<< which_feeler << "\n";
            file << "I tried to take 9 steps in the north direction, but I actual took " << north << " steps.\n";
            file << "I tried to take 9 steps in the south direction, but I actual took " << south << " steps.\n";
            file << "I tried to take 9 steps in the east direction, but I actual took " << east << " steps.\n";
            file << "I tried to take 9 steps in the west direction, but I actual took " << west << " steps.\n";
            file << endl;
        }
    
        file.close();
    }
    
    void used_in_setting_feeler_to_new_value ( string left_or_right[],
                                               string lowest_value_feeler[],
                                               int lowest_value_array[],
                                               int north_array[],
                                               int south_array[],
                                               int east_array[],
                                               int west_array[],
                                               string *lowest_value_array_direction,
                                               int *north_count,
                                               int *south_count,
                                               int *east_count,
                                               int *west_count,
                                               int *left_or_right_1,
                                               int *left_or_right_2,
                                               int *left_or_right_3,
                                               int *left_or_right_4,
                                               int *feeler,
                                               int *element )
    {
        int direction_value = 0;
    
        set_array_value_to_zero( north_array );
    
        set_array_value_to_zero( south_array );
    
        set_array_value_to_zero( east_array );
    
        set_array_value_to_zero( west_array );
        set_array_value_to_zero( lowest_value_array );
    
        left_or_right[ *left_or_right_1 ] = "";
        left_or_right[ *left_or_right_2 ] = "";
        left_or_right[ *left_or_right_3 ] = "";
        left_or_right[ *left_or_right_4 ] = "";
    
        *north_count = testing_four_directions(north_array, left_or_right, *left_or_right_1);
        *south_count = testing_four_directions(south_array, left_or_right, *left_or_right_2);
        *east_count = testing_four_directions(east_array, left_or_right, *left_or_right_3);
        *west_count = testing_four_directions(west_array, left_or_right, *left_or_right_4);
        direction_value = which_direction_is_lowest(lowest_value_feeler,
                                                    *north_count,
                                                    *south_count,
                                                    *east_count,
                                                    *west_count,
                                                    *feeler, *element);
    
        direction_value_array_transfer_value_to_new_array ( lowest_value_array,
                                                           lowest_value_array_direction,
                                                            north_array,
                                                            south_array,
                                                            east_array,
                                                            west_array,
                                                            &direction_value);
    
        displaying_which_direction_is_lowest( lowest_value_array, direction_value, *feeler );
    
    
    }
    
    void fourth_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_6[],
                                                              int lowest_value_array_feeler_2_try_6[],
                                                              int north_array_2_try_6_one_and_odd[],
                                                              int south_array_2_try_6_one_and_odd[],
                                                              int east_array_2_try_6_one_and_odd[],
                                                              int west_array_2_try_6_one_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_6_one_and_odd,
                                                              int *south_count_array_2_try_6_one_and_odd,
                                                              int *east_count_array_2_try_6_one_and_odd,
                                                              int *west_count_array_2_try_6_one_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_6,
                                                  lowest_value_array_feeler_2_try_6,
                                                  north_array_2_try_6_one_and_odd,
                                                  south_array_2_try_6_one_and_odd,
                                                  east_array_2_try_6_one_and_odd,
                                                  west_array_2_try_6_one_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_6_one_and_odd,
                                                  south_count_array_2_try_6_one_and_odd,
                                                  east_count_array_2_try_6_one_and_odd,
                                                  west_count_array_2_try_6_one_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_6[ 0 ] == 1)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    
    
    }
    
    void third_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_5[],
                                                              int lowest_value_array_feeler_2_try_5[],
                                                              int north_array_2_try_5_one_and_odd[],
                                                              int south_array_2_try_5_one_and_odd[],
                                                              int east_array_2_try_5_one_and_odd[],
                                                              int west_array_2_try_5_one_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_5_one_and_odd,
                                                              int *south_count_array_2_try_5_one_and_odd,
                                                              int *east_count_array_2_try_5_one_and_odd,
                                                              int *west_count_array_2_try_5_one_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_5,
                                                  lowest_value_array_feeler_2_try_5,
                                                  north_array_2_try_5_one_and_odd,
                                                  south_array_2_try_5_one_and_odd,
                                                  east_array_2_try_5_one_and_odd,
                                                  west_array_2_try_5_one_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_5_one_and_odd,
                                                  south_count_array_2_try_5_one_and_odd,
                                                  east_count_array_2_try_5_one_and_odd,
                                                  west_count_array_2_try_5_one_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_5[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    
    
    }
    
    int setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( string left_or_right[],
                                                               string lowest_value_feeler_2_try_4[],
                                                               int lowest_value_array_feeler_2_try_4[],
                                                               int north_array_2_try_4_zero_and_even[],
                                                               int south_array_2_try_4_zero_and_even[],
                                                               int east_array_2_try_4_zero_and_even[],
                                                               int west_array_2_try_4_zero_and_even[],
                                                               string *feeler_1_lowest_value_array_direction,
                                                               string *feeler_2_lowest_value_array_direction,
                                                               string *did_second_feeler_work,
                                                               int *north_count_array_2_try_4_zero_and_even,
                                                               int *south_count_array_2_try_4_zero_and_even,
                                                               int *east_count_array_2_try_4_zero_and_even,
                                                               int *west_count_array_2_try_4_zero_and_even,
                                                               int *left_or_right_1,
                                                               int *left_or_right_2,
                                                               int *left_or_right_3,
                                                               int *left_or_right_4,
                                                               int *feeler,
                                                               int *element,
                                                               int *the_number_of_loops)
    {
        int counter = 0;
        while ( 1 )
        {
            counter = counter + 1;
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                      lowest_value_feeler_2_try_4,
                                                      lowest_value_array_feeler_2_try_4,
                                                      north_array_2_try_4_zero_and_even,
                                                      south_array_2_try_4_zero_and_even,
                                                      east_array_2_try_4_zero_and_even,
                                                      west_array_2_try_4_zero_and_even,
                                                      feeler_2_lowest_value_array_direction,
                                                      north_count_array_2_try_4_zero_and_even,
                                                      south_count_array_2_try_4_zero_and_even,
                                                      east_count_array_2_try_4_zero_and_even,
                                                      west_count_array_2_try_4_zero_and_even,
                                                      left_or_right_1,
                                                      left_or_right_2,
                                                      left_or_right_3,
                                                      left_or_right_4,
                                                      feeler,
                                                      element );
    
                if ( lowest_value_array_feeler_2_try_4[ 0 ] == 0)
                {
                    if ( *feeler_2_lowest_value_array_direction ==  *feeler_1_lowest_value_array_direction )
                    {
                        *the_number_of_loops += 1;
                        *did_second_feeler_work = "elements_are_equal";
    
                        return counter;
                    }
                }
                else
                {
                   *the_number_of_loops += 1;
                   *did_second_feeler_work = "elements_are_unequal";
                }
        }
    }
    
    void second_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                               string lowest_value_feeler_2_try_3[],
                                                               int lowest_value_array_feeler_2_try_3[],
                                                               int north_array_2_try_3_zero_and_odd[],
                                                               int south_array_2_try_3_zero_and_odd[],
                                                               int east_array_2_try_3_zero_and_odd[],
                                                               int west_array_2_try_3_zero_and_odd[],
                                                               string *feeler_1_lowest_value_array_direction,
                                                               string *feeler_2_lowest_value_array_direction,
                                                               string *did_second_feeler_work,
                                                               int *north_count_array_2_try_3_zero_and_odd,
                                                               int *south_count_array_2_try_3_zero_and_odd,
                                                               int *east_count_array_2_try_3_zero_and_odd,
                                                               int *west_count_array_2_try_3_zero_and_odd,
                                                               int *left_or_right_1,
                                                               int *left_or_right_2,
                                                               int *left_or_right_3,
                                                               int *left_or_right_4,
                                                               int *feeler,
                                                               int *element,
                                                               int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_3,
                                                  lowest_value_array_feeler_2_try_3,
                                                  north_array_2_try_3_zero_and_odd,
                                                  south_array_2_try_3_zero_and_odd,
                                                  east_array_2_try_3_zero_and_odd,
                                                  west_array_2_try_3_zero_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_3_zero_and_odd,
                                                  south_count_array_2_try_3_zero_and_odd,
                                                  east_count_array_2_try_3_zero_and_odd,
                                                  west_count_array_2_try_3_zero_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_3[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
    
            }
        }
    }
    
    void first_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_2[],
                                                              int lowest_value_array_feeler_2_try_2[],
                                                              int north_array_2_try_2_zero_and_odd[],
                                                              int south_array_2_try_2_zero_and_odd[],
                                                              int east_array_2_try_2_zero_and_odd[],
                                                              int west_array_2_try_2_zero_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_2_zero_and_odd,
                                                              int *south_count_array_2_try_2_zero_and_odd,
                                                              int *east_count_array_2_try_2_zero_and_odd,
                                                              int *west_count_array_2_try_2_zero_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    
    
    
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_2,
                                                  lowest_value_array_feeler_2_try_2,
                                                  north_array_2_try_2_zero_and_odd,
                                                  south_array_2_try_2_zero_and_odd,
                                                  east_array_2_try_2_zero_and_odd,
                                                  west_array_2_try_2_zero_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_2_zero_and_odd,
                                                  south_count_array_2_try_2_zero_and_odd,
                                                  east_count_array_2_try_2_zero_and_odd,
                                                  west_count_array_2_try_2_zero_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                   *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    }
    
    void setting_feeler_one_element_zero_to_zero ( string left_or_right[],
                                                      string lowest_value_feeler[],
                                                      int lowest_value_array[],
                                                      int north_array_1_try_2_zero[],
                                                      int south_array_1_try_2_zero[],
                                                      int east_array_1_try_2_zero[],
                                                      int west_array_1_try_2_zero[],
                                                      string *feeler_1_lowest_value_array_direction,
                                                      string *feeler_2_lowest_value_array_direction,
                                                      string *did_second_feeler_work,
                                                      int *north_count_array_1_try_2_zero,
                                                      int *south_count_array_1_try_2_zero,
                                                      int *east_count_array_1_try_2_zero,
                                                      int *west_count_array_1_try_2_zero,
                                                      int *left_or_right_1,
                                                      int *left_or_right_2,
                                                      int *left_or_right_3,
                                                      int *left_or_right_4,
                                                      int *feeler,
                                                      int *element,
                                                      int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler,
                                                  lowest_value_array,
                                                  north_array_1_try_2_zero,
                                                  south_array_1_try_2_zero,
                                                  east_array_1_try_2_zero,
                                                  west_array_1_try_2_zero,
                                                  feeler_1_lowest_value_array_direction,
                                                  north_count_array_1_try_2_zero,
                                                  south_count_array_1_try_2_zero,
                                                  east_count_array_1_try_2_zero,
                                                  west_count_array_1_try_2_zero,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
    
    
            if ( lowest_value_array[ 0 ] == 0 )
            {
                break;
            }
        }
    }
    
    void direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest( string lowest_value_feeler[],
                                                                                                                                             int lowest_value_array[],
                                          int north_array[],
                                          int south_array[],
                                          int east_array[],
                                          int west_array[],
                                          string *lowest_value_array_direction,
                                          int *north_count,
                                          int *south_count,
                                          int *east_count,
                                          int *west_count,
                                          int *feeler,
                                          int *element,
                                          int *direction_value )
    {
    
        *direction_value = which_direction_is_lowest(lowest_value_feeler,
                                                    *north_count,
                                                    *south_count,
                                                    *east_count,
                                                    *west_count,
                                                    *feeler,
                                                    *element);
    
        direction_value_array_transfer_value_to_new_array ( lowest_value_array,
                                                           lowest_value_array_direction,
                                                            north_array,
                                                            south_array,
                                                            east_array,
                                                            west_array,
                                                            direction_value);
    
        displaying_which_direction_is_lowest( lowest_value_array, *direction_value, *feeler );
    
    }
    
    void the_master_function_part_one ( string lowest_value_feeler_1_try_1[],
                                       string lowest_value_feeler_1_try_2[],
                                       string main_left_or_right[],
                                       int main_north_array[],
                                       int main_south_array[],
                                       int main_east_array[],
                                       int main_west_array[],
                                       string *feeler_one_element_zero_equal,
                                       string *feeler_1_lowest_value_array_direction,
                                       int *main_north_count,
                                       int *main_south_count,
                                       int *main_east_count,
                                       int *main_west_count,
                                       int *less_than_node)
    {
        string left_or_right[ 20 ];
        string lowest_value_feeler_2_try_1[ 9 ];
        string lowest_value_feeler_2_try_2[ 9 ];
        string lowest_value_feeler_2_try_3[ 9 ];
        string lowest_value_feeler_2_try_4[ 9 ];
        string lowest_value_feeler_2_try_5[ 9 ];
        string feeler_2_lowest_value_array_direction = "";
        string did_second_feeler_work = "";
        int lowest_value_array_feeler_1_try_1[ 9 ];
        int lowest_value_array_feeler_1_try_2[ 9 ];
        int lowest_value_array_feeler_2_try_1[ 9 ];
        int lowest_value_array_feeler_2_try_2[ 9 ];
        int lowest_value_array_feeler_2_try_4[ 9 ];
        int lowest_value_array_feeler_2_try_5[ 9 ];
        int direction_value = 0;
        int feeler = 0;
        int element = 0;
        int left_or_right_1 = 0;
        int left_or_right_2 = 0;
        int left_or_right_3 = 0;
        int left_or_right_4 = 0;
        int north_array_1[ 9 ];
        int south_array_1[ 9 ];
        int east_array_1[ 9 ];
        int west_array_1[ 9 ];
        int north_array_2[ 9 ];
        int south_array_2[ 9 ];
        int east_array_2[ 9 ];
        int west_array_2[ 9 ];
    
        int north_array_1_try_2_zero[ 9 ];
        int south_array_1_try_2_zero[ 9 ];
        int east_array_1_try_2_zero[ 9 ];
        int west_array_1_try_2_zero[ 9 ];
    
        int north_array_2_try_2_zero_and_odd[ 9 ];
        int south_array_2_try_2_zero_and_odd[ 9 ];
        int east_array_2_try_2_zero_and_odd[ 9 ];
        int west_array_2_try_2_zero_and_odd[ 9 ];
    
        int north_array_2_try_4_zero_and_even[ 9 ];
        int south_array_2_try_4_zero_and_even[ 9 ];
        int east_array_2_try_4_zero_and_even[ 9 ];
        int west_array_2_try_4_zero_and_even[ 9 ];
    
        int north_array_2_try_5_one_and_odd[ 9 ];
        int south_array_2_try_5_one_and_odd[ 9 ];
        int east_array_2_try_5_one_and_odd[ 9 ];
        int west_array_2_try_5_one_and_odd[ 9 ];
    
        int north_count_1 = 0;
        int south_count_1 = 0;
        int east_count_1 = 0;
        int west_count_1 = 0;
        int north_count_2 = 0;
        int south_count_2 = 0;
        int east_count_2 = 0;
        int west_count_2 = 0;
    
        int north_count_array_2_try_2_zero_and_odd = 0;
        int south_count_array_2_try_2_zero_and_odd = 0;
        int east_count_array_2_try_2_zero_and_odd = 0;
        int west_count_array_2_try_2_zero_and_odd = 0;
    
        int north_count_array_2_try_3_zero_and_odd = 0;
        int south_count_array_2_try_3_zero_and_odd = 0;
        int east_count_array_2_try_3_zero_and_odd = 0;
        int west_count_array_2_try_3_zero_and_odd = 0;
    
        int north_count_array_2_try_4_zero_and_even = 0;
        int south_count_array_2_try_4_zero_and_even = 0;
        int east_count_array_2_try_4_zero_and_even = 0;
        int west_count_array_2_try_4_zero_and_even = 0;
    
        int north_count_array_2_try_5_one_and_odd = 0;
        int south_count_array_2_try_5_one_and_odd = 0;
        int east_count_array_2_try_5_one_and_odd = 0;
        int west_count_array_2_try_5_one_and_odd = 0;
    
        int north_count_array_1_try_2_zero = 0;
        int south_count_array_1_try_2_zero = 0;
        int east_count_array_1_try_2_zero = 0;
        int west_count_array_1_try_2_zero = 0;
    
        int the_number_of_loops = 0;
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting step 1
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 1 begin
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        north_count_1 = testing_four_directions(north_array_1, left_or_right, 0);
        south_count_1 = testing_four_directions(south_array_1, left_or_right, 1);
        east_count_1 = testing_four_directions(east_array_1, left_or_right, 2);
        west_count_1 = testing_four_directions(west_array_1, left_or_right, 3);
    
        cout << '\n';
        feeler = 1;
        element = 0;
    
       direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_1_try_1,
        lowest_value_array_feeler_1_try_1,
        north_array_1,
        south_array_1,
        east_array_1,
        west_array_1,
        feeler_1_lowest_value_array_direction,
        &north_count_1,
        &south_count_1,
        &east_count_1,
        &west_count_1,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_1_try_1[ 0 ] == 0 )
        {
            *feeler_one_element_zero_equal = "feeler_one_element_zero_equal_zero";
    
            cout << '\n';
    
            display_number_of_steps_message(north_count_1,
                                            south_count_1,
                                            east_count_1,
                                            west_count_1,
                                            feeler);
    
            cout << "\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in  the the_master_function_part_one function" << endl;
            }
            else
            {
                file << "\n\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n\n";
            }
    
            file.close();
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_1_try_1[ 0 ] == 1 )
        {
            *feeler_one_element_zero_equal = "feeler_one_element_zero_equal_one";
    
            element = 2;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            setting_feeler_one_element_zero_to_zero ( left_or_right,
                                                         lowest_value_feeler_1_try_2,
                                                         lowest_value_array_feeler_1_try_2,
                                                         north_array_1_try_2_zero,
                                                         south_array_1_try_2_zero,
                                                         east_array_1_try_2_zero,
                                                         west_array_1_try_2_zero,
                                                         feeler_1_lowest_value_array_direction,
                                                         &feeler_2_lowest_value_array_direction,
                                                         &did_second_feeler_work,
                                                         &north_count_array_1_try_2_zero,
                                                         &south_count_array_1_try_2_zero,
                                                         &east_count_array_1_try_2_zero,
                                                         &west_count_array_1_try_2_zero,
                                                         &left_or_right_1,
                                                         &left_or_right_2,
                                                         &left_or_right_3,
                                                         &left_or_right_4,
                                                         &feeler,
                                                         &element,
                                                         &the_number_of_loops);
    
                cout << '\n';
    
                display_number_of_steps_message(north_count_array_1_try_2_zero,
                                                south_count_array_1_try_2_zero,
                                                east_count_array_1_try_2_zero,
                                                west_count_array_1_try_2_zero,
                                                feeler);
    
                cout << '\n';
    
                cout << "\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n";
    
                cout << '\n';
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "\n\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n\n";
                }
    
                file.close();
    
        }
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 1 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 2 begin
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        north_count_2 = testing_four_directions(north_array_2, left_or_right, 4);
        south_count_2 = testing_four_directions(south_array_2, left_or_right, 5);
        east_count_2 = testing_four_directions(east_array_2, left_or_right, 6);
        west_count_2 = testing_four_directions(west_array_2, left_or_right, 7);
    
        cout << '\n';
    
        feeler = 2;
        element = 1;
    
        direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_2_try_1,
        lowest_value_array_feeler_2_try_1,
        north_array_2,
        south_array_2,
        east_array_2,
        west_array_2,
        &feeler_2_lowest_value_array_direction,
        &north_count_2,
        &south_count_2,
        &east_count_2,
        &west_count_2,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_2_try_1[ 0 ] == 0 )
        {
    
            cout << '\n';
    
            display_number_of_steps_message(north_count_2,
                                            south_count_2,
                                            east_count_2,
                                            west_count_2,
                                            feeler);
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_2_try_1[ 0 ] == 1 )
        {
            while ( 1 )
            {
                element = 3;
                left_or_right_1 = 12;
                left_or_right_2 = 13;
                left_or_right_3 = 14;
                left_or_right_4 = 15;
                first_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                   lowest_value_feeler_2_try_2,
                                                                   lowest_value_array_feeler_2_try_2,
                                                                   north_array_2_try_2_zero_and_odd,
                                                                   south_array_2_try_2_zero_and_odd,
                                                                   east_array_2_try_2_zero_and_odd,
                                                                   west_array_2_try_2_zero_and_odd,
                                                                   feeler_1_lowest_value_array_direction,
                                                                   &feeler_2_lowest_value_array_direction,
                                                                   &did_second_feeler_work,
                                                                   &north_count_array_2_try_2_zero_and_odd,
                                                                   &south_count_array_2_try_2_zero_and_odd,
                                                                   &east_count_array_2_try_2_zero_and_odd,
                                                                   &west_count_array_2_try_2_zero_and_odd,
                                                                   &left_or_right_1,
                                                                   &left_or_right_2,
                                                                   &left_or_right_3,
                                                                   &left_or_right_4,
                                                                   &feeler,
                                                                   &element,
                                                                   &the_number_of_loops);
                if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
                {
                        break;
    
                }
            }
    
    
                display_number_of_steps_message(north_count_array_2_try_2_zero_and_odd,
                                                south_count_array_2_try_2_zero_and_odd,
                                                east_count_array_2_try_2_zero_and_odd,
                                                west_count_array_2_try_2_zero_and_odd,
                                                feeler);
        }
    
        //////////
    
        cout << '\n';
    
        //results = testing_if_feeler_one_lowest_value_is_same_direction_as_feeler_two_lowest_value ( lowest_value_feeler,
                                                                                          //&did_second_feeler_work,
                                                                                          //&version);
    
    
    
            if ( lowest_value_feeler_1_try_1[ 0 ] == lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_1[ 0 ] != lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_unequal";
    
            }
    
            else if ( lowest_value_feeler_1_try_2[ 0 ] == lowest_value_feeler_2_try_2 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_2[ 0 ] != lowest_value_feeler_2_try_2 [ 0 ] )
            {
               did_second_feeler_work = "elements_are_unequal";
            }
    
        // running the second feeler again if it didn't fix the block problem the first time.
    ////
        if ( did_second_feeler_work == "elements_are_equal" )
        {
            int north_array_2_try_3_zero_and_odd[ 9 ];
            int lowest_value_array_feeler_2_try_3[ 9 ];
            int south_array_2_try_3_zero_and_odd[ 9 ];
            int east_array_2_try_3_zero_and_odd[ 9 ];
            int west_array_2_try_3_zero_and_odd[ 9 ];
    
            feeler = 2;
            element = 4;
            left_or_right_1 = 16;
            left_or_right_2 = 17;
            left_or_right_3 = 18;
            left_or_right_4 = 19;
            second_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_3,
                                                                  lowest_value_array_feeler_2_try_3,
                                                                  north_array_2_try_3_zero_and_odd,
                                                                  south_array_2_try_3_zero_and_odd,
                                                                  east_array_2_try_3_zero_and_odd,
                                                                  west_array_2_try_3_zero_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_3_zero_and_odd,
                                                                  &south_count_array_2_try_3_zero_and_odd,
                                                                  &east_count_array_2_try_3_zero_and_odd,
                                                                  &west_count_array_2_try_3_zero_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            display_number_of_steps_message(north_count_array_2_try_3_zero_and_odd,
                                        south_count_array_2_try_3_zero_and_odd,
                                        east_count_array_2_try_3_zero_and_odd,
                                        west_count_array_2_try_3_zero_and_odd,
                                        feeler);
        }
    
    
        cout << '\n';
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting feeler 2 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << "The second feeler did something to unblock feeler 1\n\n";
        cout << "Step 1 ended = make feeler 1 and 2 unequal - gain control.\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in  the the_master_function_part_one function" << endl;
            }
            else
            {
                file << "The second feeler did something to unblock feeler 1\n\n";
                file << "Step 1 ended = make feeler 1 and 2 unequal - gain control.\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            }
    
            file.close();
        }
    
    ////
    
    // begin test here
    
    
    
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making the unequal equal again
    
    ////
            feeler = 2;
            element = 5;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            *less_than_node = setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_4,
                                                                lowest_value_array_feeler_2_try_4,
                                                                north_array_2_try_4_zero_and_even,
                                                                south_array_2_try_4_zero_and_even,
                                                                east_array_2_try_4_zero_and_even,
                                                                west_array_2_try_4_zero_and_even,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_4_zero_and_even,
                                                                &south_count_array_2_try_4_zero_and_even,
                                                                &east_count_array_2_try_4_zero_and_even,
                                                                &west_count_array_2_try_4_zero_and_even,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_4_zero_and_even,
                                        south_count_array_2_try_4_zero_and_even,
                                        east_count_array_2_try_4_zero_and_even,
                                        west_count_array_2_try_4_zero_and_even,
                                        feeler);
    
            cout << "Step 2 ended = make feeler 1 and 2 equal - lose control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "Step 2 ended = make feeler 1 and 2 equal - lose control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making equal unequal again.
    ////
            feeler = 3;
            element = 6;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            third_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_5,
                                                                lowest_value_array_feeler_2_try_5,
                                                                north_array_2_try_5_one_and_odd,
                                                                south_array_2_try_5_one_and_odd,
                                                                east_array_2_try_5_one_and_odd,
                                                                west_array_2_try_5_one_and_odd,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_5_one_and_odd,
                                                                &south_count_array_2_try_5_one_and_odd,
                                                                &east_count_array_2_try_5_one_and_odd,
                                                                &west_count_array_2_try_5_one_and_odd,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_5_one_and_odd,
                                        south_count_array_2_try_5_one_and_odd,
                                        east_count_array_2_try_5_one_and_odd,
                                        west_count_array_2_try_5_one_and_odd,
                                        feeler);
    
            cout << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    file << endl;
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << '\n';
    
        *main_north_count = north_count_1;
        *main_south_count = south_count_1;
        *main_east_count = east_count_1;
        *main_west_count = west_count_1;
    
        set_one_string_array_equal_to_another_string_array ( main_left_or_right, left_or_right );
    
        set_one_int_array_equal_to_another_int_array ( main_north_array, north_array_1 );
    
        set_one_int_array_equal_to_another_int_array ( main_south_array, south_array_1 );
    
        set_one_int_array_equal_to_another_int_array ( main_east_array, east_array_1 );
    
        set_one_int_array_equal_to_another_int_array ( main_west_array, west_array_1 );
    }
    
    void the_master_function_part_two ( string lowest_value_feeler_1_try_1[],
                                       string lowest_value_feeler_1_try_2[],
                                       string main_left_or_right[],
                                       int main_north_array[],
                                       int main_south_array[],
                                       int main_east_array[],
                                       int main_west_array[],
                                       string *feeler_one_element_zero_equal,
                                       string *feeler_1_lowest_value_array_direction,
                                       int *main_north_count,
                                       int *main_south_count,
                                       int *main_east_count,
                                       int *main_west_count,
                                       int *less_than_node,
                                       int *result_of_left_node_test)
    {
    
        string left_or_right[ 20 ];
        string lowest_value_feeler_2_try_1[ 9 ];
        string lowest_value_feeler_2_try_2[ 9 ];
        string lowest_value_feeler_2_try_3[ 9 ];
        string lowest_value_feeler_2_try_4[ 9 ];
        string lowest_value_feeler_2_try_6[ 9 ];
        string feeler_2_lowest_value_array_direction = "";
        string did_second_feeler_work = "";
        int lowest_value_array_feeler_2_try_1[ 9 ];
        int lowest_value_array_feeler_2_try_2[ 9 ];
    
        int lowest_value_array_feeler_2_try_4[ 9 ];
        int lowest_value_array_feeler_2_try_6[ 9 ];
        int direction_value = 0;
        int feeler = 0;
        int element = 0;
        int left_or_right_1 = 0;
        int left_or_right_2 = 0;
        int left_or_right_3 = 0;
        int left_or_right_4 = 0;
        int north_array_1[ 9 ];
        int south_array_1[ 9 ];
        int east_array_1[ 9 ];
        int west_array_1[ 9 ];
        int north_array_2[ 9 ];
        int south_array_2[ 9 ];
        int east_array_2[ 9 ];
        int west_array_2[ 9 ];
    
        int north_array_2_try_2_zero_and_odd[ 9 ];
        int south_array_2_try_2_zero_and_odd[ 9 ];
        int east_array_2_try_2_zero_and_odd[ 9 ];
        int west_array_2_try_2_zero_and_odd[ 9 ];
    
        int north_array_2_try_4_zero_and_even[ 9 ];
        int south_array_2_try_4_zero_and_even[ 9 ];
        int east_array_2_try_4_zero_and_even[ 9 ];
        int west_array_2_try_4_zero_and_even[ 9 ];
    
        int north_array_2_try_6_one_and_odd[ 9 ];
        int south_array_2_try_6_one_and_odd[ 9 ];
        int east_array_2_try_6_one_and_odd[ 9 ];
        int west_array_2_try_6_one_and_odd[ 9 ];
    
        int north_element_0[ 9 ];
        int south_element_0[ 9 ];
        int east_element_0[ 9 ];
        int west_element_0[ 9 ];
    
        int north_count_2 = 0;
        int south_count_2 = 0;
        int east_count_2 = 0;
        int west_count_2 = 0;
    
        int north_count_array_2_try_2_zero_and_odd = 0;
        int south_count_array_2_try_2_zero_and_odd = 0;
        int east_count_array_2_try_2_zero_and_odd = 0;
        int west_count_array_2_try_2_zero_and_odd = 0;
    
        int north_count_array_2_try_3_zero_and_odd = 0;
        int south_count_array_2_try_3_zero_and_odd = 0;
        int east_count_array_2_try_3_zero_and_odd = 0;
        int west_count_array_2_try_3_zero_and_odd = 0;
    
        int north_count_array_2_try_4_zero_and_even = 0;
        int south_count_array_2_try_4_zero_and_even = 0;
        int east_count_array_2_try_4_zero_and_even = 0;
        int west_count_array_2_try_4_zero_and_even = 0;
    
        int north_count_array_2_try_6_one_and_odd = 0;
        int south_count_array_2_try_6_one_and_odd = 0;
        int east_count_array_2_try_6_one_and_odd = 0;
        int west_count_array_2_try_6_one_and_odd = 0;
    
        int the_number_of_loops = 0;
        int greater_than_node = 0;
    
        set_array_value_to_zero( north_element_0 );
    
        set_array_value_to_zero( south_element_0 );
    
        set_array_value_to_zero( east_element_0 );
    
        set_array_value_to_zero( west_element_0 );
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting step 1
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        set_one_string_array_equal_to_another_string_array ( left_or_right, main_left_or_right );
    
        set_one_int_array_equal_to_another_int_array ( north_array_1, main_north_array );
    
        set_one_int_array_equal_to_another_int_array ( south_array_1, main_south_array );
    
        set_one_int_array_equal_to_another_int_array ( east_array_1, main_east_array );
    
        set_one_int_array_equal_to_another_int_array ( west_array_1, main_west_array );
    
    
        north_count_2 = testing_four_directions(north_array_2, left_or_right, 4);
        south_count_2 = testing_four_directions(south_array_2, left_or_right, 5);
        east_count_2 = testing_four_directions(east_array_2, left_or_right, 6);
        west_count_2 = testing_four_directions(west_array_2, left_or_right, 7);
        display_number_of_steps_message(north_count_2, south_count_2,east_count_2, west_count_2, 2);
    
        cout << '\n';
    
        feeler = 2;
        element = 1;
    
        direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_2_try_1,
        lowest_value_array_feeler_2_try_1,
        north_array_2,
        south_array_2,
        east_array_2,
        west_array_2,
        &feeler_2_lowest_value_array_direction,
        &north_count_2,
        &south_count_2,
        &east_count_2,
        &west_count_2,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_2_try_1[ 0 ] == 0 )
        {
    
            cout << '\n';
    
            display_number_of_steps_message(north_count_2,
                                            south_count_2,
                                            east_count_2,
                                            west_count_2,
                                            feeler);
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_2_try_1[ 0 ] == 1 )
        {
            while ( 1 )
            {
                element = 3;
                left_or_right_1 = 12;
                left_or_right_2 = 13;
                left_or_right_3 = 14;
                left_or_right_4 = 15;
                first_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                   lowest_value_feeler_2_try_2,
                                                                   lowest_value_array_feeler_2_try_2,
                                                                   north_array_2_try_2_zero_and_odd,
                                                                   south_array_2_try_2_zero_and_odd,
                                                                   east_array_2_try_2_zero_and_odd,
                                                                   west_array_2_try_2_zero_and_odd,
                                                                   feeler_1_lowest_value_array_direction,
                                                                   &feeler_2_lowest_value_array_direction,
                                                                   &did_second_feeler_work,
                                                                   &north_count_array_2_try_2_zero_and_odd,
                                                                   &south_count_array_2_try_2_zero_and_odd,
                                                                   &east_count_array_2_try_2_zero_and_odd,
                                                                   &west_count_array_2_try_2_zero_and_odd,
                                                                   &left_or_right_1,
                                                                   &left_or_right_2,
                                                                   &left_or_right_3,
                                                                   &left_or_right_4,
                                                                   &feeler,
                                                                   &element,
                                                                   &the_number_of_loops);
                if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
                {
                        break;
    
                }
            }
        }
    
        //////////
    
        cout << '\n';
    
        //results = testing_if_feeler_one_lowest_value_is_same_direction_as_feeler_two_lowest_value ( lowest_value_feeler,
                                                                                          //&did_second_feeler_work,
                                                                                          //&version);
    
    
    
            if ( lowest_value_feeler_1_try_1[ 0 ] == lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_1[ 0 ] != lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_unequal";
    
            }
    
            else if ( lowest_value_feeler_1_try_2[ 0 ] == lowest_value_feeler_2_try_2 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_2[ 0 ] != lowest_value_feeler_2_try_2 [ 0 ] )
            {
               did_second_feeler_work = "elements_are_unequal";
    
            }
    
        // running the second feeler again if it didn't fix the block problem the first time.
    ////
        if ( did_second_feeler_work == "elements_are_equal" )
        {
            int lowest_value_array_feeler_2_try_3[ 9 ];
            int north_array_2_try_3_zero_and_odd[ 9 ];
            int south_array_2_try_3_zero_and_odd[ 9 ];
            int east_array_2_try_3_zero_and_odd[ 9 ];
            int west_array_2_try_3_zero_and_odd[ 9 ];
    
            feeler = 2;
            element = 4;
            left_or_right_1 = 16;
            left_or_right_2 = 17;
            left_or_right_3 = 18;
            left_or_right_4 = 19;
            second_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_3,
                                                                  lowest_value_array_feeler_2_try_3,
                                                                  north_array_2_try_3_zero_and_odd,
                                                                  south_array_2_try_3_zero_and_odd,
                                                                  east_array_2_try_3_zero_and_odd,
                                                                  west_array_2_try_3_zero_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_3_zero_and_odd,
                                                                  &south_count_array_2_try_3_zero_and_odd,
                                                                  &east_count_array_2_try_3_zero_and_odd,
                                                                  &west_count_array_2_try_3_zero_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            display_number_of_steps_message(north_count_array_2_try_3_zero_and_odd,
                                        south_count_array_2_try_3_zero_and_odd,
                                        east_count_array_2_try_3_zero_and_odd,
                                        west_count_array_2_try_3_zero_and_odd,
                                        feeler);
        }
    
    
        cout << '\n';
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting feeler 2 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << "The second feeler did something to unblock feeler 1\n\n";
        cout << "Step 4 ended = make feeler 1 and 2 unequal - gain control.\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "The second feeler did something to unblock feeler 1\n\n";
                file << "Step 4 ended = make feeler 1 and 2 unequal - gain control.\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            }
    
            file.close();
        }
    
    ////
    
    // begin test here
    
    
    
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making the unequal equal again
    
    ////
            feeler = 2;
            element = 5;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            greater_than_node = setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_4,
                                                                lowest_value_array_feeler_2_try_4,
                                                                north_array_2_try_4_zero_and_even,
                                                                south_array_2_try_4_zero_and_even,
                                                                east_array_2_try_4_zero_and_even,
                                                                west_array_2_try_4_zero_and_even,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_4_zero_and_even,
                                                                &south_count_array_2_try_4_zero_and_even,
                                                                &east_count_array_2_try_4_zero_and_even,
                                                                &west_count_array_2_try_4_zero_and_even,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_4_zero_and_even,
                                        south_count_array_2_try_4_zero_and_even,
                                        east_count_array_2_try_4_zero_and_even,
                                        west_count_array_2_try_4_zero_and_even,
                                        feeler);
    
            cout << "Step 5 ended = make feeler 1 and 2 equal - lose control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "The second feeler did something to unblock feeler 1\n\n";
                    file << "Step 5 ended = make feeler 1 and 2 unequal - gain control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making equal unequal again.
    ////
            feeler = 3;
            element = 7;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            fourth_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_6,
                                                                  lowest_value_array_feeler_2_try_6,
                                                                  north_array_2_try_6_one_and_odd,
                                                                  south_array_2_try_6_one_and_odd,
                                                                  east_array_2_try_6_one_and_odd,
                                                                  west_array_2_try_6_one_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_6_one_and_odd,
                                                                  &south_count_array_2_try_6_one_and_odd,
                                                                  &east_count_array_2_try_6_one_and_odd,
                                                                  &west_count_array_2_try_6_one_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_6_one_and_odd,
                                        south_count_array_2_try_6_one_and_odd,
                                        east_count_array_2_try_6_one_and_odd,
                                        west_count_array_2_try_6_one_and_odd,
                                        feeler);
    
            cout << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "Step 6 ended = make feeler 1 and 2 unequal - regain control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << '\n';
    
        if ( greater_than_node > *less_than_node )
        {
            cout << "greater than node: " << greater_than_node << ", is greater than less than node: " << *less_than_node << '\n';
            cout << "Added left node, start turning.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is greater than less than node: " << *less_than_node << '\n';
                file << "Added left node, start turning.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 0;
        }
        else if( *less_than_node > greater_than_node )
        {
            cout << "greater than node: " << greater_than_node << ", is not greater than less than node: " << *less_than_node << '\n';
            cout << "Didn\'t add left node, no turning, go straight.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is not greater than less than node: " << *less_than_node << '\n';
                file << "Didn\'t add left node, no turning, go straight.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 1;
        }
        else
        {
            cout << "greater than node: " << greater_than_node << ", is equal to less than node: " << *less_than_node << '\n';
            cout << "Didn\'t add left node, no turning, go straight.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is equal to less than node: " << *less_than_node << '\n';
                file << "Didn\'t add left node, no turning, go straight.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 1;
        }
    }
    
    int main ()
    {
        string lowest_value_feeler_1_try_1[ 9 ];
        string lowest_value_feeler_1_try_2[ 9 ];
        string left_or_right[ 4 ];
        int north_array[ 9 ];
        int south_array[ 9 ];
        int east_array[ 9 ];
        int west_array[ 9 ];
        int compare_to_output_array_1[ 9 ];
        int compare_to_output_array_2[ 9 ];
        int the_random_list_generated_by_the_left_node_results_array[ 9 ];
        string feeler_1_lowest_value_array_direction = "";
        string feeler_one_element_zero_equal = "";
        int north_count_1 = 0;
        int south_count_1 = 0;
        int east_count_1 = 0;
        int west_count_1 = 0;
        int less_than_node = 0;
        int result_of_left_node_test = 0;
        int try_again = 0;
        int good_job = 0;
    
        srand( time( NULL ) );
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            cout << "Starting program\n";
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "Starting program\n\n";
            }
            file.close();
        }
    
        for ( int i = 0; i < 9; i++ )
        {
            // keep the numbers small so they're easy to read
            compare_to_output_array_1[ i ] = rand() % 2;
        }
    
        while ( 1 )
        {
            north_count_1 = 0;
            south_count_1 = 0;
            east_count_1 = 0;
            west_count_1 = 0;
            less_than_node = 0;
            result_of_left_node_test = 0;
            int counting_matching_array_elements_1 = 0;
            int counting_matching_array_elements_2 = 0;
            int counting_left_nodes_1 = 0;
            int counting_left_nodes_2 = 0;
    
            for ( int i = 0; i < 9; i++ )
            {
                the_master_function_part_one(lowest_value_feeler_1_try_1,
                                         lowest_value_feeler_1_try_2,
                                         left_or_right,
                                         north_array,
                                         south_array,
                                         east_array,
                                         west_array,
                                         &feeler_one_element_zero_equal,
                                         &feeler_1_lowest_value_array_direction,
                                         &north_count_1,
                                         &south_count_1,
                                         &east_count_1,
                                         &west_count_1,
                                         &less_than_node);
    
            the_master_function_part_two(lowest_value_feeler_1_try_1,
                                         lowest_value_feeler_1_try_2,
                                         left_or_right,
                                         north_array,
                                         south_array,
                                         east_array,
                                         west_array,
                                         &feeler_one_element_zero_equal,
                                         &feeler_1_lowest_value_array_direction,
                                         &north_count_1,
                                         &south_count_1,
                                         &east_count_1,
                                         &west_count_1,
                                         &less_than_node,
                                         &result_of_left_node_test);
    
            the_random_list_generated_by_the_left_node_results_array[ i ] = result_of_left_node_test;
            }
    
            for ( int i = 0; i < 9; i++ )
            {
                // keep the numbers small so they're easy to read
                compare_to_output_array_2[ i ] = rand() % 2;
            }
    
            for ( int i = 0; i < 9; i++ )
            {
                // counting left nodes in the 2 arrays
                if ( compare_to_output_array_1[ i ] == 0 )
                {
                    counting_left_nodes_1 += 1;
                }
                if ( compare_to_output_array_2[ i ] == 0 )
                {
                    counting_left_nodes_2 += 1;
                }
    
                // comparing the elements of the two arrays to the results array to find matching elements
                if (compare_to_output_array_1[ i ] == the_random_list_generated_by_the_left_node_results_array [ i ] )
                {
                    counting_matching_array_elements_1 += 1;
                }
                if (compare_to_output_array_2[ i ] == the_random_list_generated_by_the_left_node_results_array[ i ] )
                {
                    counting_matching_array_elements_2 += 1;
                }
            }
    
            if ( counting_matching_array_elements_1 > counting_matching_array_elements_2 )
            {
                if ( counting_left_nodes_1 < counting_left_nodes_2 )
                {
    
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was met: Good job!.\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was met: Good job!.\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_1, 9 );
                    good_job += 1;
                    break;
                }
                else
                {
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was not met: Try again.\n\n";
    
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was not met: Try again.\n\n";
    
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_1, 9 );
    
                    try_again += 1;
                }
            }
            else if ( counting_matching_array_elements_2 > counting_matching_array_elements_1 )
            {
                if ( counting_left_nodes_2 < counting_left_nodes_1 )
                {
                    cout << "The goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was met: Good job!.\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "The goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was met: Good job!.\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_2, 9 );
                    good_job += 1;
                    break;
                }
                else
                {
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was not met: Try again.\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was not met: Try again.\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_2, 9 );
                    try_again += 1;
                }
            }
        }
    
        cout << '\n';
        cout << "generated input list 1\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated input list 1\n";
            }
    
            file.close();
        }
    
        displayArray( compare_to_output_array_1, 9 );
        cout << '\n';
        cout << "generated input list 2\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated input list 2\n";
            }
    
            file.close();
        }
    
        displayArray( compare_to_output_array_2, 9 );
        cout << '\n';
        cout << "generated results list\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated results list\n";
            }
    
            file.close();
        }
    
        displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
        cout << "\n\n";
    
        cout << "\n\nscore:\n";
        cout << "Number of times won = " << good_job << '\n';
        cout << "Number of tries until won = " << try_again << '\n';
    
        cout << "\nEnding program\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\n\n";
    
                file << "\n\nscore:\n";
                file << "Number of times won = " << good_job << '\n';
                file << "Number of tries until won = " << try_again << '\n';
    
                file << "\nEnding program\n";
            }
    
            file.close();
        }
    
    
    
        getchar();
    }
    It's 100 percent faster now.
    Last edited by jeremy duncan; 12-14-2015 at 06:32 AM.

  4. #4
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    Thanks a lot! Merry Christmas.

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by jeremy duncan
    How does the srand code look now for srand?
    It is okay, but you could read Prelude's article on using rand() for an example of hashing the bytes of the time_t instead.

    That said, if you are compiling with respect to C++11 or later, you could make use of the new random number facilities in the standard library instead of using srand and rand, or resorting to a third party library like Boost. These provide more options, and rather importantly, you have better control over the PRNG algorithm.

    By the way, avoid posting too many lines of code. Unless they are getting paid for it or have some vested interest (e.g., they are a user of the software), people are not too likely to want to wade through a 3000 line program for you. Yes, 3000 lines is relatively trivial, but often problems can be distilled into much smaller programs (a few hundred lines, maybe even less) that demonstrate the same problem, and these are far more likely to be read and dissected here.
    Last edited by laserlight; 12-14-2015 at 06:47 AM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    I wondered about if I was posting too many lines of code. I will remember that for the next time. Thanks laserlight!

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You're welcome!

    Related to the issue of posting too many lines of code: I noticed that your main function consists of over 400 lines of code. Generally, functions should do one thing and do it well (also known as the single responsibility principle). Typically, a function that is particularly large does too much. The metrics for what is "large" and what is "too much" can be sometimes arbitrary or an art form, and of course depends on your indent style, but unless your function is just hardcoding a whole lot of data, 400 lines is almost certainly too much. I'd say somewhere between 50 to 100 lines would be a good soft limit to keep; some style guides recommend as little as 30 or 40 as the upper limit.

    Another thing that you should do is the declare variables near first use, i.e., try to declare a variable at the point where it can be initialised, or where it will soon after receive a logically valid initial value.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    OK, I fixed the main to be in main and two functions.

    Code:
    int displaying_the_test_results_from_running_the_two_main_function(
                                                                       int compare_to_output_array_1[],
                                                                       int compare_to_output_array_2[],
                                                                       int the_random_list_generated_by_the_left_node_results_array[],
                                                                       int *counting_matching_array_elements_1,
                                                                       int *counting_matching_array_elements_2,
                                                                       int *counting_left_nodes_1,
                                                                       int *counting_left_nodes_2,
                                                                       int *try_again,
                                                                       int *good_job)
    {
        int break_or_not = 0;
        if ( *counting_matching_array_elements_1 > *counting_matching_array_elements_2 )
            {
                if ( *counting_left_nodes_1 < *counting_left_nodes_2 )
                {
    
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was met: Good job!.\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was met: Good job!.\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_1, 9 );
                    *good_job += 1;
                    break_or_not = 1;
                }
                else
                {
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was not met: Try again.\n\n";
    
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was not met: Try again.\n\n";
    
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_1, 9 );
    
                    *try_again += 1;
                }
            }
            else if ( *counting_matching_array_elements_2 > *counting_matching_array_elements_1 )
            {
                if ( *counting_left_nodes_2 < *counting_left_nodes_1 )
                {
                    cout << "The goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was met: Good job!.\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "The goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was met: Good job!.\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_2, 9 );
                    *good_job += 1;
                    break_or_not = 1;
                }
                else
                {
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was not met: Try again.\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was not met: Try again.\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_2, 9 );
                    *try_again += 1;
                }
            }
            return break_or_not;
    }
    
    void running_the_two_main_functions( int compare_to_output_array_1[],
                                        int compare_to_output_array_2[],
                                        int the_random_list_generated_by_the_left_node_results_array[],
                                        int *try_again,
                                        int *good_job )
    {
        string lowest_value_feeler_1_try_1[ 9 ];
        string lowest_value_feeler_1_try_2[ 9 ];
        string left_or_right[ 4 ];
        int north_array[ 9 ];
        int south_array[ 9 ];
        int east_array[ 9 ];
        int west_array[ 9 ];
        string feeler_1_lowest_value_array_direction = "";
        string feeler_one_element_zero_equal = "";
        int north_count_1 = 0;
        int south_count_1 = 0;
        int east_count_1 = 0;
        int west_count_1 = 0;
        int less_than_node = 0;
        int result_of_left_node_test = 0;
    
            while ( 1 )
        {
            north_count_1 = 0;
            south_count_1 = 0;
            east_count_1 = 0;
            west_count_1 = 0;
            less_than_node = 0;
            result_of_left_node_test = 0;
            int counting_matching_array_elements_1 = 0;
            int counting_matching_array_elements_2 = 0;
            int counting_left_nodes_1 = 0;
            int counting_left_nodes_2 = 0;
    
            for ( int i = 0; i < 9; i++ )
            {
                the_master_function_part_one(lowest_value_feeler_1_try_1,
                                         lowest_value_feeler_1_try_2,
                                         left_or_right,
                                         north_array,
                                         south_array,
                                         east_array,
                                         west_array,
                                         &feeler_one_element_zero_equal,
                                         &feeler_1_lowest_value_array_direction,
                                         &north_count_1,
                                         &south_count_1,
                                         &east_count_1,
                                         &west_count_1,
                                         &less_than_node);
    
            the_master_function_part_two(lowest_value_feeler_1_try_1,
                                         lowest_value_feeler_1_try_2,
                                         left_or_right,
                                         north_array,
                                         south_array,
                                         east_array,
                                         west_array,
                                         &feeler_one_element_zero_equal,
                                         &feeler_1_lowest_value_array_direction,
                                         &north_count_1,
                                         &south_count_1,
                                         &east_count_1,
                                         &west_count_1,
                                         &less_than_node,
                                         &result_of_left_node_test);
    
            the_random_list_generated_by_the_left_node_results_array[ i ] = result_of_left_node_test;
            }
    
            for ( int i = 0; i < 9; i++ )
            {
                // keep the numbers small so they're easy to read
                compare_to_output_array_2[ i ] = rand() % 2;
            }
    
            for ( int i = 0; i < 9; i++ )
            {
                // counting left nodes in the 2 arrays
                if ( compare_to_output_array_1[ i ] == 0 )
                {
                    counting_left_nodes_1 += 1;
                }
                if ( compare_to_output_array_2[ i ] == 0 )
                {
                    counting_left_nodes_2 += 1;
                }
    
                // comparing the elements of the two arrays to the results array to find matching elements
                if (compare_to_output_array_1[ i ] == the_random_list_generated_by_the_left_node_results_array [ i ] )
                {
                    counting_matching_array_elements_1 += 1;
                }
                if (compare_to_output_array_2[ i ] == the_random_list_generated_by_the_left_node_results_array[ i ] )
                {
                    counting_matching_array_elements_2 += 1;
                }
            }
    
            int break_or_not = displaying_the_test_results_from_running_the_two_main_function(
                                                                        compare_to_output_array_1,
                                                                        compare_to_output_array_2,
                                                                        the_random_list_generated_by_the_left_node_results_array,
                                                                        &counting_matching_array_elements_1,
                                                                        &counting_matching_array_elements_2,
                                                                        &counting_left_nodes_1,
                                                                        &counting_left_nodes_2,
                                                                        try_again,
                                                                        good_job);
    
            if ( break_or_not == 1 )
            {
                break;
            }
        }
    }
    
    int main ()
    {
        int compare_to_output_array_1[ 9 ];
        int compare_to_output_array_2[ 9 ];
        int the_random_list_generated_by_the_left_node_results_array[ 9 ];
        int try_again = 0;
        int good_job = 0;
    
        srand( time( NULL ) );
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            cout << "Starting program\n";
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "Starting program\n\n";
            }
            file.close();
        }
    
        for ( int i = 0; i < 9; i++ )
        {
            // keep the numbers small so they're easy to read
            compare_to_output_array_1[ i ] = rand() % 2;
        }
    
        running_the_two_main_functions( compare_to_output_array_1,
                                        compare_to_output_array_2,
                                        the_random_list_generated_by_the_left_node_results_array,
                                        &try_again,
                                        &good_job );
    
        cout << '\n';
        cout << "generated input list 1\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated input list 1\n";
            }
    
            file.close();
        }
    
        displayArray( compare_to_output_array_1, 9 );
        cout << '\n';
        cout << "generated input list 2\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated input list 2\n";
            }
    
            file.close();
        }
    
        displayArray( compare_to_output_array_2, 9 );
        cout << '\n';
        cout << "generated results list\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated results list\n";
            }
    
            file.close();
        }
    
        displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
        cout << "\n\n";
    
        cout << "\n\nscore:\n";
        cout << "Number of times won = " << good_job << '\n';
        cout << "Number of tries until won = " << try_again << '\n';
    
        cout << "\nEnding program\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\n\n";
    
                file << "\n\nscore:\n";
                file << "Number of times won = " << good_job << '\n';
                file << "Number of tries until won = " << try_again << '\n';
    
                file << "\nEnding program\n";
            }
    
            file.close();
        }
    
    
    
        getchar();
    }
    I also commented out the beep which made the program 100% faster. So now my program is nice, thanks to you laserlight!

  9. #9
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by jeremy duncan View Post
    I also commented out the beep which made the program 100% faster.
    Have you considered running the beep in a background thread?
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  10. #10
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Jeremy. You've spent a lot of time on this code, I can see that. Be sure that you make a backup so that you can look back over it in a few years.

  11. #11
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    Elkvis, here is a version I made that has sound from beep. I made it because it seemed you wanted to hear the beep so here you go;

    Code:
    #include <cstdlib>
    #include <ctime>
    #include <iostream>
    #include <windows.h> // WinApi header
    #include <cstdio>
    #include <string>
    #include <time.h>
    #include <fstream>
    
    using namespace std;
    
    int findSmallestRemainingElement (int array[], int size, int index);
    void swap (int array[], int first_index, int second_index);
    
    void sort (int array[], int size)
    {
        for ( int i = 0; i < size; i++ )
        {
            int index = findSmallestRemainingElement( array, size, i );
            swap( array, i, index );
        }
    }
    
    int findSmallestRemainingElement (int array[], int size, int index)
    {
        int index_of_smallest_value = index;
        for (int i = index + 1; i < size; i++)
        {
            if ( array[ i ] < array[ index_of_smallest_value ] )
            {
                index_of_smallest_value = i;
            }
        }
        return index_of_smallest_value;
    }
    
    void swap (int array[], int first_index, int second_index)
    {
        int temp = array[ first_index ];
        array[ first_index ] = array[ second_index ];
        array[ second_index ] = temp;
    }
    
    // small helper method to display the before and after arrays
    void displayArray (int array[], int size)
    {
        cout << "{";
        for ( int i = 0; i < size; i++ )
        {
            // you'll see this pattern a lot for nicely formatting
            // lists--check if we're past the first element, and
            // if so, append a comma
            if ( i != 0 )
            {
                cout << ", ";
            }
            cout << array[ i ];
        }
        cout << "}";
    }
    
    void set_array_value_to_zero ( int array[] )
    {
        for ( int i = 0; i < 9; i++ )
        {
            array[ i ] = 0;
        }
    }
    
    void set_one_string_array_equal_to_another_string_array ( string array[], string array2[] )
    {
        for ( int i = 0; i < 4; i++ )
        {
            array[ i ] = array2[ i ];
        }
    }
    
    void set_one_int_array_equal_to_another_int_array ( int array[], int array2[] )
    {
        for ( int i = 0; i < 9; i++ )
        {
            array[ i ] = array2[ i ];
        }
    }
    
    void newSwitch (int array[], int size, int subtracting_this_many_array_elements, int *high, int *medium, int *low)
    {
        for ( int i = size; i-- > subtracting_this_many_array_elements; )
        {
    
            switch(array[i])
            {
                case 8:
                case 7:
                case 6:
                    //cout << "Input: " << i << " too high\n";
                    *high += 1;
                    break;
                case 5:
                case 4:
                case 3:
                    //cout << "Input: " << i << " might be good\n";
                    *medium += 1;
                    break;
                case 2:
                case 1:
                case 0:
                    //cout << "Input: " << i << " is good\n";
                    *low += 1;
                    break;
            }
        }
    }
    
    int which_value_is_largest (int high, int medium, int low)
    {
        int value = 0;
    
        if ( high > medium && high > low && medium > low )
        {
            value = 13;
        }
    
        else if ( high > medium && high > low && medium == low )
        {
            value = 12;
        }
    
        else if ( high > medium && high > low && low > medium )
        {
            value = 11;
        }
    
        else if ( medium > high && medium > low && high > low )
        {
            value = 10;
        }
    
        else if ( medium > high && medium > low && high == low )
        {
            value = 9;
        }
    
        else if ( medium > high && medium > low && low > high )
        {
            value = 8;
        }
    
        else if ( low > medium && low > high && high > medium )
        {
            value = 7;
        }
    
        else if ( low > medium && low > high && high == medium )
        {
            value = 6;
        }
    
        else if ( low > medium && low > high && medium > high )
        {
            value = 5;
        }
    
        else if ( medium == low && high < medium )
        {
            value = 4;
        }
        else if ( high == low && medium < high )
        {
            value = 3;
        }
        else if ( high == medium && low < medium )
        {
            value = 2;
        }
        else
        {
            value = 1;
        }
    
        return value;
    }
    
    int side (int array[], int size, int subtracting_this_many_array_elements)
    {
        int too_high = 0;
        int might_be_good = 0;
        int good_stuff = 0;
    
        int value = 0;
    
        //cout << "____________________________________\n";
    
        //cout << "Original array: ";
        //displayArray( array, size );
        //cout << '\n';
    
        sort( array, size );
    
        //cout << "Sorted array: ";
        //displayArray( array, size );
       // cout << '\n';
        //cout << '\n';
    
        newSwitch( array, size, subtracting_this_many_array_elements, &too_high, &might_be_good, &good_stuff );
    
        //cout << '\n';
    
        //cout << "high counter = " << too_high << '\n';
        //cout << "medium counter = " << might_be_good << '\n';
        //cout << "low counter = " << good_stuff << '\n';
    
        //cout << '\n';
    
        value = which_value_is_largest (too_high, might_be_good, good_stuff);
        //interpreting_whichValueIsLargest(value);
    
        //cout << '\n';
    
        return value;
    }
    
    void randomizing_array_elements ( int array[], int size)
    {
    
        for ( int i = 0; i < size; i++ )
        {
            // keep the numbers small so they're easy to read
            array[ i ] = rand() % 9;
        }
    }
    
    int  do_this_if_left_or_right_is_greater(int array[], string left_or_right[], int *I_took_a_step, int left_side, int right_side, int subtracting_this_many_array_elements, int which_string_element)
    {
        int value = 0;
        //cout << "____________________________________\n";
    
        //cout << "Left side value is: " << left_side << '\n';
        //cout << "Right side value is: " << right_side << '\n';
        //cout << '\n';
    
        if ( left_side > right_side )
        {
            for ( int i = 0; i < 8; i++ )
            {
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
    
                subtracting_this_many_array_elements++;
                left_side = side( array, 9, subtracting_this_many_array_elements );
                //cout << "Left side value is: " << left_side << '\n';
    
                if (left_side <= 3)
                {
                    //cout << "____________________________________\n";
    
                    //cout << "Took a step\n";
                    value = 1;
                    *I_took_a_step += 1;
                    //Beep(1568, 500);
    
                    break;
                }
                else
                {
                    value = 0;
                }
                //cout << '\n';
            }
            left_or_right [ which_string_element ] = "left";
        }
        else if ( right_side > left_side )
        {
            for ( int i = 0; i < 8; i++ )
            {
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
    
                subtracting_this_many_array_elements++;
                right_side = side( array, 9, subtracting_this_many_array_elements );
                //cout << "Right side value is: " << right_side << '\n';
    
                if (right_side <= 3)
                {
                    //cout << "____________________________________\n";
                    //cout << "Took a step\n";
                    value = 1;
                    *I_took_a_step += 1;
                    //Beep(523,500); // 523 hertz (C5) for 500 milliseconds
                    break;
                }
                else
                {
                    value = 0;
                }
    
                //cout << '\n';
            }
            left_or_right [ which_string_element ] = "right";
        }
    
        return value;
    }
    
    int testing_four_directions(int counter[], string left_or_right[], int which_string_element)
    {
        int array[ 9 ];
    
        int I_took_a_step = 0;
    
        int subtracting_this_many_array_elements = 0;
    
        for ( int i = 0; i < 9; i++ )
        {
            set_array_value_to_zero( array );
    
            randomizing_array_elements(array, 9);
            int left_side = side( array, 9 , subtracting_this_many_array_elements);
    
            set_array_value_to_zero( array );
    
            randomizing_array_elements(array, 9);
            int right_side = side( array, 9, subtracting_this_many_array_elements );
    
            while ( left_side == right_side )
            {
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
                left_side = side( array, 9 , subtracting_this_many_array_elements);
    
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
                right_side = side( array, 9, subtracting_this_many_array_elements );
            }
    
            int step_counter = do_this_if_left_or_right_is_greater(array, left_or_right, &I_took_a_step, left_side, right_side, subtracting_this_many_array_elements, which_string_element);
            counter[ i ] = step_counter;
        }
        return I_took_a_step;
    }
    
    
    int which_direction_is_lowest(string lowest_value_feeler[], int north, int south, int east, int west, int feeler, int element)
    {
        int direction_value = 0;
        if ( north < south && north < east && north < west )
        {
            lowest_value_feeler[ element ] = "north";
            direction_value = 1;
        }
        else if ( south < north && south < east && south < west )
        {
            lowest_value_feeler[ element ] = "south";
            direction_value = 2;
        }
        else if ( east < north && east < south && east < west )
        {
            lowest_value_feeler[ element ] = "east";
            direction_value = 3;
        }
        else if ( west < north && west < south && west < east )
        {
            lowest_value_feeler[ element ] = "west";
            direction_value = 4;
        }
        else if ( north == south && north == east && north == west )
        {
            lowest_value_feeler[ element ] = "no_lowest_direction.";
            direction_value = 5;
        }
        else if ( north == east && north == south )
        {
            lowest_value_feeler[ element ] = "north_east_south.";
            direction_value = 6;
        }
        else if ( east == south && east == west )
        {
            lowest_value_feeler[ element ] = "east_south_west.";
            direction_value = 7;
        }
        else if ( south == west && south == north )
        {
            lowest_value_feeler[ element ] = "south_west_north.";
            direction_value = 8;
        }
        else if ( west == north && west == east )
        {
            lowest_value_feeler[ element ] = "west_north_east.";
            direction_value = 9;
        }
        else if ( north == east )
        {
            lowest_value_feeler[ element ] = "north_east.";
            direction_value = 10;
        }
        else if ( east == south )
        {
            lowest_value_feeler[ element ] = "east_south.";
            direction_value = 11;
        }
        else if ( south == west )
        {
            lowest_value_feeler[ element ] = "south_west.";
            direction_value = 12;
        }
        else if ( west == north )
        {
            lowest_value_feeler[ element ] = "west_north.";
            direction_value = 13;
        }
        else if ( west == east )
        {
            lowest_value_feeler[ element ] = "west_east.";
            direction_value = 14;
        }
        else if ( north == south )
        {
            lowest_value_feeler[ element ] = "north_south.";
            direction_value = 15;
        }
        else if ( north == east && north > south && north > west )
        {
            lowest_value_feeler[ element ] = "north_east";
            direction_value = 16;
        }
    
        else if ( north == west && north > east && north > south )
        {
            lowest_value_feeler[ element ] = "north_west";
            direction_value = 17;
        }
        else if ( north == south && north > east && north > west )
        {
            lowest_value_feeler[ element ] = "north_south";
            direction_value = 18;
        }
        else if ( east == west && east > north && east > south )
        {
            lowest_value_feeler[ element ] = "east_west";
            direction_value = 19;
        }
        else if ( east == south && east > north && east > west )
        {
            lowest_value_feeler[ element ] = "east_south";
            direction_value = 20;
        }
        else if ( west == south && west > north && west > east )
        {
            lowest_value_feeler[ element ] = "west_south";
            direction_value = 21;
        }
    
        return direction_value;
    }
    
    void displaying_which_direction_is_lowest( int lowest_value_array[], int direction_value, int feeler )
    {
    
        if ( direction_value == 1 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 2 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 3 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 4 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 5 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south, east, west direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south, east, west direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 6 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east, south direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east, south direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 7 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south, west direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south, west direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 8 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south, west, north direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south, west, north direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 9 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, north, east direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, north, east direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 10 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 11 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 12 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south, west direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south, west direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 13 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, north direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, north direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 14 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, east direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, east direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 15 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 16 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 17 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, west direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, west direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 18 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 19 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, west direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, west direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 20 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 21 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, south direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, south direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
    }
    
    void direction_value_array_transfer_value_to_new_array (int lowest_value_array[],
                                                           string *lowest_value_array_direction,
                                                                      int north[],
                                                                      int south[],
                                                                      int east[],
                                                                      int west[],
                                                                      int *direction_value)
    {
    
        switch( *direction_value )
        {
            case 1:
            case 5:
            case 6:
            case 10:
            case 17:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, north );
                *lowest_value_array_direction = "north";
                break;
    
            case 2:
            case 8:
            case 12:
            case 15:
            case 18:
            case 20:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, south );
                *lowest_value_array_direction = "south";
                break;
    
            case 3:
            case 7:
            case 11:
            case 16:
            case 19:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, east );
                *lowest_value_array_direction = "east";
                break;
    
            case 4:
            case 9:
            case 13:
            case 14:
            case 21:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, west );
                *lowest_value_array_direction = "west";
                break;
        }
    }
    
    void display_number_of_steps_message(int north, int south, int east, int west, int which_feeler)
    {
        cout << "Values with feeler "<< which_feeler << "\n";
        cout << "I tried to take 9 steps in the north direction, but I actual took " << north << " steps.\n";
        cout << "I tried to take 9 steps in the south direction, but I actual took " << south << " steps.\n";
        cout << "I tried to take 9 steps in the east direction, but I actual took " << east << " steps.\n";
        cout << "I tried to take 9 steps in the west direction, but I actual took " << west << " steps.\n";
    
        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
        if( file.fail() )
        {
            cout << "error while opening the file in the display_number_of_steps_message function" << endl;
        }
        else
        {
            file << endl;
            file << "Values with feeler "<< which_feeler << "\n";
            file << "I tried to take 9 steps in the north direction, but I actual took " << north << " steps.\n";
            file << "I tried to take 9 steps in the south direction, but I actual took " << south << " steps.\n";
            file << "I tried to take 9 steps in the east direction, but I actual took " << east << " steps.\n";
            file << "I tried to take 9 steps in the west direction, but I actual took " << west << " steps.\n";
            file << endl;
        }
    
        file.close();
    }
    
    void used_in_setting_feeler_to_new_value ( string left_or_right[],
                                               string lowest_value_feeler[],
                                               int lowest_value_array[],
                                               int north_array[],
                                               int south_array[],
                                               int east_array[],
                                               int west_array[],
                                               string *lowest_value_array_direction,
                                               int *north_count,
                                               int *south_count,
                                               int *east_count,
                                               int *west_count,
                                               int *left_or_right_1,
                                               int *left_or_right_2,
                                               int *left_or_right_3,
                                               int *left_or_right_4,
                                               int *feeler,
                                               int *element )
    {
        int direction_value = 0;
    
        set_array_value_to_zero( north_array );
    
        set_array_value_to_zero( south_array );
    
        set_array_value_to_zero( east_array );
    
        set_array_value_to_zero( west_array );
        set_array_value_to_zero( lowest_value_array );
    
        left_or_right[ *left_or_right_1 ] = "";
        left_or_right[ *left_or_right_2 ] = "";
        left_or_right[ *left_or_right_3 ] = "";
        left_or_right[ *left_or_right_4 ] = "";
    
        *north_count = testing_four_directions(north_array, left_or_right, *left_or_right_1);
        *south_count = testing_four_directions(south_array, left_or_right, *left_or_right_2);
        *east_count = testing_four_directions(east_array, left_or_right, *left_or_right_3);
        *west_count = testing_four_directions(west_array, left_or_right, *left_or_right_4);
        direction_value = which_direction_is_lowest(lowest_value_feeler,
                                                    *north_count,
                                                    *south_count,
                                                    *east_count,
                                                    *west_count,
                                                    *feeler, *element);
    
        direction_value_array_transfer_value_to_new_array ( lowest_value_array,
                                                           lowest_value_array_direction,
                                                            north_array,
                                                            south_array,
                                                            east_array,
                                                            west_array,
                                                            &direction_value);
    
        displaying_which_direction_is_lowest( lowest_value_array, direction_value, *feeler );
    
    
    }
    
    void fourth_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_6[],
                                                              int lowest_value_array_feeler_2_try_6[],
                                                              int north_array_2_try_6_one_and_odd[],
                                                              int south_array_2_try_6_one_and_odd[],
                                                              int east_array_2_try_6_one_and_odd[],
                                                              int west_array_2_try_6_one_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_6_one_and_odd,
                                                              int *south_count_array_2_try_6_one_and_odd,
                                                              int *east_count_array_2_try_6_one_and_odd,
                                                              int *west_count_array_2_try_6_one_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_6,
                                                  lowest_value_array_feeler_2_try_6,
                                                  north_array_2_try_6_one_and_odd,
                                                  south_array_2_try_6_one_and_odd,
                                                  east_array_2_try_6_one_and_odd,
                                                  west_array_2_try_6_one_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_6_one_and_odd,
                                                  south_count_array_2_try_6_one_and_odd,
                                                  east_count_array_2_try_6_one_and_odd,
                                                  west_count_array_2_try_6_one_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_6[ 0 ] == 1)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    
    
    }
    
    void third_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_5[],
                                                              int lowest_value_array_feeler_2_try_5[],
                                                              int north_array_2_try_5_one_and_odd[],
                                                              int south_array_2_try_5_one_and_odd[],
                                                              int east_array_2_try_5_one_and_odd[],
                                                              int west_array_2_try_5_one_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_5_one_and_odd,
                                                              int *south_count_array_2_try_5_one_and_odd,
                                                              int *east_count_array_2_try_5_one_and_odd,
                                                              int *west_count_array_2_try_5_one_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_5,
                                                  lowest_value_array_feeler_2_try_5,
                                                  north_array_2_try_5_one_and_odd,
                                                  south_array_2_try_5_one_and_odd,
                                                  east_array_2_try_5_one_and_odd,
                                                  west_array_2_try_5_one_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_5_one_and_odd,
                                                  south_count_array_2_try_5_one_and_odd,
                                                  east_count_array_2_try_5_one_and_odd,
                                                  west_count_array_2_try_5_one_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_5[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    
    
    }
    
    int setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( string left_or_right[],
                                                               string lowest_value_feeler_2_try_4[],
                                                               int lowest_value_array_feeler_2_try_4[],
                                                               int north_array_2_try_4_zero_and_even[],
                                                               int south_array_2_try_4_zero_and_even[],
                                                               int east_array_2_try_4_zero_and_even[],
                                                               int west_array_2_try_4_zero_and_even[],
                                                               string *feeler_1_lowest_value_array_direction,
                                                               string *feeler_2_lowest_value_array_direction,
                                                               string *did_second_feeler_work,
                                                               int *north_count_array_2_try_4_zero_and_even,
                                                               int *south_count_array_2_try_4_zero_and_even,
                                                               int *east_count_array_2_try_4_zero_and_even,
                                                               int *west_count_array_2_try_4_zero_and_even,
                                                               int *left_or_right_1,
                                                               int *left_or_right_2,
                                                               int *left_or_right_3,
                                                               int *left_or_right_4,
                                                               int *feeler,
                                                               int *element,
                                                               int *the_number_of_loops)
    {
        int counter = 0;
        while ( 1 )
        {
            counter = counter + 1;
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                      lowest_value_feeler_2_try_4,
                                                      lowest_value_array_feeler_2_try_4,
                                                      north_array_2_try_4_zero_and_even,
                                                      south_array_2_try_4_zero_and_even,
                                                      east_array_2_try_4_zero_and_even,
                                                      west_array_2_try_4_zero_and_even,
                                                      feeler_2_lowest_value_array_direction,
                                                      north_count_array_2_try_4_zero_and_even,
                                                      south_count_array_2_try_4_zero_and_even,
                                                      east_count_array_2_try_4_zero_and_even,
                                                      west_count_array_2_try_4_zero_and_even,
                                                      left_or_right_1,
                                                      left_or_right_2,
                                                      left_or_right_3,
                                                      left_or_right_4,
                                                      feeler,
                                                      element );
    
                if ( lowest_value_array_feeler_2_try_4[ 0 ] == 0)
                {
                    if ( *feeler_2_lowest_value_array_direction ==  *feeler_1_lowest_value_array_direction )
                    {
                        *the_number_of_loops += 1;
                        *did_second_feeler_work = "elements_are_equal";
    
                        return counter;
                    }
                }
                else
                {
                   *the_number_of_loops += 1;
                   *did_second_feeler_work = "elements_are_unequal";
                }
        }
    }
    
    void second_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                               string lowest_value_feeler_2_try_3[],
                                                               int lowest_value_array_feeler_2_try_3[],
                                                               int north_array_2_try_3_zero_and_odd[],
                                                               int south_array_2_try_3_zero_and_odd[],
                                                               int east_array_2_try_3_zero_and_odd[],
                                                               int west_array_2_try_3_zero_and_odd[],
                                                               string *feeler_1_lowest_value_array_direction,
                                                               string *feeler_2_lowest_value_array_direction,
                                                               string *did_second_feeler_work,
                                                               int *north_count_array_2_try_3_zero_and_odd,
                                                               int *south_count_array_2_try_3_zero_and_odd,
                                                               int *east_count_array_2_try_3_zero_and_odd,
                                                               int *west_count_array_2_try_3_zero_and_odd,
                                                               int *left_or_right_1,
                                                               int *left_or_right_2,
                                                               int *left_or_right_3,
                                                               int *left_or_right_4,
                                                               int *feeler,
                                                               int *element,
                                                               int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_3,
                                                  lowest_value_array_feeler_2_try_3,
                                                  north_array_2_try_3_zero_and_odd,
                                                  south_array_2_try_3_zero_and_odd,
                                                  east_array_2_try_3_zero_and_odd,
                                                  west_array_2_try_3_zero_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_3_zero_and_odd,
                                                  south_count_array_2_try_3_zero_and_odd,
                                                  east_count_array_2_try_3_zero_and_odd,
                                                  west_count_array_2_try_3_zero_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_3[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
    
            }
        }
    }
    
    void first_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_2[],
                                                              int lowest_value_array_feeler_2_try_2[],
                                                              int north_array_2_try_2_zero_and_odd[],
                                                              int south_array_2_try_2_zero_and_odd[],
                                                              int east_array_2_try_2_zero_and_odd[],
                                                              int west_array_2_try_2_zero_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_2_zero_and_odd,
                                                              int *south_count_array_2_try_2_zero_and_odd,
                                                              int *east_count_array_2_try_2_zero_and_odd,
                                                              int *west_count_array_2_try_2_zero_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    
    
    
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_2,
                                                  lowest_value_array_feeler_2_try_2,
                                                  north_array_2_try_2_zero_and_odd,
                                                  south_array_2_try_2_zero_and_odd,
                                                  east_array_2_try_2_zero_and_odd,
                                                  west_array_2_try_2_zero_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_2_zero_and_odd,
                                                  south_count_array_2_try_2_zero_and_odd,
                                                  east_count_array_2_try_2_zero_and_odd,
                                                  west_count_array_2_try_2_zero_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                   *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    }
    
    void setting_feeler_one_element_zero_to_zero ( string left_or_right[],
                                                      string lowest_value_feeler[],
                                                      int lowest_value_array[],
                                                      int north_array_1_try_2_zero[],
                                                      int south_array_1_try_2_zero[],
                                                      int east_array_1_try_2_zero[],
                                                      int west_array_1_try_2_zero[],
                                                      string *feeler_1_lowest_value_array_direction,
                                                      string *feeler_2_lowest_value_array_direction,
                                                      string *did_second_feeler_work,
                                                      int *north_count_array_1_try_2_zero,
                                                      int *south_count_array_1_try_2_zero,
                                                      int *east_count_array_1_try_2_zero,
                                                      int *west_count_array_1_try_2_zero,
                                                      int *left_or_right_1,
                                                      int *left_or_right_2,
                                                      int *left_or_right_3,
                                                      int *left_or_right_4,
                                                      int *feeler,
                                                      int *element,
                                                      int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler,
                                                  lowest_value_array,
                                                  north_array_1_try_2_zero,
                                                  south_array_1_try_2_zero,
                                                  east_array_1_try_2_zero,
                                                  west_array_1_try_2_zero,
                                                  feeler_1_lowest_value_array_direction,
                                                  north_count_array_1_try_2_zero,
                                                  south_count_array_1_try_2_zero,
                                                  east_count_array_1_try_2_zero,
                                                  west_count_array_1_try_2_zero,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
    
    
            if ( lowest_value_array[ 0 ] == 0 )
            {
                break;
            }
        }
    }
    
    void direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest( string lowest_value_feeler[],
                                                                                                                                             int lowest_value_array[],
                                          int north_array[],
                                          int south_array[],
                                          int east_array[],
                                          int west_array[],
                                          string *lowest_value_array_direction,
                                          int *north_count,
                                          int *south_count,
                                          int *east_count,
                                          int *west_count,
                                          int *feeler,
                                          int *element,
                                          int *direction_value )
    {
    
        *direction_value = which_direction_is_lowest(lowest_value_feeler,
                                                    *north_count,
                                                    *south_count,
                                                    *east_count,
                                                    *west_count,
                                                    *feeler,
                                                    *element);
    
        direction_value_array_transfer_value_to_new_array ( lowest_value_array,
                                                           lowest_value_array_direction,
                                                            north_array,
                                                            south_array,
                                                            east_array,
                                                            west_array,
                                                            direction_value);
    
        displaying_which_direction_is_lowest( lowest_value_array, *direction_value, *feeler );
    
    }
    
    void the_master_function_part_one ( string lowest_value_feeler_1_try_1[],
                                       string lowest_value_feeler_1_try_2[],
                                       string main_left_or_right[],
                                       int main_north_array[],
                                       int main_south_array[],
                                       int main_east_array[],
                                       int main_west_array[],
                                       string *feeler_one_element_zero_equal,
                                       string *feeler_1_lowest_value_array_direction,
                                       int *main_north_count,
                                       int *main_south_count,
                                       int *main_east_count,
                                       int *main_west_count,
                                       int *less_than_node)
    {
        string left_or_right[ 20 ];
        string lowest_value_feeler_2_try_1[ 9 ];
        string lowest_value_feeler_2_try_2[ 9 ];
        string lowest_value_feeler_2_try_3[ 9 ];
        string lowest_value_feeler_2_try_4[ 9 ];
        string lowest_value_feeler_2_try_5[ 9 ];
        string feeler_2_lowest_value_array_direction = "";
        string did_second_feeler_work = "";
        int lowest_value_array_feeler_1_try_1[ 9 ];
        int lowest_value_array_feeler_1_try_2[ 9 ];
        int lowest_value_array_feeler_2_try_1[ 9 ];
        int lowest_value_array_feeler_2_try_2[ 9 ];
        int lowest_value_array_feeler_2_try_4[ 9 ];
        int lowest_value_array_feeler_2_try_5[ 9 ];
        int direction_value = 0;
        int feeler = 0;
        int element = 0;
        int left_or_right_1 = 0;
        int left_or_right_2 = 0;
        int left_or_right_3 = 0;
        int left_or_right_4 = 0;
        int north_array_1[ 9 ];
        int south_array_1[ 9 ];
        int east_array_1[ 9 ];
        int west_array_1[ 9 ];
        int north_array_2[ 9 ];
        int south_array_2[ 9 ];
        int east_array_2[ 9 ];
        int west_array_2[ 9 ];
    
        int north_array_1_try_2_zero[ 9 ];
        int south_array_1_try_2_zero[ 9 ];
        int east_array_1_try_2_zero[ 9 ];
        int west_array_1_try_2_zero[ 9 ];
    
        int north_array_2_try_2_zero_and_odd[ 9 ];
        int south_array_2_try_2_zero_and_odd[ 9 ];
        int east_array_2_try_2_zero_and_odd[ 9 ];
        int west_array_2_try_2_zero_and_odd[ 9 ];
    
        int north_array_2_try_4_zero_and_even[ 9 ];
        int south_array_2_try_4_zero_and_even[ 9 ];
        int east_array_2_try_4_zero_and_even[ 9 ];
        int west_array_2_try_4_zero_and_even[ 9 ];
    
        int north_array_2_try_5_one_and_odd[ 9 ];
        int south_array_2_try_5_one_and_odd[ 9 ];
        int east_array_2_try_5_one_and_odd[ 9 ];
        int west_array_2_try_5_one_and_odd[ 9 ];
    
        int north_count_1 = 0;
        int south_count_1 = 0;
        int east_count_1 = 0;
        int west_count_1 = 0;
        int north_count_2 = 0;
        int south_count_2 = 0;
        int east_count_2 = 0;
        int west_count_2 = 0;
    
        int north_count_array_2_try_2_zero_and_odd = 0;
        int south_count_array_2_try_2_zero_and_odd = 0;
        int east_count_array_2_try_2_zero_and_odd = 0;
        int west_count_array_2_try_2_zero_and_odd = 0;
    
        int north_count_array_2_try_3_zero_and_odd = 0;
        int south_count_array_2_try_3_zero_and_odd = 0;
        int east_count_array_2_try_3_zero_and_odd = 0;
        int west_count_array_2_try_3_zero_and_odd = 0;
    
        int north_count_array_2_try_4_zero_and_even = 0;
        int south_count_array_2_try_4_zero_and_even = 0;
        int east_count_array_2_try_4_zero_and_even = 0;
        int west_count_array_2_try_4_zero_and_even = 0;
    
        int north_count_array_2_try_5_one_and_odd = 0;
        int south_count_array_2_try_5_one_and_odd = 0;
        int east_count_array_2_try_5_one_and_odd = 0;
        int west_count_array_2_try_5_one_and_odd = 0;
    
        int north_count_array_1_try_2_zero = 0;
        int south_count_array_1_try_2_zero = 0;
        int east_count_array_1_try_2_zero = 0;
        int west_count_array_1_try_2_zero = 0;
    
        int the_number_of_loops = 0;
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting step 1
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 1 begin
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        north_count_1 = testing_four_directions(north_array_1, left_or_right, 0);
        south_count_1 = testing_four_directions(south_array_1, left_or_right, 1);
        east_count_1 = testing_four_directions(east_array_1, left_or_right, 2);
        west_count_1 = testing_four_directions(west_array_1, left_or_right, 3);
    
        cout << '\n';
        feeler = 1;
        element = 0;
    
       direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_1_try_1,
        lowest_value_array_feeler_1_try_1,
        north_array_1,
        south_array_1,
        east_array_1,
        west_array_1,
        feeler_1_lowest_value_array_direction,
        &north_count_1,
        &south_count_1,
        &east_count_1,
        &west_count_1,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_1_try_1[ 0 ] == 0 )
        {
            *feeler_one_element_zero_equal = "feeler_one_element_zero_equal_zero";
    
            cout << '\n';
    
            display_number_of_steps_message(north_count_1,
                                            south_count_1,
                                            east_count_1,
                                            west_count_1,
                                            feeler);
    
            cout << "\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in  the the_master_function_part_one function" << endl;
            }
            else
            {
                file << "\n\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n\n";
            }
    
            file.close();
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_1_try_1[ 0 ] == 1 )
        {
            *feeler_one_element_zero_equal = "feeler_one_element_zero_equal_one";
    
            element = 2;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            setting_feeler_one_element_zero_to_zero ( left_or_right,
                                                         lowest_value_feeler_1_try_2,
                                                         lowest_value_array_feeler_1_try_2,
                                                         north_array_1_try_2_zero,
                                                         south_array_1_try_2_zero,
                                                         east_array_1_try_2_zero,
                                                         west_array_1_try_2_zero,
                                                         feeler_1_lowest_value_array_direction,
                                                         &feeler_2_lowest_value_array_direction,
                                                         &did_second_feeler_work,
                                                         &north_count_array_1_try_2_zero,
                                                         &south_count_array_1_try_2_zero,
                                                         &east_count_array_1_try_2_zero,
                                                         &west_count_array_1_try_2_zero,
                                                         &left_or_right_1,
                                                         &left_or_right_2,
                                                         &left_or_right_3,
                                                         &left_or_right_4,
                                                         &feeler,
                                                         &element,
                                                         &the_number_of_loops);
    
                cout << '\n';
    
                display_number_of_steps_message(north_count_array_1_try_2_zero,
                                                south_count_array_1_try_2_zero,
                                                east_count_array_1_try_2_zero,
                                                west_count_array_1_try_2_zero,
                                                feeler);
    
                cout << '\n';
    
                cout << "\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n";
    
                cout << '\n';
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "\n\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n\n";
                }
    
                file.close();
    
        }
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 1 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 2 begin
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        north_count_2 = testing_four_directions(north_array_2, left_or_right, 4);
        south_count_2 = testing_four_directions(south_array_2, left_or_right, 5);
        east_count_2 = testing_four_directions(east_array_2, left_or_right, 6);
        west_count_2 = testing_four_directions(west_array_2, left_or_right, 7);
    
        cout << '\n';
    
        feeler = 2;
        element = 1;
    
        direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_2_try_1,
        lowest_value_array_feeler_2_try_1,
        north_array_2,
        south_array_2,
        east_array_2,
        west_array_2,
        &feeler_2_lowest_value_array_direction,
        &north_count_2,
        &south_count_2,
        &east_count_2,
        &west_count_2,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_2_try_1[ 0 ] == 0 )
        {
    
            cout << '\n';
    
            display_number_of_steps_message(north_count_2,
                                            south_count_2,
                                            east_count_2,
                                            west_count_2,
                                            feeler);
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_2_try_1[ 0 ] == 1 )
        {
            while ( 1 )
            {
                element = 3;
                left_or_right_1 = 12;
                left_or_right_2 = 13;
                left_or_right_3 = 14;
                left_or_right_4 = 15;
                first_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                   lowest_value_feeler_2_try_2,
                                                                   lowest_value_array_feeler_2_try_2,
                                                                   north_array_2_try_2_zero_and_odd,
                                                                   south_array_2_try_2_zero_and_odd,
                                                                   east_array_2_try_2_zero_and_odd,
                                                                   west_array_2_try_2_zero_and_odd,
                                                                   feeler_1_lowest_value_array_direction,
                                                                   &feeler_2_lowest_value_array_direction,
                                                                   &did_second_feeler_work,
                                                                   &north_count_array_2_try_2_zero_and_odd,
                                                                   &south_count_array_2_try_2_zero_and_odd,
                                                                   &east_count_array_2_try_2_zero_and_odd,
                                                                   &west_count_array_2_try_2_zero_and_odd,
                                                                   &left_or_right_1,
                                                                   &left_or_right_2,
                                                                   &left_or_right_3,
                                                                   &left_or_right_4,
                                                                   &feeler,
                                                                   &element,
                                                                   &the_number_of_loops);
                if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
                {
                        break;
    
                }
            }
    
    
                display_number_of_steps_message(north_count_array_2_try_2_zero_and_odd,
                                                south_count_array_2_try_2_zero_and_odd,
                                                east_count_array_2_try_2_zero_and_odd,
                                                west_count_array_2_try_2_zero_and_odd,
                                                feeler);
        }
    
        //////////
    
        cout << '\n';
    
        //results = testing_if_feeler_one_lowest_value_is_same_direction_as_feeler_two_lowest_value ( lowest_value_feeler,
                                                                                          //&did_second_feeler_work,
                                                                                          //&version);
    
    
    
            if ( lowest_value_feeler_1_try_1[ 0 ] == lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_1[ 0 ] != lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_unequal";
    
            }
    
            else if ( lowest_value_feeler_1_try_2[ 0 ] == lowest_value_feeler_2_try_2 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_2[ 0 ] != lowest_value_feeler_2_try_2 [ 0 ] )
            {
               did_second_feeler_work = "elements_are_unequal";
            }
    
        // running the second feeler again if it didn't fix the block problem the first time.
    ////
        if ( did_second_feeler_work == "elements_are_equal" )
        {
            int north_array_2_try_3_zero_and_odd[ 9 ];
            int lowest_value_array_feeler_2_try_3[ 9 ];
            int south_array_2_try_3_zero_and_odd[ 9 ];
            int east_array_2_try_3_zero_and_odd[ 9 ];
            int west_array_2_try_3_zero_and_odd[ 9 ];
    
            feeler = 2;
            element = 4;
            left_or_right_1 = 16;
            left_or_right_2 = 17;
            left_or_right_3 = 18;
            left_or_right_4 = 19;
            second_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_3,
                                                                  lowest_value_array_feeler_2_try_3,
                                                                  north_array_2_try_3_zero_and_odd,
                                                                  south_array_2_try_3_zero_and_odd,
                                                                  east_array_2_try_3_zero_and_odd,
                                                                  west_array_2_try_3_zero_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_3_zero_and_odd,
                                                                  &south_count_array_2_try_3_zero_and_odd,
                                                                  &east_count_array_2_try_3_zero_and_odd,
                                                                  &west_count_array_2_try_3_zero_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            display_number_of_steps_message(north_count_array_2_try_3_zero_and_odd,
                                        south_count_array_2_try_3_zero_and_odd,
                                        east_count_array_2_try_3_zero_and_odd,
                                        west_count_array_2_try_3_zero_and_odd,
                                        feeler);
        }
    
    
        cout << '\n';
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting feeler 2 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << "The second feeler did something to unblock feeler 1\n\n";
        cout << "Step 1 ended = make feeler 1 and 2 unequal - gain control.\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in  the the_master_function_part_one function" << endl;
            }
            else
            {
                file << "The second feeler did something to unblock feeler 1\n\n";
                file << "Step 1 ended = make feeler 1 and 2 unequal - gain control.\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            }
    
            file.close();
        }
    
    ////
    
    // begin test here
    
    
    
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making the unequal equal again
    
    ////
            feeler = 2;
            element = 5;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            *less_than_node = setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_4,
                                                                lowest_value_array_feeler_2_try_4,
                                                                north_array_2_try_4_zero_and_even,
                                                                south_array_2_try_4_zero_and_even,
                                                                east_array_2_try_4_zero_and_even,
                                                                west_array_2_try_4_zero_and_even,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_4_zero_and_even,
                                                                &south_count_array_2_try_4_zero_and_even,
                                                                &east_count_array_2_try_4_zero_and_even,
                                                                &west_count_array_2_try_4_zero_and_even,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_4_zero_and_even,
                                        south_count_array_2_try_4_zero_and_even,
                                        east_count_array_2_try_4_zero_and_even,
                                        west_count_array_2_try_4_zero_and_even,
                                        feeler);
    
            cout << "Step 2 ended = make feeler 1 and 2 equal - lose control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "Step 2 ended = make feeler 1 and 2 equal - lose control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making equal unequal again.
    ////
            feeler = 3;
            element = 6;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            third_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_5,
                                                                lowest_value_array_feeler_2_try_5,
                                                                north_array_2_try_5_one_and_odd,
                                                                south_array_2_try_5_one_and_odd,
                                                                east_array_2_try_5_one_and_odd,
                                                                west_array_2_try_5_one_and_odd,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_5_one_and_odd,
                                                                &south_count_array_2_try_5_one_and_odd,
                                                                &east_count_array_2_try_5_one_and_odd,
                                                                &west_count_array_2_try_5_one_and_odd,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_5_one_and_odd,
                                        south_count_array_2_try_5_one_and_odd,
                                        east_count_array_2_try_5_one_and_odd,
                                        west_count_array_2_try_5_one_and_odd,
                                        feeler);
    
            cout << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    file << endl;
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << '\n';
    
        *main_north_count = north_count_1;
        *main_south_count = south_count_1;
        *main_east_count = east_count_1;
        *main_west_count = west_count_1;
    
        set_one_string_array_equal_to_another_string_array ( main_left_or_right, left_or_right );
    
        set_one_int_array_equal_to_another_int_array ( main_north_array, north_array_1 );
    
        set_one_int_array_equal_to_another_int_array ( main_south_array, south_array_1 );
    
        set_one_int_array_equal_to_another_int_array ( main_east_array, east_array_1 );
    
        set_one_int_array_equal_to_another_int_array ( main_west_array, west_array_1 );
    }
    
    void the_master_function_part_two ( string lowest_value_feeler_1_try_1[],
                                       string lowest_value_feeler_1_try_2[],
                                       string main_left_or_right[],
                                       int main_north_array[],
                                       int main_south_array[],
                                       int main_east_array[],
                                       int main_west_array[],
                                       string *feeler_one_element_zero_equal,
                                       string *feeler_1_lowest_value_array_direction,
                                       int *main_north_count,
                                       int *main_south_count,
                                       int *main_east_count,
                                       int *main_west_count,
                                       int *less_than_node,
                                       int *result_of_left_node_test)
    {
    
        string left_or_right[ 20 ];
        string lowest_value_feeler_2_try_1[ 9 ];
        string lowest_value_feeler_2_try_2[ 9 ];
        string lowest_value_feeler_2_try_3[ 9 ];
        string lowest_value_feeler_2_try_4[ 9 ];
        string lowest_value_feeler_2_try_6[ 9 ];
        string feeler_2_lowest_value_array_direction = "";
        string did_second_feeler_work = "";
        int lowest_value_array_feeler_2_try_1[ 9 ];
        int lowest_value_array_feeler_2_try_2[ 9 ];
    
        int lowest_value_array_feeler_2_try_4[ 9 ];
        int lowest_value_array_feeler_2_try_6[ 9 ];
        int direction_value = 0;
        int feeler = 0;
        int element = 0;
        int left_or_right_1 = 0;
        int left_or_right_2 = 0;
        int left_or_right_3 = 0;
        int left_or_right_4 = 0;
        int north_array_1[ 9 ];
        int south_array_1[ 9 ];
        int east_array_1[ 9 ];
        int west_array_1[ 9 ];
        int north_array_2[ 9 ];
        int south_array_2[ 9 ];
        int east_array_2[ 9 ];
        int west_array_2[ 9 ];
    
        int north_array_2_try_2_zero_and_odd[ 9 ];
        int south_array_2_try_2_zero_and_odd[ 9 ];
        int east_array_2_try_2_zero_and_odd[ 9 ];
        int west_array_2_try_2_zero_and_odd[ 9 ];
    
        int north_array_2_try_4_zero_and_even[ 9 ];
        int south_array_2_try_4_zero_and_even[ 9 ];
        int east_array_2_try_4_zero_and_even[ 9 ];
        int west_array_2_try_4_zero_and_even[ 9 ];
    
        int north_array_2_try_6_one_and_odd[ 9 ];
        int south_array_2_try_6_one_and_odd[ 9 ];
        int east_array_2_try_6_one_and_odd[ 9 ];
        int west_array_2_try_6_one_and_odd[ 9 ];
    
        int north_element_0[ 9 ];
        int south_element_0[ 9 ];
        int east_element_0[ 9 ];
        int west_element_0[ 9 ];
    
        int north_count_2 = 0;
        int south_count_2 = 0;
        int east_count_2 = 0;
        int west_count_2 = 0;
    
        int north_count_array_2_try_2_zero_and_odd = 0;
        int south_count_array_2_try_2_zero_and_odd = 0;
        int east_count_array_2_try_2_zero_and_odd = 0;
        int west_count_array_2_try_2_zero_and_odd = 0;
    
        int north_count_array_2_try_3_zero_and_odd = 0;
        int south_count_array_2_try_3_zero_and_odd = 0;
        int east_count_array_2_try_3_zero_and_odd = 0;
        int west_count_array_2_try_3_zero_and_odd = 0;
    
        int north_count_array_2_try_4_zero_and_even = 0;
        int south_count_array_2_try_4_zero_and_even = 0;
        int east_count_array_2_try_4_zero_and_even = 0;
        int west_count_array_2_try_4_zero_and_even = 0;
    
        int north_count_array_2_try_6_one_and_odd = 0;
        int south_count_array_2_try_6_one_and_odd = 0;
        int east_count_array_2_try_6_one_and_odd = 0;
        int west_count_array_2_try_6_one_and_odd = 0;
    
        int the_number_of_loops = 0;
        int greater_than_node = 0;
    
        set_array_value_to_zero( north_element_0 );
    
        set_array_value_to_zero( south_element_0 );
    
        set_array_value_to_zero( east_element_0 );
    
        set_array_value_to_zero( west_element_0 );
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting step 1
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        set_one_string_array_equal_to_another_string_array ( left_or_right, main_left_or_right );
    
        set_one_int_array_equal_to_another_int_array ( north_array_1, main_north_array );
    
        set_one_int_array_equal_to_another_int_array ( south_array_1, main_south_array );
    
        set_one_int_array_equal_to_another_int_array ( east_array_1, main_east_array );
    
        set_one_int_array_equal_to_another_int_array ( west_array_1, main_west_array );
    
    
        north_count_2 = testing_four_directions(north_array_2, left_or_right, 4);
        south_count_2 = testing_four_directions(south_array_2, left_or_right, 5);
        east_count_2 = testing_four_directions(east_array_2, left_or_right, 6);
        west_count_2 = testing_four_directions(west_array_2, left_or_right, 7);
        display_number_of_steps_message(north_count_2, south_count_2,east_count_2, west_count_2, 2);
    
        cout << '\n';
    
        feeler = 2;
        element = 1;
    
        direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_2_try_1,
        lowest_value_array_feeler_2_try_1,
        north_array_2,
        south_array_2,
        east_array_2,
        west_array_2,
        &feeler_2_lowest_value_array_direction,
        &north_count_2,
        &south_count_2,
        &east_count_2,
        &west_count_2,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_2_try_1[ 0 ] == 0 )
        {
    
            cout << '\n';
    
            display_number_of_steps_message(north_count_2,
                                            south_count_2,
                                            east_count_2,
                                            west_count_2,
                                            feeler);
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_2_try_1[ 0 ] == 1 )
        {
            while ( 1 )
            {
                element = 3;
                left_or_right_1 = 12;
                left_or_right_2 = 13;
                left_or_right_3 = 14;
                left_or_right_4 = 15;
                first_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                   lowest_value_feeler_2_try_2,
                                                                   lowest_value_array_feeler_2_try_2,
                                                                   north_array_2_try_2_zero_and_odd,
                                                                   south_array_2_try_2_zero_and_odd,
                                                                   east_array_2_try_2_zero_and_odd,
                                                                   west_array_2_try_2_zero_and_odd,
                                                                   feeler_1_lowest_value_array_direction,
                                                                   &feeler_2_lowest_value_array_direction,
                                                                   &did_second_feeler_work,
                                                                   &north_count_array_2_try_2_zero_and_odd,
                                                                   &south_count_array_2_try_2_zero_and_odd,
                                                                   &east_count_array_2_try_2_zero_and_odd,
                                                                   &west_count_array_2_try_2_zero_and_odd,
                                                                   &left_or_right_1,
                                                                   &left_or_right_2,
                                                                   &left_or_right_3,
                                                                   &left_or_right_4,
                                                                   &feeler,
                                                                   &element,
                                                                   &the_number_of_loops);
                if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
                {
                        break;
    
                }
            }
        }
    
        //////////
    
        cout << '\n';
    
        //results = testing_if_feeler_one_lowest_value_is_same_direction_as_feeler_two_lowest_value ( lowest_value_feeler,
                                                                                          //&did_second_feeler_work,
                                                                                          //&version);
    
    
    
            if ( lowest_value_feeler_1_try_1[ 0 ] == lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_1[ 0 ] != lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_unequal";
    
            }
    
            else if ( lowest_value_feeler_1_try_2[ 0 ] == lowest_value_feeler_2_try_2 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_2[ 0 ] != lowest_value_feeler_2_try_2 [ 0 ] )
            {
               did_second_feeler_work = "elements_are_unequal";
    
            }
    
        // running the second feeler again if it didn't fix the block problem the first time.
    ////
        if ( did_second_feeler_work == "elements_are_equal" )
        {
            int lowest_value_array_feeler_2_try_3[ 9 ];
            int north_array_2_try_3_zero_and_odd[ 9 ];
            int south_array_2_try_3_zero_and_odd[ 9 ];
            int east_array_2_try_3_zero_and_odd[ 9 ];
            int west_array_2_try_3_zero_and_odd[ 9 ];
    
            feeler = 2;
            element = 4;
            left_or_right_1 = 16;
            left_or_right_2 = 17;
            left_or_right_3 = 18;
            left_or_right_4 = 19;
            second_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_3,
                                                                  lowest_value_array_feeler_2_try_3,
                                                                  north_array_2_try_3_zero_and_odd,
                                                                  south_array_2_try_3_zero_and_odd,
                                                                  east_array_2_try_3_zero_and_odd,
                                                                  west_array_2_try_3_zero_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_3_zero_and_odd,
                                                                  &south_count_array_2_try_3_zero_and_odd,
                                                                  &east_count_array_2_try_3_zero_and_odd,
                                                                  &west_count_array_2_try_3_zero_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            display_number_of_steps_message(north_count_array_2_try_3_zero_and_odd,
                                        south_count_array_2_try_3_zero_and_odd,
                                        east_count_array_2_try_3_zero_and_odd,
                                        west_count_array_2_try_3_zero_and_odd,
                                        feeler);
        }
    
    
        cout << '\n';
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting feeler 2 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << "The second feeler did something to unblock feeler 1\n\n";
        cout << "Step 4 ended = make feeler 1 and 2 unequal - gain control.\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "The second feeler did something to unblock feeler 1\n\n";
                file << "Step 4 ended = make feeler 1 and 2 unequal - gain control.\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            }
    
            file.close();
        }
    
    ////
    
    // begin test here
    
    
    
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making the unequal equal again
    
    ////
            feeler = 2;
            element = 5;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            greater_than_node = setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_4,
                                                                lowest_value_array_feeler_2_try_4,
                                                                north_array_2_try_4_zero_and_even,
                                                                south_array_2_try_4_zero_and_even,
                                                                east_array_2_try_4_zero_and_even,
                                                                west_array_2_try_4_zero_and_even,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_4_zero_and_even,
                                                                &south_count_array_2_try_4_zero_and_even,
                                                                &east_count_array_2_try_4_zero_and_even,
                                                                &west_count_array_2_try_4_zero_and_even,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_4_zero_and_even,
                                        south_count_array_2_try_4_zero_and_even,
                                        east_count_array_2_try_4_zero_and_even,
                                        west_count_array_2_try_4_zero_and_even,
                                        feeler);
    
            cout << "Step 5 ended = make feeler 1 and 2 equal - lose control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "Step 5 ended = make feeler 1 and 2 equal - lose control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making equal unequal again.
    ////
            feeler = 3;
            element = 7;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            fourth_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_6,
                                                                  lowest_value_array_feeler_2_try_6,
                                                                  north_array_2_try_6_one_and_odd,
                                                                  south_array_2_try_6_one_and_odd,
                                                                  east_array_2_try_6_one_and_odd,
                                                                  west_array_2_try_6_one_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_6_one_and_odd,
                                                                  &south_count_array_2_try_6_one_and_odd,
                                                                  &east_count_array_2_try_6_one_and_odd,
                                                                  &west_count_array_2_try_6_one_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_6_one_and_odd,
                                        south_count_array_2_try_6_one_and_odd,
                                        east_count_array_2_try_6_one_and_odd,
                                        west_count_array_2_try_6_one_and_odd,
                                        feeler);
    
            cout << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "Step 6 ended = make feeler 1 and 2 unequal - regain control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << '\n';
    
        if ( greater_than_node > *less_than_node )
        {
            cout << "greater than node: " << greater_than_node << ", is greater than less than node: " << *less_than_node << '\n';
            cout << "Added left node, start turning.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is greater than less than node: " << *less_than_node << '\n';
                file << "Added left node, start turning.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 0;
        }
        else if( *less_than_node > greater_than_node )
        {
            cout << "greater than node: " << greater_than_node << ", is not greater than less than node: " << *less_than_node << '\n';
            cout << "Didn\'t add left node, no turning, go straight.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is not greater than less than node: " << *less_than_node << '\n';
                file << "Didn\'t add left node, no turning, go straight.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 1;
        }
        else
        {
            cout << "greater than node: " << greater_than_node << ", is equal to less than node: " << *less_than_node << '\n';
            cout << "Didn\'t add left node, no turning, go straight.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is equal to less than node: " << *less_than_node << '\n';
                file << "Didn\'t add left node, no turning, go straight.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 1;
        }
    }
    
    void which_team_scored( int *try_again, int *good_job )
    {
        if ( *try_again == 0)
        {
            cout << "\nteam 2 scored.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nteam 2 scored.\n";
            }
    
            file.close();
    
        }
        else if ( *try_again == 1 )
        {
            cout << "\nteam 1 scored.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nteam 1 scored.\n";
            }
    
            file.close();
        }
        else if ( *try_again % 2 == 0 )
        {
            cout << "\nteam 2 scored.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nteam 2 scored.\n";
            }
    
            file.close();
        }
        else if ( *try_again % 2 == 1 )
        {
            cout << "\nteam 1 scored.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nteam 1 scored.\n";
            }
    
            file.close();
        }
    }
    
    void listening_to_the_sound_made_by_the_array()
    {
    
        int i;
        int counter = 0;
        int counter_to_add_new_sound = 0;
        int zero_counter = 0;
        int one_counter = 0;
    
        ifstream input("array_used_for_sound.txt");
    
        cout << "\n Listen\n\n";
    
            while ( input >> i)
            {
                counter_to_add_new_sound += 1;
                counter += 1;
    
                if( counter == 2)
                {
                    Sleep( 400 );
                }
                else if ( counter == 4 )
                {
                    Sleep( 250 );
                }
                if ( counter_to_add_new_sound  == 4 )
                {
                    Beep(400,210);
                    Beep(500,210);
                    Beep(600,210);
                }
                else if ( counter_to_add_new_sound  == 8 )
                {
                    Beep(400,210);
                    Beep(500,210);
                    Beep(600,210);
                }
                else if ( counter_to_add_new_sound  == 12 )
                {
                    Beep(400,210);
                    Beep(500,210);
                    Beep(600,210);
    
                }
                else if ( counter_to_add_new_sound  == 16 )
                {
                    Beep(1000,210);
                    Beep(1100,210);
                    Beep(1200,210);
                    counter_to_add_new_sound = 0;
                }
    
    
                if (i == 0 )
                {
                    zero_counter += 1;
                    Beep(400,150);
                }
                else if ( i == 1 )
                {
                    one_counter += 1;
                    Beep(900, 150);
                }
                    counter = 0;
            }
    
            cout << "I can hear it\n\n";
    
            for ( int i = 0; i < zero_counter; i+= 1 )
            {
                Beep(400,150);
            }
    
            for ( int i = 0; i < one_counter; i+= 1 )
            {
                Beep(900, 150);
            }
    }
    
    void writing_array_to_file_to_listen_to_after_program_ends( int array[])
    {
        for ( int i = 0; i < 9; i++ )
        {
            fstream file("array_used_for_sound.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << array[ i ] << endl;
            }
    
            file.close();
        }
    }
    
    int displaying_the_test_results_from_running_the_two_main_function(
                                                                       int compare_to_output_array_1[],
                                                                       int compare_to_output_array_2[],
                                                                       int the_random_list_generated_by_the_left_node_results_array[],
                                                                       int *counting_matching_array_elements_1,
                                                                       int *counting_matching_array_elements_2,
                                                                       int *counting_left_nodes_1,
                                                                       int *counting_left_nodes_2,
                                                                       int *try_again,
                                                                       int *good_job)
    {
        int break_or_not = 0;
    
        if ( *counting_matching_array_elements_1 > *counting_matching_array_elements_2 )
            {
                if ( *counting_left_nodes_1 < *counting_left_nodes_2 )
                {
    
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was met: Good job!.\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was met: Good job!.\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
    
                    writing_array_to_file_to_listen_to_after_program_ends( compare_to_output_array_2);
                    writing_array_to_file_to_listen_to_after_program_ends( compare_to_output_array_1);
                    writing_array_to_file_to_listen_to_after_program_ends( the_random_list_generated_by_the_left_node_results_array);
                    displayArray( compare_to_output_array_1, 9 );
                    *good_job += 1;
                    break_or_not = 1;
                }
                else
                {
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was not met: Try again.\n\n";
    
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was not met: Try again.\n\n";
    
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_1, 9 );
    
                    *try_again += 1;
                }
            }
            else if ( *counting_matching_array_elements_2 > *counting_matching_array_elements_1 )
            {
                if ( *counting_left_nodes_2 < *counting_left_nodes_1 )
                {
                    cout << "The goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was met: Good job!.\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "The goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was met: Good job!.\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    writing_array_to_file_to_listen_to_after_program_ends( compare_to_output_array_1);
                    writing_array_to_file_to_listen_to_after_program_ends( compare_to_output_array_2);
                    writing_array_to_file_to_listen_to_after_program_ends( the_random_list_generated_by_the_left_node_results_array);
                    displayArray( compare_to_output_array_2, 9 );
                    *good_job += 1;
                    break_or_not = 1;
                }
                else
                {
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was not met: Try again.\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was not met: Try again.\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_2, 9 );
                    *try_again += 1;
                }
            }
    
            return break_or_not;
    }
    
    void running_the_two_main_functions( int compare_to_output_array_1[],
                                        int compare_to_output_array_2[],
                                        int the_random_list_generated_by_the_left_node_results_array[],
                                        int *try_again,
                                        int *good_job )
    {
        string lowest_value_feeler_1_try_1[ 9 ];
        string lowest_value_feeler_1_try_2[ 9 ];
        string left_or_right[ 4 ];
        int north_array[ 9 ];
        int south_array[ 9 ];
        int east_array[ 9 ];
        int west_array[ 9 ];
        string feeler_1_lowest_value_array_direction = "";
        string feeler_one_element_zero_equal = "";
        int north_count_1 = 0;
        int south_count_1 = 0;
        int east_count_1 = 0;
        int west_count_1 = 0;
        int less_than_node = 0;
        int result_of_left_node_test = 0;
    
            while ( 1 )
        {
            north_count_1 = 0;
            south_count_1 = 0;
            east_count_1 = 0;
            west_count_1 = 0;
            less_than_node = 0;
            result_of_left_node_test = 0;
            int counting_matching_array_elements_1 = 0;
            int counting_matching_array_elements_2 = 0;
            int counting_left_nodes_1 = 0;
            int counting_left_nodes_2 = 0;
    
            for ( int i = 0; i < 9; i++ )
            {
                the_master_function_part_one(lowest_value_feeler_1_try_1,
                                         lowest_value_feeler_1_try_2,
                                         left_or_right,
                                         north_array,
                                         south_array,
                                         east_array,
                                         west_array,
                                         &feeler_one_element_zero_equal,
                                         &feeler_1_lowest_value_array_direction,
                                         &north_count_1,
                                         &south_count_1,
                                         &east_count_1,
                                         &west_count_1,
                                         &less_than_node);
    
            the_master_function_part_two(lowest_value_feeler_1_try_1,
                                         lowest_value_feeler_1_try_2,
                                         left_or_right,
                                         north_array,
                                         south_array,
                                         east_array,
                                         west_array,
                                         &feeler_one_element_zero_equal,
                                         &feeler_1_lowest_value_array_direction,
                                         &north_count_1,
                                         &south_count_1,
                                         &east_count_1,
                                         &west_count_1,
                                         &less_than_node,
                                         &result_of_left_node_test);
    
            the_random_list_generated_by_the_left_node_results_array[ i ] = result_of_left_node_test;
            }
    
            for ( int i = 0; i < 9; i++ )
            {
                // keep the numbers small so they're easy to read
                compare_to_output_array_2[ i ] = rand() % 2;
            }
    
            for ( int i = 0; i < 9; i++ )
            {
                // counting left nodes in the 2 arrays
                if ( compare_to_output_array_1[ i ] == 0 )
                {
                    counting_left_nodes_1 += 1;
                }
                if ( compare_to_output_array_2[ i ] == 0 )
                {
                    counting_left_nodes_2 += 1;
                }
    
                // comparing the elements of the two arrays to the results array to find matching elements
                if (compare_to_output_array_1[ i ] == the_random_list_generated_by_the_left_node_results_array [ i ] )
                {
                    counting_matching_array_elements_1 += 1;
                }
                if (compare_to_output_array_2[ i ] == the_random_list_generated_by_the_left_node_results_array[ i ] )
                {
                    counting_matching_array_elements_2 += 1;
                }
            }
    
            int break_or_not = displaying_the_test_results_from_running_the_two_main_function(
                                                                        compare_to_output_array_1,
                                                                        compare_to_output_array_2,
                                                                        the_random_list_generated_by_the_left_node_results_array,
                                                                        &counting_matching_array_elements_1,
                                                                        &counting_matching_array_elements_2,
                                                                        &counting_left_nodes_1,
                                                                        &counting_left_nodes_2,
                                                                        try_again,
                                                                        good_job);
    
            if ( break_or_not == 1 )
            {
                break;
            }
        }
    }
    
    int main ()
    {
        int compare_to_output_array_1[ 9 ];
        int compare_to_output_array_2[ 9 ];
        int the_random_list_generated_by_the_left_node_results_array[ 9 ];
        int try_again = 0;
        int good_job = 0;
        srand( time( NULL ) );
    
    
        set_array_value_to_zero( compare_to_output_array_1 );
        set_array_value_to_zero( compare_to_output_array_2 );
        set_array_value_to_zero( the_random_list_generated_by_the_left_node_results_array );
    
        // clear text file
        {
            fstream file("text_from_program.txt", ios::out | ios::trunc);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
    
    
            file.close();
        }
    
        // clear text file
        {
            fstream file("array_used_for_sound.txt", ios::out | ios::trunc);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
    
    
            file.close();
        }
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            cout << "Starting program\n";
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "Starting program\n\n";
            }
            file.close();
        }
    
        for ( int i = 0; i < 9; i++ )
        {
            // keep the numbers small so they're easy to read
            compare_to_output_array_1[ i ] = rand() % 2;
        }
    
        running_the_two_main_functions( compare_to_output_array_1,
                                        compare_to_output_array_2,
                                        the_random_list_generated_by_the_left_node_results_array,
                                        &try_again,
                                        &good_job );
    
    
    
        cout << '\n';
        cout << "generated input list 1\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated input list 1\n";
            }
    
            file.close();
        }
    
        displayArray( compare_to_output_array_1, 9 );
        cout << '\n';
        cout << "generated input list 2\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated input list 2\n";
            }
    
            file.close();
        }
    
        displayArray( compare_to_output_array_2, 9 );
        cout << '\n';
        cout << "generated results list\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated results list\n";
            }
    
            file.close();
        }
    
        displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
        cout << "\n\n";
    
        cout << "\n\nscore:\n";
        cout << "Number of times won = " << good_job << '\n';
        cout << "Number of retries until won = " << try_again << '\n';
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\n\n";
    
                file << "\n\nscore:\n";
                file << "Number of times won = " << good_job << '\n';
                file << "Number of retries until won = " << try_again << '\n';
            }
    
            file.close();
        }
    
        which_team_scored( &try_again, &good_job );
    
        cout << "\nEnding program\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\n\n";
    
                file << "\nEnding program\n\n";
            }
    
            file.close();
        }
    
        cout << "listening to the sound the arrays make\n";
        listening_to_the_sound_made_by_the_array();
    
        getchar();
    
    }
    My AI SW version 16;

    Mega File Upload - ai program 16.zip

    This version adds sound.

    I removed the beep from my previous version because the beep was heard before the program finished multiple times for a long time and that made the program wit for the sound to finish before continuing which slowed my program.

    So I took the results and made a beep sound that made logical sense if you read my notes in the link I gave.

    I hope you like it, I made it for you.

  12. #12
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by jeremy duncan View Post
    I hope you like it, I made it for you.
    And what have you made for the rest of us?

  13. #13
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    If your program is over 3000 lines, it might be time to start considering breaking your project up into separate files.

    In fact, you seem to be "coding by copying". Your "displaying_which_direction_is_lowest()" function is 403 lines long, and is mostly the same code copied over and over with minor differences. With a little thought and planning, this function could easily be reduced to 40 lines or less.

    There is so much unnecessary redundancy - not only does this make it difficult for you to follow the code, but it will make maintaining/updating/debugging it a nightmare.

  14. #14
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Try using this list of refactoring techniques; particularly the ones that lead to "more logical pieces" - the code kind of needs it. Anywhere you use a bare statement block is a strong hint you could create a function. (An example would be all the places you handle files.) There might even be some opportunity for class design if you take a critical look at this code.

  15. #15
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    Hi Hodor, I have been busy for a long time today thinking up and making code to make my program better.

    Here is the link to the source and program for you to try:

    Mega File Upload - ai program 17.zip

    To the other two people, I am reading the cpp book this website sells and am stuck on the binary search trees and decided to start coding with what it taught me. I am still reading that chapter and doing the binary tree code exercise but it's difficult for me so I started to do this, I haven't gotten to the classes or refactoring part of the book yet, this is the best I can do for now, sry.

    Anyway some people are scared to download strange files from people like me so I will post my code here for you to read so you don't have to download from that strange link;

    Here you go, Horon,

    Code:
    #include <cstdlib>
    #include <ctime>
    #include <iostream>
    #include <windows.h> // WinApi header
    #include <cstdio>
    #include <string>
    #include <time.h>
    #include <fstream>
    
    using namespace std;
    
    int findSmallestRemainingElement (int array[], int size, int index);
    void swap (int array[], int first_index, int second_index);
    
    void sort (int array[], int size)
    {
        for ( int i = 0; i < size; i++ )
        {
            int index = findSmallestRemainingElement( array, size, i );
            swap( array, i, index );
        }
    }
    
    int findSmallestRemainingElement (int array[], int size, int index)
    {
        int index_of_smallest_value = index;
        for (int i = index + 1; i < size; i++)
        {
            if ( array[ i ] < array[ index_of_smallest_value ] )
            {
                index_of_smallest_value = i;
            }
        }
        return index_of_smallest_value;
    }
    
    void swap (int array[], int first_index, int second_index)
    {
        int temp = array[ first_index ];
        array[ first_index ] = array[ second_index ];
        array[ second_index ] = temp;
    }
    
    // small helper method to display the before and after arrays
    void displayArray (int array[], int size)
    {
        cout << "{";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "{";
            }
    
            file.close();
        }
    
        for ( int i = 0; i < size; i++ )
        {
            // you'll see this pattern a lot for nicely formatting
            // lists--check if we're past the first element, and
            // if so, append a comma
            if ( i != 0 )
            {
                cout << ", ";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << ", ";
                    }
    
                    file.close();
                }
    
            }
            cout << array[ i ];
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << array[ i ];
                }
    
                file.close();
            }
        }
        cout << "}";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "}";
            }
    
            file.close();
        }
    }
    
    void set_array_value_to_zero ( int array[] )
    {
        for ( int i = 0; i < 9; i++ )
        {
            array[ i ] = 0;
        }
    }
    
    void set_one_string_array_equal_to_another_string_array ( string array[], string array2[] )
    {
        for ( int i = 0; i < 4; i++ )
        {
            array[ i ] = array2[ i ];
        }
    }
    
    void set_one_int_array_equal_to_another_int_array ( int array[], int array2[] )
    {
        for ( int i = 0; i < 9; i++ )
        {
            array[ i ] = array2[ i ];
        }
    }
    
    void newSwitch (int array[], int size, int subtracting_this_many_array_elements, int *high, int *medium, int *low)
    {
        for ( int i = size; i-- > subtracting_this_many_array_elements; )
        {
    
            switch(array[i])
            {
                case 8:
                case 7:
                case 6:
                    //cout << "Input: " << i << " too high\n";
                    *high += 1;
                    break;
                case 5:
                case 4:
                case 3:
                    //cout << "Input: " << i << " might be good\n";
                    *medium += 1;
                    break;
                case 2:
                case 1:
                case 0:
                    //cout << "Input: " << i << " is good\n";
                    *low += 1;
                    break;
            }
        }
    }
    
    int which_value_is_largest (int high, int medium, int low)
    {
        int value = 0;
    
        if ( high > medium && high > low && medium > low )
        {
            value = 13;
        }
    
        else if ( high > medium && high > low && medium == low )
        {
            value = 12;
        }
    
        else if ( high > medium && high > low && low > medium )
        {
            value = 11;
        }
    
        else if ( medium > high && medium > low && high > low )
        {
            value = 10;
        }
    
        else if ( medium > high && medium > low && high == low )
        {
            value = 9;
        }
    
        else if ( medium > high && medium > low && low > high )
        {
            value = 8;
        }
    
        else if ( low > medium && low > high && high > medium )
        {
            value = 7;
        }
    
        else if ( low > medium && low > high && high == medium )
        {
            value = 6;
        }
    
        else if ( low > medium && low > high && medium > high )
        {
            value = 5;
        }
    
        else if ( medium == low && high < medium )
        {
            value = 4;
        }
        else if ( high == low && medium < high )
        {
            value = 3;
        }
        else if ( high == medium && low < medium )
        {
            value = 2;
        }
        else
        {
            value = 1;
        }
    
        return value;
    }
    
    int side (int array[], int size, int subtracting_this_many_array_elements)
    {
        int too_high = 0;
        int might_be_good = 0;
        int good_stuff = 0;
    
        int value = 0;
    
        //cout << "____________________________________\n";
    
        //cout << "Original array: ";
        //displayArray( array, size );
        //cout << '\n';
    
        sort( array, size );
    
        //cout << "Sorted array: ";
        //displayArray( array, size );
       // cout << '\n';
        //cout << '\n';
    
        newSwitch( array, size, subtracting_this_many_array_elements, &too_high, &might_be_good, &good_stuff );
    
        //cout << '\n';
    
        //cout << "high counter = " << too_high << '\n';
        //cout << "medium counter = " << might_be_good << '\n';
        //cout << "low counter = " << good_stuff << '\n';
    
        //cout << '\n';
    
        value = which_value_is_largest (too_high, might_be_good, good_stuff);
        //interpreting_whichValueIsLargest(value);
    
        //cout << '\n';
    
        return value;
    }
    
    void randomizing_array_elements ( int array[], int size)
    {
    
        for ( int i = 0; i < size; i++ )
        {
            // keep the numbers small so they're easy to read
            array[ i ] = rand() % 9;
        }
    }
    
    int  do_this_if_left_or_right_is_greater(int array[], string left_or_right[], int *I_took_a_step, int left_side, int right_side, int subtracting_this_many_array_elements, int which_string_element)
    {
        int value = 0;
        //cout << "____________________________________\n";
    
        //cout << "Left side value is: " << left_side << '\n';
        //cout << "Right side value is: " << right_side << '\n';
        //cout << '\n';
    
        if ( left_side > right_side )
        {
            for ( int i = 0; i < 8; i++ )
            {
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
    
                subtracting_this_many_array_elements++;
                left_side = side( array, 9, subtracting_this_many_array_elements );
                //cout << "Left side value is: " << left_side << '\n';
    
                if (left_side <= 3)
                {
                    //cout << "____________________________________\n";
    
                    //cout << "Took a step\n";
                    value = 1;
                    *I_took_a_step += 1;
                    //Beep(1568, 500);
    
                    break;
                }
                else
                {
                    value = 0;
                }
                //cout << '\n';
            }
            left_or_right [ which_string_element ] = "left";
        }
        else if ( right_side > left_side )
        {
            for ( int i = 0; i < 8; i++ )
            {
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
    
                subtracting_this_many_array_elements++;
                right_side = side( array, 9, subtracting_this_many_array_elements );
                //cout << "Right side value is: " << right_side << '\n';
    
                if (right_side <= 3)
                {
                    //cout << "____________________________________\n";
                    //cout << "Took a step\n";
                    value = 1;
                    *I_took_a_step += 1;
                    //Beep(523,500); // 523 hertz (C5) for 500 milliseconds
                    break;
                }
                else
                {
                    value = 0;
                }
    
                //cout << '\n';
            }
            left_or_right [ which_string_element ] = "right";
        }
    
        return value;
    }
    
    int testing_four_directions(int counter[], string left_or_right[], int which_string_element)
    {
        int array[ 9 ];
    
        int I_took_a_step = 0;
    
        int subtracting_this_many_array_elements = 0;
    
        for ( int i = 0; i < 9; i++ )
        {
            set_array_value_to_zero( array );
    
            randomizing_array_elements(array, 9);
            int left_side = side( array, 9 , subtracting_this_many_array_elements);
    
            set_array_value_to_zero( array );
    
            randomizing_array_elements(array, 9);
            int right_side = side( array, 9, subtracting_this_many_array_elements );
    
            while ( left_side == right_side )
            {
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
                left_side = side( array, 9 , subtracting_this_many_array_elements);
    
                set_array_value_to_zero( array );
    
                randomizing_array_elements(array, 9);
                right_side = side( array, 9, subtracting_this_many_array_elements );
            }
    
            int step_counter = do_this_if_left_or_right_is_greater(array, left_or_right, &I_took_a_step, left_side, right_side, subtracting_this_many_array_elements, which_string_element);
            counter[ i ] = step_counter;
        }
        return I_took_a_step;
    }
    
    
    int which_direction_is_lowest(string lowest_value_feeler[], int north, int south, int east, int west, int feeler, int element)
    {
        int direction_value = 0;
        if ( north < south && north < east && north < west )
        {
            lowest_value_feeler[ element ] = "north";
            direction_value = 1;
        }
        else if ( south < north && south < east && south < west )
        {
            lowest_value_feeler[ element ] = "south";
            direction_value = 2;
        }
        else if ( east < north && east < south && east < west )
        {
            lowest_value_feeler[ element ] = "east";
            direction_value = 3;
        }
        else if ( west < north && west < south && west < east )
        {
            lowest_value_feeler[ element ] = "west";
            direction_value = 4;
        }
        else if ( north == south && north == east && north == west )
        {
            lowest_value_feeler[ element ] = "no_lowest_direction.";
            direction_value = 5;
        }
        else if ( north == east && north == south )
        {
            lowest_value_feeler[ element ] = "north_east_south.";
            direction_value = 6;
        }
        else if ( east == south && east == west )
        {
            lowest_value_feeler[ element ] = "east_south_west.";
            direction_value = 7;
        }
        else if ( south == west && south == north )
        {
            lowest_value_feeler[ element ] = "south_west_north.";
            direction_value = 8;
        }
        else if ( west == north && west == east )
        {
            lowest_value_feeler[ element ] = "west_north_east.";
            direction_value = 9;
        }
        else if ( north == east )
        {
            lowest_value_feeler[ element ] = "north_east.";
            direction_value = 10;
        }
        else if ( east == south )
        {
            lowest_value_feeler[ element ] = "east_south.";
            direction_value = 11;
        }
        else if ( south == west )
        {
            lowest_value_feeler[ element ] = "south_west.";
            direction_value = 12;
        }
        else if ( west == north )
        {
            lowest_value_feeler[ element ] = "west_north.";
            direction_value = 13;
        }
        else if ( west == east )
        {
            lowest_value_feeler[ element ] = "west_east.";
            direction_value = 14;
        }
        else if ( north == south )
        {
            lowest_value_feeler[ element ] = "north_south.";
            direction_value = 15;
        }
        else if ( north == east && north > south && north > west )
        {
            lowest_value_feeler[ element ] = "north_east";
            direction_value = 16;
        }
    
        else if ( north == west && north > east && north > south )
        {
            lowest_value_feeler[ element ] = "north_west";
            direction_value = 17;
        }
        else if ( north == south && north > east && north > west )
        {
            lowest_value_feeler[ element ] = "north_south";
            direction_value = 18;
        }
        else if ( east == west && east > north && east > south )
        {
            lowest_value_feeler[ element ] = "east_west";
            direction_value = 19;
        }
        else if ( east == south && east > north && east > west )
        {
            lowest_value_feeler[ element ] = "east_south";
            direction_value = 20;
        }
        else if ( west == south && west > north && west > east )
        {
            lowest_value_feeler[ element ] = "west_south";
            direction_value = 21;
        }
    
        return direction_value;
    }
    
    void displaying_which_direction_is_lowest( int lowest_value_array[], int direction_value, int feeler )
    {
    
        if ( direction_value == 1 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 2 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 3 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 4 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 5 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south, east, west direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south, east, west direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 6 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east, south direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east, south direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 7 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south, west direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south, west direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 8 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south, west, north direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south, west, north direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 9 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, north, east direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, north, east direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 10 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 11 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 12 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south, west direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south, west direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 13 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, north direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, north direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 14 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, east direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, east direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 15 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 16 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 17 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, west direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, west direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 18 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 19 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, west direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, west direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 20 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 21 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, south direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, south direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
    }
    
    void direction_value_array_transfer_value_to_new_array (int lowest_value_array[],
                                                           string *lowest_value_array_direction,
                                                                      int north[],
                                                                      int south[],
                                                                      int east[],
                                                                      int west[],
                                                                      int *direction_value)
    {
    
        switch( *direction_value )
        {
            case 1:
            case 5:
            case 6:
            case 10:
            case 17:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, north );
                *lowest_value_array_direction = "north";
                break;
    
            case 2:
            case 8:
            case 12:
            case 15:
            case 18:
            case 20:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, south );
                *lowest_value_array_direction = "south";
                break;
    
            case 3:
            case 7:
            case 11:
            case 16:
            case 19:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, east );
                *lowest_value_array_direction = "east";
                break;
    
            case 4:
            case 9:
            case 13:
            case 14:
            case 21:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, west );
                *lowest_value_array_direction = "west";
                break;
        }
    }
    
    void display_number_of_steps_message(int north, int south, int east, int west, int which_feeler)
    {
        cout << "Values with feeler "<< which_feeler << "\n";
        cout << "I tried to take 9 steps in the north direction, but I actual took " << north << " steps.\n";
        cout << "I tried to take 9 steps in the south direction, but I actual took " << south << " steps.\n";
        cout << "I tried to take 9 steps in the east direction, but I actual took " << east << " steps.\n";
        cout << "I tried to take 9 steps in the west direction, but I actual took " << west << " steps.\n";
    
        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
        if( file.fail() )
        {
            cout << "error while opening the file in the display_number_of_steps_message function" << endl;
        }
        else
        {
            file << endl;
            file << "Values with feeler "<< which_feeler << "\n";
            file << "I tried to take 9 steps in the north direction, but I actual took " << north << " steps.\n";
            file << "I tried to take 9 steps in the south direction, but I actual took " << south << " steps.\n";
            file << "I tried to take 9 steps in the east direction, but I actual took " << east << " steps.\n";
            file << "I tried to take 9 steps in the west direction, but I actual took " << west << " steps.\n";
            file << endl;
        }
    
        file.close();
    }
    
    void used_in_setting_feeler_to_new_value ( string left_or_right[],
                                               string lowest_value_feeler[],
                                               int lowest_value_array[],
                                               int north_array[],
                                               int south_array[],
                                               int east_array[],
                                               int west_array[],
                                               string *lowest_value_array_direction,
                                               int *north_count,
                                               int *south_count,
                                               int *east_count,
                                               int *west_count,
                                               int *left_or_right_1,
                                               int *left_or_right_2,
                                               int *left_or_right_3,
                                               int *left_or_right_4,
                                               int *feeler,
                                               int *element )
    {
        int direction_value = 0;
    
        set_array_value_to_zero( north_array );
    
        set_array_value_to_zero( south_array );
    
        set_array_value_to_zero( east_array );
    
        set_array_value_to_zero( west_array );
        set_array_value_to_zero( lowest_value_array );
    
        left_or_right[ *left_or_right_1 ] = "";
        left_or_right[ *left_or_right_2 ] = "";
        left_or_right[ *left_or_right_3 ] = "";
        left_or_right[ *left_or_right_4 ] = "";
    
        *north_count = testing_four_directions(north_array, left_or_right, *left_or_right_1);
        *south_count = testing_four_directions(south_array, left_or_right, *left_or_right_2);
        *east_count = testing_four_directions(east_array, left_or_right, *left_or_right_3);
        *west_count = testing_four_directions(west_array, left_or_right, *left_or_right_4);
        direction_value = which_direction_is_lowest(lowest_value_feeler,
                                                    *north_count,
                                                    *south_count,
                                                    *east_count,
                                                    *west_count,
                                                    *feeler, *element);
    
        direction_value_array_transfer_value_to_new_array ( lowest_value_array,
                                                           lowest_value_array_direction,
                                                            north_array,
                                                            south_array,
                                                            east_array,
                                                            west_array,
                                                            &direction_value);
    
        displaying_which_direction_is_lowest( lowest_value_array, direction_value, *feeler );
    
    
    }
    
    void fourth_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_6[],
                                                              int lowest_value_array_feeler_2_try_6[],
                                                              int north_array_2_try_6_one_and_odd[],
                                                              int south_array_2_try_6_one_and_odd[],
                                                              int east_array_2_try_6_one_and_odd[],
                                                              int west_array_2_try_6_one_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_6_one_and_odd,
                                                              int *south_count_array_2_try_6_one_and_odd,
                                                              int *east_count_array_2_try_6_one_and_odd,
                                                              int *west_count_array_2_try_6_one_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_6,
                                                  lowest_value_array_feeler_2_try_6,
                                                  north_array_2_try_6_one_and_odd,
                                                  south_array_2_try_6_one_and_odd,
                                                  east_array_2_try_6_one_and_odd,
                                                  west_array_2_try_6_one_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_6_one_and_odd,
                                                  south_count_array_2_try_6_one_and_odd,
                                                  east_count_array_2_try_6_one_and_odd,
                                                  west_count_array_2_try_6_one_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_6[ 0 ] == 1)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    
    
    }
    
    void third_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_5[],
                                                              int lowest_value_array_feeler_2_try_5[],
                                                              int north_array_2_try_5_one_and_odd[],
                                                              int south_array_2_try_5_one_and_odd[],
                                                              int east_array_2_try_5_one_and_odd[],
                                                              int west_array_2_try_5_one_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_5_one_and_odd,
                                                              int *south_count_array_2_try_5_one_and_odd,
                                                              int *east_count_array_2_try_5_one_and_odd,
                                                              int *west_count_array_2_try_5_one_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_5,
                                                  lowest_value_array_feeler_2_try_5,
                                                  north_array_2_try_5_one_and_odd,
                                                  south_array_2_try_5_one_and_odd,
                                                  east_array_2_try_5_one_and_odd,
                                                  west_array_2_try_5_one_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_5_one_and_odd,
                                                  south_count_array_2_try_5_one_and_odd,
                                                  east_count_array_2_try_5_one_and_odd,
                                                  west_count_array_2_try_5_one_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_5[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    
    
    }
    
    int setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( string left_or_right[],
                                                               string lowest_value_feeler_2_try_4[],
                                                               int lowest_value_array_feeler_2_try_4[],
                                                               int north_array_2_try_4_zero_and_even[],
                                                               int south_array_2_try_4_zero_and_even[],
                                                               int east_array_2_try_4_zero_and_even[],
                                                               int west_array_2_try_4_zero_and_even[],
                                                               string *feeler_1_lowest_value_array_direction,
                                                               string *feeler_2_lowest_value_array_direction,
                                                               string *did_second_feeler_work,
                                                               int *north_count_array_2_try_4_zero_and_even,
                                                               int *south_count_array_2_try_4_zero_and_even,
                                                               int *east_count_array_2_try_4_zero_and_even,
                                                               int *west_count_array_2_try_4_zero_and_even,
                                                               int *left_or_right_1,
                                                               int *left_or_right_2,
                                                               int *left_or_right_3,
                                                               int *left_or_right_4,
                                                               int *feeler,
                                                               int *element,
                                                               int *the_number_of_loops)
    {
        int counter = 0;
        while ( 1 )
        {
            counter = counter + 1;
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                      lowest_value_feeler_2_try_4,
                                                      lowest_value_array_feeler_2_try_4,
                                                      north_array_2_try_4_zero_and_even,
                                                      south_array_2_try_4_zero_and_even,
                                                      east_array_2_try_4_zero_and_even,
                                                      west_array_2_try_4_zero_and_even,
                                                      feeler_2_lowest_value_array_direction,
                                                      north_count_array_2_try_4_zero_and_even,
                                                      south_count_array_2_try_4_zero_and_even,
                                                      east_count_array_2_try_4_zero_and_even,
                                                      west_count_array_2_try_4_zero_and_even,
                                                      left_or_right_1,
                                                      left_or_right_2,
                                                      left_or_right_3,
                                                      left_or_right_4,
                                                      feeler,
                                                      element );
    
                if ( lowest_value_array_feeler_2_try_4[ 0 ] == 0)
                {
                    if ( *feeler_2_lowest_value_array_direction ==  *feeler_1_lowest_value_array_direction )
                    {
                        *the_number_of_loops += 1;
                        *did_second_feeler_work = "elements_are_equal";
    
                        return counter;
                    }
                }
                else
                {
                   *the_number_of_loops += 1;
                   *did_second_feeler_work = "elements_are_unequal";
                }
        }
    }
    
    void second_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                               string lowest_value_feeler_2_try_3[],
                                                               int lowest_value_array_feeler_2_try_3[],
                                                               int north_array_2_try_3_zero_and_odd[],
                                                               int south_array_2_try_3_zero_and_odd[],
                                                               int east_array_2_try_3_zero_and_odd[],
                                                               int west_array_2_try_3_zero_and_odd[],
                                                               string *feeler_1_lowest_value_array_direction,
                                                               string *feeler_2_lowest_value_array_direction,
                                                               string *did_second_feeler_work,
                                                               int *north_count_array_2_try_3_zero_and_odd,
                                                               int *south_count_array_2_try_3_zero_and_odd,
                                                               int *east_count_array_2_try_3_zero_and_odd,
                                                               int *west_count_array_2_try_3_zero_and_odd,
                                                               int *left_or_right_1,
                                                               int *left_or_right_2,
                                                               int *left_or_right_3,
                                                               int *left_or_right_4,
                                                               int *feeler,
                                                               int *element,
                                                               int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_3,
                                                  lowest_value_array_feeler_2_try_3,
                                                  north_array_2_try_3_zero_and_odd,
                                                  south_array_2_try_3_zero_and_odd,
                                                  east_array_2_try_3_zero_and_odd,
                                                  west_array_2_try_3_zero_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_3_zero_and_odd,
                                                  south_count_array_2_try_3_zero_and_odd,
                                                  east_count_array_2_try_3_zero_and_odd,
                                                  west_count_array_2_try_3_zero_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_3[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
    
            }
        }
    }
    
    void first_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_2[],
                                                              int lowest_value_array_feeler_2_try_2[],
                                                              int north_array_2_try_2_zero_and_odd[],
                                                              int south_array_2_try_2_zero_and_odd[],
                                                              int east_array_2_try_2_zero_and_odd[],
                                                              int west_array_2_try_2_zero_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_2_zero_and_odd,
                                                              int *south_count_array_2_try_2_zero_and_odd,
                                                              int *east_count_array_2_try_2_zero_and_odd,
                                                              int *west_count_array_2_try_2_zero_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    
    
    
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_2,
                                                  lowest_value_array_feeler_2_try_2,
                                                  north_array_2_try_2_zero_and_odd,
                                                  south_array_2_try_2_zero_and_odd,
                                                  east_array_2_try_2_zero_and_odd,
                                                  west_array_2_try_2_zero_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_2_zero_and_odd,
                                                  south_count_array_2_try_2_zero_and_odd,
                                                  east_count_array_2_try_2_zero_and_odd,
                                                  west_count_array_2_try_2_zero_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                   *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    }
    
    void setting_feeler_one_element_zero_to_zero ( string left_or_right[],
                                                      string lowest_value_feeler[],
                                                      int lowest_value_array[],
                                                      int north_array_1_try_2_zero[],
                                                      int south_array_1_try_2_zero[],
                                                      int east_array_1_try_2_zero[],
                                                      int west_array_1_try_2_zero[],
                                                      string *feeler_1_lowest_value_array_direction,
                                                      string *feeler_2_lowest_value_array_direction,
                                                      string *did_second_feeler_work,
                                                      int *north_count_array_1_try_2_zero,
                                                      int *south_count_array_1_try_2_zero,
                                                      int *east_count_array_1_try_2_zero,
                                                      int *west_count_array_1_try_2_zero,
                                                      int *left_or_right_1,
                                                      int *left_or_right_2,
                                                      int *left_or_right_3,
                                                      int *left_or_right_4,
                                                      int *feeler,
                                                      int *element,
                                                      int *the_number_of_loops)
    {
        while ( 1 )
        {
            used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler,
                                                  lowest_value_array,
                                                  north_array_1_try_2_zero,
                                                  south_array_1_try_2_zero,
                                                  east_array_1_try_2_zero,
                                                  west_array_1_try_2_zero,
                                                  feeler_1_lowest_value_array_direction,
                                                  north_count_array_1_try_2_zero,
                                                  south_count_array_1_try_2_zero,
                                                  east_count_array_1_try_2_zero,
                                                  west_count_array_1_try_2_zero,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
    
    
            if ( lowest_value_array[ 0 ] == 0 )
            {
                break;
            }
        }
    }
    
    void direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest( string lowest_value_feeler[],
                                                                                                                                             int lowest_value_array[],
                                          int north_array[],
                                          int south_array[],
                                          int east_array[],
                                          int west_array[],
                                          string *lowest_value_array_direction,
                                          int *north_count,
                                          int *south_count,
                                          int *east_count,
                                          int *west_count,
                                          int *feeler,
                                          int *element,
                                          int *direction_value )
    {
    
        *direction_value = which_direction_is_lowest(lowest_value_feeler,
                                                    *north_count,
                                                    *south_count,
                                                    *east_count,
                                                    *west_count,
                                                    *feeler,
                                                    *element);
    
        direction_value_array_transfer_value_to_new_array ( lowest_value_array,
                                                           lowest_value_array_direction,
                                                            north_array,
                                                            south_array,
                                                            east_array,
                                                            west_array,
                                                            direction_value);
    
        displaying_which_direction_is_lowest( lowest_value_array, *direction_value, *feeler );
    
    }
    
    void the_master_function_part_one ( string lowest_value_feeler_1_try_1[],
                                       string lowest_value_feeler_1_try_2[],
                                       string main_left_or_right[],
                                       int main_north_array[],
                                       int main_south_array[],
                                       int main_east_array[],
                                       int main_west_array[],
                                       string *feeler_one_element_zero_equal,
                                       string *feeler_1_lowest_value_array_direction,
                                       int *main_north_count,
                                       int *main_south_count,
                                       int *main_east_count,
                                       int *main_west_count,
                                       int *less_than_node)
    {
        string left_or_right[ 20 ];
        string lowest_value_feeler_2_try_1[ 9 ];
        string lowest_value_feeler_2_try_2[ 9 ];
        string lowest_value_feeler_2_try_3[ 9 ];
        string lowest_value_feeler_2_try_4[ 9 ];
        string lowest_value_feeler_2_try_5[ 9 ];
        string feeler_2_lowest_value_array_direction = "";
        string did_second_feeler_work = "";
        int lowest_value_array_feeler_1_try_1[ 9 ];
        int lowest_value_array_feeler_1_try_2[ 9 ];
        int lowest_value_array_feeler_2_try_1[ 9 ];
        int lowest_value_array_feeler_2_try_2[ 9 ];
        int lowest_value_array_feeler_2_try_4[ 9 ];
        int lowest_value_array_feeler_2_try_5[ 9 ];
        int direction_value = 0;
        int feeler = 0;
        int element = 0;
        int left_or_right_1 = 0;
        int left_or_right_2 = 0;
        int left_or_right_3 = 0;
        int left_or_right_4 = 0;
        int north_array_1[ 9 ];
        int south_array_1[ 9 ];
        int east_array_1[ 9 ];
        int west_array_1[ 9 ];
        int north_array_2[ 9 ];
        int south_array_2[ 9 ];
        int east_array_2[ 9 ];
        int west_array_2[ 9 ];
    
        int north_array_1_try_2_zero[ 9 ];
        int south_array_1_try_2_zero[ 9 ];
        int east_array_1_try_2_zero[ 9 ];
        int west_array_1_try_2_zero[ 9 ];
    
        int north_array_2_try_2_zero_and_odd[ 9 ];
        int south_array_2_try_2_zero_and_odd[ 9 ];
        int east_array_2_try_2_zero_and_odd[ 9 ];
        int west_array_2_try_2_zero_and_odd[ 9 ];
    
        int north_array_2_try_4_zero_and_even[ 9 ];
        int south_array_2_try_4_zero_and_even[ 9 ];
        int east_array_2_try_4_zero_and_even[ 9 ];
        int west_array_2_try_4_zero_and_even[ 9 ];
    
        int north_array_2_try_5_one_and_odd[ 9 ];
        int south_array_2_try_5_one_and_odd[ 9 ];
        int east_array_2_try_5_one_and_odd[ 9 ];
        int west_array_2_try_5_one_and_odd[ 9 ];
    
        int north_count_1 = 0;
        int south_count_1 = 0;
        int east_count_1 = 0;
        int west_count_1 = 0;
        int north_count_2 = 0;
        int south_count_2 = 0;
        int east_count_2 = 0;
        int west_count_2 = 0;
    
        int north_count_array_2_try_2_zero_and_odd = 0;
        int south_count_array_2_try_2_zero_and_odd = 0;
        int east_count_array_2_try_2_zero_and_odd = 0;
        int west_count_array_2_try_2_zero_and_odd = 0;
    
        int north_count_array_2_try_3_zero_and_odd = 0;
        int south_count_array_2_try_3_zero_and_odd = 0;
        int east_count_array_2_try_3_zero_and_odd = 0;
        int west_count_array_2_try_3_zero_and_odd = 0;
    
        int north_count_array_2_try_4_zero_and_even = 0;
        int south_count_array_2_try_4_zero_and_even = 0;
        int east_count_array_2_try_4_zero_and_even = 0;
        int west_count_array_2_try_4_zero_and_even = 0;
    
        int north_count_array_2_try_5_one_and_odd = 0;
        int south_count_array_2_try_5_one_and_odd = 0;
        int east_count_array_2_try_5_one_and_odd = 0;
        int west_count_array_2_try_5_one_and_odd = 0;
    
        int north_count_array_1_try_2_zero = 0;
        int south_count_array_1_try_2_zero = 0;
        int east_count_array_1_try_2_zero = 0;
        int west_count_array_1_try_2_zero = 0;
    
        int the_number_of_loops = 0;
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting step 1
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 1 begin
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        north_count_1 = testing_four_directions(north_array_1, left_or_right, 0);
        south_count_1 = testing_four_directions(south_array_1, left_or_right, 1);
        east_count_1 = testing_four_directions(east_array_1, left_or_right, 2);
        west_count_1 = testing_four_directions(west_array_1, left_or_right, 3);
    
        cout << '\n';
        feeler = 1;
        element = 0;
    
       direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_1_try_1,
        lowest_value_array_feeler_1_try_1,
        north_array_1,
        south_array_1,
        east_array_1,
        west_array_1,
        feeler_1_lowest_value_array_direction,
        &north_count_1,
        &south_count_1,
        &east_count_1,
        &west_count_1,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_1_try_1[ 0 ] == 0 )
        {
            *feeler_one_element_zero_equal = "feeler_one_element_zero_equal_zero";
    
            cout << '\n';
    
            display_number_of_steps_message(north_count_1,
                                            south_count_1,
                                            east_count_1,
                                            west_count_1,
                                            feeler);
    
            cout << "\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in  the the_master_function_part_one function" << endl;
            }
            else
            {
                file << "\n\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n\n";
            }
    
            file.close();
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_1_try_1[ 0 ] == 1 )
        {
            *feeler_one_element_zero_equal = "feeler_one_element_zero_equal_one";
    
            element = 2;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            setting_feeler_one_element_zero_to_zero ( left_or_right,
                                                         lowest_value_feeler_1_try_2,
                                                         lowest_value_array_feeler_1_try_2,
                                                         north_array_1_try_2_zero,
                                                         south_array_1_try_2_zero,
                                                         east_array_1_try_2_zero,
                                                         west_array_1_try_2_zero,
                                                         feeler_1_lowest_value_array_direction,
                                                         &feeler_2_lowest_value_array_direction,
                                                         &did_second_feeler_work,
                                                         &north_count_array_1_try_2_zero,
                                                         &south_count_array_1_try_2_zero,
                                                         &east_count_array_1_try_2_zero,
                                                         &west_count_array_1_try_2_zero,
                                                         &left_or_right_1,
                                                         &left_or_right_2,
                                                         &left_or_right_3,
                                                         &left_or_right_4,
                                                         &feeler,
                                                         &element,
                                                         &the_number_of_loops);
    
                cout << '\n';
    
                display_number_of_steps_message(north_count_array_1_try_2_zero,
                                                south_count_array_1_try_2_zero,
                                                east_count_array_1_try_2_zero,
                                                west_count_array_1_try_2_zero,
                                                feeler);
    
                cout << '\n';
    
                cout << "\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n";
    
                cout << '\n';
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "\n\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n\n";
                }
    
                file.close();
    
        }
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 1 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 2 begin
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        north_count_2 = testing_four_directions(north_array_2, left_or_right, 4);
        south_count_2 = testing_four_directions(south_array_2, left_or_right, 5);
        east_count_2 = testing_four_directions(east_array_2, left_or_right, 6);
        west_count_2 = testing_four_directions(west_array_2, left_or_right, 7);
    
        cout << '\n';
    
        feeler = 2;
        element = 1;
    
        direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_2_try_1,
        lowest_value_array_feeler_2_try_1,
        north_array_2,
        south_array_2,
        east_array_2,
        west_array_2,
        &feeler_2_lowest_value_array_direction,
        &north_count_2,
        &south_count_2,
        &east_count_2,
        &west_count_2,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_2_try_1[ 0 ] == 0 )
        {
    
            cout << '\n';
    
            display_number_of_steps_message(north_count_2,
                                            south_count_2,
                                            east_count_2,
                                            west_count_2,
                                            feeler);
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_2_try_1[ 0 ] == 1 )
        {
            while ( 1 )
            {
                element = 3;
                left_or_right_1 = 12;
                left_or_right_2 = 13;
                left_or_right_3 = 14;
                left_or_right_4 = 15;
                first_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                   lowest_value_feeler_2_try_2,
                                                                   lowest_value_array_feeler_2_try_2,
                                                                   north_array_2_try_2_zero_and_odd,
                                                                   south_array_2_try_2_zero_and_odd,
                                                                   east_array_2_try_2_zero_and_odd,
                                                                   west_array_2_try_2_zero_and_odd,
                                                                   feeler_1_lowest_value_array_direction,
                                                                   &feeler_2_lowest_value_array_direction,
                                                                   &did_second_feeler_work,
                                                                   &north_count_array_2_try_2_zero_and_odd,
                                                                   &south_count_array_2_try_2_zero_and_odd,
                                                                   &east_count_array_2_try_2_zero_and_odd,
                                                                   &west_count_array_2_try_2_zero_and_odd,
                                                                   &left_or_right_1,
                                                                   &left_or_right_2,
                                                                   &left_or_right_3,
                                                                   &left_or_right_4,
                                                                   &feeler,
                                                                   &element,
                                                                   &the_number_of_loops);
                if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
                {
                        break;
    
                }
            }
    
    
                display_number_of_steps_message(north_count_array_2_try_2_zero_and_odd,
                                                south_count_array_2_try_2_zero_and_odd,
                                                east_count_array_2_try_2_zero_and_odd,
                                                west_count_array_2_try_2_zero_and_odd,
                                                feeler);
        }
    
        //////////
    
        cout << '\n';
    
        //results = testing_if_feeler_one_lowest_value_is_same_direction_as_feeler_two_lowest_value ( lowest_value_feeler,
                                                                                          //&did_second_feeler_work,
                                                                                          //&version);
    
    
    
            if ( lowest_value_feeler_1_try_1[ 0 ] == lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_1[ 0 ] != lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_unequal";
    
            }
    
            else if ( lowest_value_feeler_1_try_2[ 0 ] == lowest_value_feeler_2_try_2 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_2[ 0 ] != lowest_value_feeler_2_try_2 [ 0 ] )
            {
               did_second_feeler_work = "elements_are_unequal";
            }
    
        // running the second feeler again if it didn't fix the block problem the first time.
    ////
        if ( did_second_feeler_work == "elements_are_equal" )
        {
            int north_array_2_try_3_zero_and_odd[ 9 ];
            int lowest_value_array_feeler_2_try_3[ 9 ];
            int south_array_2_try_3_zero_and_odd[ 9 ];
            int east_array_2_try_3_zero_and_odd[ 9 ];
            int west_array_2_try_3_zero_and_odd[ 9 ];
    
            feeler = 2;
            element = 4;
            left_or_right_1 = 16;
            left_or_right_2 = 17;
            left_or_right_3 = 18;
            left_or_right_4 = 19;
            second_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_3,
                                                                  lowest_value_array_feeler_2_try_3,
                                                                  north_array_2_try_3_zero_and_odd,
                                                                  south_array_2_try_3_zero_and_odd,
                                                                  east_array_2_try_3_zero_and_odd,
                                                                  west_array_2_try_3_zero_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_3_zero_and_odd,
                                                                  &south_count_array_2_try_3_zero_and_odd,
                                                                  &east_count_array_2_try_3_zero_and_odd,
                                                                  &west_count_array_2_try_3_zero_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            display_number_of_steps_message(north_count_array_2_try_3_zero_and_odd,
                                        south_count_array_2_try_3_zero_and_odd,
                                        east_count_array_2_try_3_zero_and_odd,
                                        west_count_array_2_try_3_zero_and_odd,
                                        feeler);
        }
    
    
        cout << '\n';
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting feeler 2 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << "The second feeler did something to unblock feeler 1\n\n";
        cout << "Step 1 ended = make feeler 1 and 2 unequal - gain control.\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in  the the_master_function_part_one function" << endl;
            }
            else
            {
                file << "The second feeler did something to unblock feeler 1\n\n";
                file << "Step 1 ended = make feeler 1 and 2 unequal - gain control.\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            }
    
            file.close();
        }
    
    ////
    
    // begin test here
    
    
    
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making the unequal equal again
    
    ////
            feeler = 2;
            element = 5;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            *less_than_node = setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_4,
                                                                lowest_value_array_feeler_2_try_4,
                                                                north_array_2_try_4_zero_and_even,
                                                                south_array_2_try_4_zero_and_even,
                                                                east_array_2_try_4_zero_and_even,
                                                                west_array_2_try_4_zero_and_even,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_4_zero_and_even,
                                                                &south_count_array_2_try_4_zero_and_even,
                                                                &east_count_array_2_try_4_zero_and_even,
                                                                &west_count_array_2_try_4_zero_and_even,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_4_zero_and_even,
                                        south_count_array_2_try_4_zero_and_even,
                                        east_count_array_2_try_4_zero_and_even,
                                        west_count_array_2_try_4_zero_and_even,
                                        feeler);
    
            cout << "Step 2 ended = make feeler 1 and 2 equal - lose control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "Step 2 ended = make feeler 1 and 2 equal - lose control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making equal unequal again.
    ////
            feeler = 3;
            element = 6;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            third_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_5,
                                                                lowest_value_array_feeler_2_try_5,
                                                                north_array_2_try_5_one_and_odd,
                                                                south_array_2_try_5_one_and_odd,
                                                                east_array_2_try_5_one_and_odd,
                                                                west_array_2_try_5_one_and_odd,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_5_one_and_odd,
                                                                &south_count_array_2_try_5_one_and_odd,
                                                                &east_count_array_2_try_5_one_and_odd,
                                                                &west_count_array_2_try_5_one_and_odd,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_5_one_and_odd,
                                        south_count_array_2_try_5_one_and_odd,
                                        east_count_array_2_try_5_one_and_odd,
                                        west_count_array_2_try_5_one_and_odd,
                                        feeler);
    
            cout << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    file << endl;
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << '\n';
    
        *main_north_count = north_count_1;
        *main_south_count = south_count_1;
        *main_east_count = east_count_1;
        *main_west_count = west_count_1;
    
        set_one_string_array_equal_to_another_string_array ( main_left_or_right, left_or_right );
    
        set_one_int_array_equal_to_another_int_array ( main_north_array, north_array_1 );
    
        set_one_int_array_equal_to_another_int_array ( main_south_array, south_array_1 );
    
        set_one_int_array_equal_to_another_int_array ( main_east_array, east_array_1 );
    
        set_one_int_array_equal_to_another_int_array ( main_west_array, west_array_1 );
    }
    
    void the_master_function_part_two ( string lowest_value_feeler_1_try_1[],
                                       string lowest_value_feeler_1_try_2[],
                                       string main_left_or_right[],
                                       int main_north_array[],
                                       int main_south_array[],
                                       int main_east_array[],
                                       int main_west_array[],
                                       string *feeler_one_element_zero_equal,
                                       string *feeler_1_lowest_value_array_direction,
                                       int *main_north_count,
                                       int *main_south_count,
                                       int *main_east_count,
                                       int *main_west_count,
                                       int *less_than_node,
                                       int *result_of_left_node_test)
    {
    
        string left_or_right[ 20 ];
        string lowest_value_feeler_2_try_1[ 9 ];
        string lowest_value_feeler_2_try_2[ 9 ];
        string lowest_value_feeler_2_try_3[ 9 ];
        string lowest_value_feeler_2_try_4[ 9 ];
        string lowest_value_feeler_2_try_6[ 9 ];
        string feeler_2_lowest_value_array_direction = "";
        string did_second_feeler_work = "";
        int lowest_value_array_feeler_2_try_1[ 9 ];
        int lowest_value_array_feeler_2_try_2[ 9 ];
    
        int lowest_value_array_feeler_2_try_4[ 9 ];
        int lowest_value_array_feeler_2_try_6[ 9 ];
        int direction_value = 0;
        int feeler = 0;
        int element = 0;
        int left_or_right_1 = 0;
        int left_or_right_2 = 0;
        int left_or_right_3 = 0;
        int left_or_right_4 = 0;
        int north_array_1[ 9 ];
        int south_array_1[ 9 ];
        int east_array_1[ 9 ];
        int west_array_1[ 9 ];
        int north_array_2[ 9 ];
        int south_array_2[ 9 ];
        int east_array_2[ 9 ];
        int west_array_2[ 9 ];
    
        int north_array_2_try_2_zero_and_odd[ 9 ];
        int south_array_2_try_2_zero_and_odd[ 9 ];
        int east_array_2_try_2_zero_and_odd[ 9 ];
        int west_array_2_try_2_zero_and_odd[ 9 ];
    
        int north_array_2_try_4_zero_and_even[ 9 ];
        int south_array_2_try_4_zero_and_even[ 9 ];
        int east_array_2_try_4_zero_and_even[ 9 ];
        int west_array_2_try_4_zero_and_even[ 9 ];
    
        int north_array_2_try_6_one_and_odd[ 9 ];
        int south_array_2_try_6_one_and_odd[ 9 ];
        int east_array_2_try_6_one_and_odd[ 9 ];
        int west_array_2_try_6_one_and_odd[ 9 ];
    
        int north_element_0[ 9 ];
        int south_element_0[ 9 ];
        int east_element_0[ 9 ];
        int west_element_0[ 9 ];
    
        int north_count_2 = 0;
        int south_count_2 = 0;
        int east_count_2 = 0;
        int west_count_2 = 0;
    
        int north_count_array_2_try_2_zero_and_odd = 0;
        int south_count_array_2_try_2_zero_and_odd = 0;
        int east_count_array_2_try_2_zero_and_odd = 0;
        int west_count_array_2_try_2_zero_and_odd = 0;
    
        int north_count_array_2_try_3_zero_and_odd = 0;
        int south_count_array_2_try_3_zero_and_odd = 0;
        int east_count_array_2_try_3_zero_and_odd = 0;
        int west_count_array_2_try_3_zero_and_odd = 0;
    
        int north_count_array_2_try_4_zero_and_even = 0;
        int south_count_array_2_try_4_zero_and_even = 0;
        int east_count_array_2_try_4_zero_and_even = 0;
        int west_count_array_2_try_4_zero_and_even = 0;
    
        int north_count_array_2_try_6_one_and_odd = 0;
        int south_count_array_2_try_6_one_and_odd = 0;
        int east_count_array_2_try_6_one_and_odd = 0;
        int west_count_array_2_try_6_one_and_odd = 0;
    
        int the_number_of_loops = 0;
        int greater_than_node = 0;
    
        set_array_value_to_zero( north_element_0 );
    
        set_array_value_to_zero( south_element_0 );
    
        set_array_value_to_zero( east_element_0 );
    
        set_array_value_to_zero( west_element_0 );
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting step 1
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        set_one_string_array_equal_to_another_string_array ( left_or_right, main_left_or_right );
    
        set_one_int_array_equal_to_another_int_array ( north_array_1, main_north_array );
    
        set_one_int_array_equal_to_another_int_array ( south_array_1, main_south_array );
    
        set_one_int_array_equal_to_another_int_array ( east_array_1, main_east_array );
    
        set_one_int_array_equal_to_another_int_array ( west_array_1, main_west_array );
    
    
        north_count_2 = testing_four_directions(north_array_2, left_or_right, 4);
        south_count_2 = testing_four_directions(south_array_2, left_or_right, 5);
        east_count_2 = testing_four_directions(east_array_2, left_or_right, 6);
        west_count_2 = testing_four_directions(west_array_2, left_or_right, 7);
        display_number_of_steps_message(north_count_2, south_count_2,east_count_2, west_count_2, 2);
    
        cout << '\n';
    
        feeler = 2;
        element = 1;
    
        direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_2_try_1,
        lowest_value_array_feeler_2_try_1,
        north_array_2,
        south_array_2,
        east_array_2,
        west_array_2,
        &feeler_2_lowest_value_array_direction,
        &north_count_2,
        &south_count_2,
        &east_count_2,
        &west_count_2,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_2_try_1[ 0 ] == 0 )
        {
    
            cout << '\n';
    
            display_number_of_steps_message(north_count_2,
                                            south_count_2,
                                            east_count_2,
                                            west_count_2,
                                            feeler);
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_2_try_1[ 0 ] == 1 )
        {
            while ( 1 )
            {
                element = 3;
                left_or_right_1 = 12;
                left_or_right_2 = 13;
                left_or_right_3 = 14;
                left_or_right_4 = 15;
                first_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                   lowest_value_feeler_2_try_2,
                                                                   lowest_value_array_feeler_2_try_2,
                                                                   north_array_2_try_2_zero_and_odd,
                                                                   south_array_2_try_2_zero_and_odd,
                                                                   east_array_2_try_2_zero_and_odd,
                                                                   west_array_2_try_2_zero_and_odd,
                                                                   feeler_1_lowest_value_array_direction,
                                                                   &feeler_2_lowest_value_array_direction,
                                                                   &did_second_feeler_work,
                                                                   &north_count_array_2_try_2_zero_and_odd,
                                                                   &south_count_array_2_try_2_zero_and_odd,
                                                                   &east_count_array_2_try_2_zero_and_odd,
                                                                   &west_count_array_2_try_2_zero_and_odd,
                                                                   &left_or_right_1,
                                                                   &left_or_right_2,
                                                                   &left_or_right_3,
                                                                   &left_or_right_4,
                                                                   &feeler,
                                                                   &element,
                                                                   &the_number_of_loops);
                if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
                {
                        break;
    
                }
            }
        }
    
        //////////
    
        cout << '\n';
    
        //results = testing_if_feeler_one_lowest_value_is_same_direction_as_feeler_two_lowest_value ( lowest_value_feeler,
                                                                                          //&did_second_feeler_work,
                                                                                          //&version);
    
    
    
            if ( lowest_value_feeler_1_try_1[ 0 ] == lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_1[ 0 ] != lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_unequal";
    
            }
    
            else if ( lowest_value_feeler_1_try_2[ 0 ] == lowest_value_feeler_2_try_2 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_2[ 0 ] != lowest_value_feeler_2_try_2 [ 0 ] )
            {
               did_second_feeler_work = "elements_are_unequal";
    
            }
    
        // running the second feeler again if it didn't fix the block problem the first time.
    ////
        if ( did_second_feeler_work == "elements_are_equal" )
        {
            int lowest_value_array_feeler_2_try_3[ 9 ];
            int north_array_2_try_3_zero_and_odd[ 9 ];
            int south_array_2_try_3_zero_and_odd[ 9 ];
            int east_array_2_try_3_zero_and_odd[ 9 ];
            int west_array_2_try_3_zero_and_odd[ 9 ];
    
            feeler = 2;
            element = 4;
            left_or_right_1 = 16;
            left_or_right_2 = 17;
            left_or_right_3 = 18;
            left_or_right_4 = 19;
            second_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_3,
                                                                  lowest_value_array_feeler_2_try_3,
                                                                  north_array_2_try_3_zero_and_odd,
                                                                  south_array_2_try_3_zero_and_odd,
                                                                  east_array_2_try_3_zero_and_odd,
                                                                  west_array_2_try_3_zero_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_3_zero_and_odd,
                                                                  &south_count_array_2_try_3_zero_and_odd,
                                                                  &east_count_array_2_try_3_zero_and_odd,
                                                                  &west_count_array_2_try_3_zero_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            display_number_of_steps_message(north_count_array_2_try_3_zero_and_odd,
                                        south_count_array_2_try_3_zero_and_odd,
                                        east_count_array_2_try_3_zero_and_odd,
                                        west_count_array_2_try_3_zero_and_odd,
                                        feeler);
        }
    
    
        cout << '\n';
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting feeler 2 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << "The second feeler did something to unblock feeler 1\n\n";
        cout << "Step 4 ended = make feeler 1 and 2 unequal - gain control.\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "The second feeler did something to unblock feeler 1\n\n";
                file << "Step 4 ended = make feeler 1 and 2 unequal - gain control.\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            }
    
            file.close();
        }
    
    ////
    
    // begin test here
    
    
    
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making the unequal equal again
    
    ////
            feeler = 2;
            element = 5;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            greater_than_node = setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_4,
                                                                lowest_value_array_feeler_2_try_4,
                                                                north_array_2_try_4_zero_and_even,
                                                                south_array_2_try_4_zero_and_even,
                                                                east_array_2_try_4_zero_and_even,
                                                                west_array_2_try_4_zero_and_even,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_4_zero_and_even,
                                                                &south_count_array_2_try_4_zero_and_even,
                                                                &east_count_array_2_try_4_zero_and_even,
                                                                &west_count_array_2_try_4_zero_and_even,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_4_zero_and_even,
                                        south_count_array_2_try_4_zero_and_even,
                                        east_count_array_2_try_4_zero_and_even,
                                        west_count_array_2_try_4_zero_and_even,
                                        feeler);
    
            cout << "Step 5 ended = make feeler 1 and 2 equal - lose control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "Step 5 ended = make feeler 1 and 2 equal - lose control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making equal unequal again.
    ////
            feeler = 3;
            element = 7;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            fourth_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_6,
                                                                  lowest_value_array_feeler_2_try_6,
                                                                  north_array_2_try_6_one_and_odd,
                                                                  south_array_2_try_6_one_and_odd,
                                                                  east_array_2_try_6_one_and_odd,
                                                                  west_array_2_try_6_one_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_6_one_and_odd,
                                                                  &south_count_array_2_try_6_one_and_odd,
                                                                  &east_count_array_2_try_6_one_and_odd,
                                                                  &west_count_array_2_try_6_one_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            display_number_of_steps_message(north_count_array_2_try_6_one_and_odd,
                                        south_count_array_2_try_6_one_and_odd,
                                        east_count_array_2_try_6_one_and_odd,
                                        west_count_array_2_try_6_one_and_odd,
                                        feeler);
    
            cout << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "Step 6 ended = make feeler 1 and 2 unequal - regain control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << '\n';
    
        if ( greater_than_node > *less_than_node )
        {
            cout << "greater than node: " << greater_than_node << ", is greater than less than node: " << *less_than_node << '\n';
            cout << "Added left node, start turning.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is greater than less than node: " << *less_than_node << '\n';
                file << "Added left node, start turning.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 0;
        }
        else if( *less_than_node > greater_than_node )
        {
            cout << "greater than node: " << greater_than_node << ", is not greater than less than node: " << *less_than_node << '\n';
            cout << "Didn\'t add left node, no turning, go straight.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is not greater than less than node: " << *less_than_node << '\n';
                file << "Didn\'t add left node, no turning, go straight.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 1;
        }
        else
        {
            cout << "greater than node: " << greater_than_node << ", is equal to less than node: " << *less_than_node << '\n';
            cout << "Didn\'t add left node, no turning, go straight.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is equal to less than node: " << *less_than_node << '\n';
                file << "Didn\'t add left node, no turning, go straight.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 1;
        }
    }
    
    void which_team_scored( int *try_again, int *good_job )
    {
        if ( *try_again == 0)
        {
            cout << "\nteam 2 won.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nteam 2 won.\n";
            }
    
            file.close();
    
        }
        else if ( *try_again == 1 )
        {
            cout << "\nteam 1 won.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nteam 1 won.\n";
            }
    
            file.close();
        }
        else if ( *try_again % 2 == 0 )
        {
            cout << "\nteam 2 won.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nteam 2 won.\n";
            }
    
            file.close();
        }
        else if ( *try_again % 2 == 1 )
        {
            cout << "\nteam 1 won.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nteam 1 won.\n";
            }
    
            file.close();
        }
    }
    
    void display_message_about_stack_layer_part_two( int *stack_layer_one,
                                                     int *stack_layer_two,
                                                     int *stack_layer_three,
                                                     int *stack_layer_four)
    {
        if ( *stack_layer_one == 0 )
             {
                 cout << "- stack layer 1 value is too low\n";
                 cout << "meaning it went bad at catching the ball.\n";
    
                 {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "- stack layer 1 value is too low\n";
                        file << "meaning it went bad at catching the ball.\n";
                    }
    
                    file.close();
                }
             }
             if ( *stack_layer_two == 0 )
             {
                 cout << "- stack layer 2 value is too low\n";
    
                 {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "- stack layer 2 value is too low\n";
                    }
    
                    file.close();
                }
                 if ( *stack_layer_one > 0 )
                 {
                     cout << "meaning it went bad at controlling the ball once cought.\n";
    
                     {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "meaning it went bad at controlling the ball once cought.\n";
                        }
    
                        file.close();
                    }
                 }
             }
             if ( *stack_layer_three == 0 )
             {
                 cout << "- stack layer 3 value is too low\n";
    
                 {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "- stack layer 3 value is too low\n";
                    }
    
                    file.close();
                }
                 if ( (*stack_layer_one > 0) && (*stack_layer_two> 0) )
                 {
                     cout << "meaning it went bad at tossing the ball to the other hand to throw.\n";
    
                     {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "meaning it went bad at tossing the ball to the other hand to throw.\n";
                        }
    
                        file.close();
                    }
                 }
             }
             if ( *stack_layer_four == 0 )
             {
                 cout << "- stack layer 4 value is too low\n";
    
                 {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "- stack layer 4 value is too low\n";
                    }
    
                    file.close();
                }
                 if (  (*stack_layer_one > 0) && (*stack_layer_two> 0)  && (*stack_layer_three > 0 ) )
                 {
                     cout << "meaning it went bad at throwing the ball.\n\n";
    
                     {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "meaning it went bad at throwing the ball.\n\n";
                        }
    
                        file.close();
                    }
                 }
             }
    }
    
    void display_message_about_stack_layer_part_one( int array[],
                                                     int *first_array_one_counter,
                                                     int *second_array_one_counter,
                                                     int *third_array_one_counter,
                                                     int *stack_layer_one,
                                                     int *stack_layer_two,
                                                     int *stack_layer_three,
                                                     int *stack_layer_four)
    {
        if ( (*first_array_one_counter == *second_array_one_counter) && (*first_array_one_counter == *third_array_one_counter) )
        {
            cout << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
                }
    
                file.close();
            }
    
            int counter = 0;
    
            for ( int i = 0; i < 8; i++ )
            {
    
                counter += 1;
    
                if ( counter == 1 || counter == 2 )
                {
                    if ( array[ i ] == 1 )
                    {
                        *stack_layer_one += 1;
                    }
                }
                else if ( counter == 3 || counter == 4 )
                {
                    if ( array[ i ] == 1 )
                    {
                        *stack_layer_two += 1;
                    }
                }
                else if ( counter == 5 || counter == 6 )
                {
                    if ( array[ i ] == 1 )
                    {
                        *stack_layer_three += 1;
                    }
                }
                else if ( counter == 7 || counter == 8 )
                {
                    if ( array[ i ] == 1 )
                    {
                        *stack_layer_four += 1;
                    }
                }
            }
    
        }
    
        if ( (*first_array_one_counter == *second_array_one_counter) && (*first_array_one_counter < *third_array_one_counter) )
            {
                cout << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 0; i < 8; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
    
            }
    
            if ( (*first_array_one_counter == *second_array_one_counter) && (*first_array_one_counter > *third_array_one_counter) )
            {
                cout << "\nThird array needs to change one or more stack layers to a higher one value.\n\n";
                cout << "\nThis is the right most array on the binary search tree\n";
                cout << "That means did you score phase\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nThird array needs to change one or more stack layers to a higher one value.\n\n";
                        file << "\nThis is the second right most array on the binary search tree\n";
                        cout << "That means did you score phase\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 18; i < 26; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
    
            if ( (*first_array_one_counter == *third_array_one_counter) && (*first_array_one_counter < *second_array_one_counter) )
            {
                cout << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 0; i < 8; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
    
            if ( (*first_array_one_counter == *third_array_one_counter) && (*first_array_one_counter > *second_array_one_counter) )
            {
                cout << "\nSecond array needs to change one or more stack layers to a higher one value.\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nSecond array needs to change one or more stack layers to a higher one value.\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 9; i < 17; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
    
            if ( (*third_array_one_counter == *second_array_one_counter ) && (*first_array_one_counter < *second_array_one_counter )  )
            {
                cout << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 0; i < 8; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
    
            if ( (*third_array_one_counter == *second_array_one_counter ) && (*first_array_one_counter > *second_array_one_counter )  )
            {
                cout << "\nSecond array needs to change one or more stack layers to a higher one value.\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nSecond array needs to change one or more stack layers to a higher one value.\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 9; i < 17; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
    
        if ( (*first_array_one_counter < *second_array_one_counter) && (*first_array_one_counter < *third_array_one_counter) )
            {
                cout << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
                cout << "\nThis is the left most array on the binary search tree\n";
                cout << "That means this is the catch and control phase\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
                        file << "\nThis is the left most array on the binary search tree\n";
                        file << "That means this is the catch and control phase\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 0; i < 8; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
    
            }
    
            if ( (*second_array_one_counter < *first_array_one_counter  ) && (*second_array_one_counter < *third_array_one_counter  ) )
            {
                cout << "\nSecond array needs to change one or more stack layers to a higher one value.\n\n";
                cout << "\nThis is the second right most array on the binary search tree\n";
                cout << "That means this is the catch and shoot the puck phase\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nSecond array needs to change one or more stack layers to a higher one value.\n\n";
                        file << "\nThis is the second right most array on the binary search tree\n";
                        file << "That means this is the catch and shoot the puck phase\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 9; i < 17; i++ )
                {
    
                    counter += 1;
    
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
            if ( (*third_array_one_counter < *first_array_one_counter  ) && (*third_array_one_counter < *second_array_one_counter) )
            {
                cout << "\nThird array needs to change one or more stack layers to a higher one value.\n\n";
                cout << "\nThis is the right most array on the binary search tree\n";
                cout << "That means did you score phase\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nThird array needs to change one or more stack layers to a higher one value.\n\n";
                        file << "\nThis is the second right most array on the binary search tree\n";
                        cout << "That means did you score phase\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 18; i < 26; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
    }
    
    void reading_the_results_of_listening_to_the_sound_made_by_the_array_function ( int *zero_counter, int *one_counter )
    {
    
        ifstream input("array_used_for_sound.txt");
        if( input.fail() )
        {
            cout << "error while opening the file in the main function" << endl;
        }
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
        cout << "counting 27 array elements to find 1, 0, value...\n\nresults\n";
        cout << "zero = " << *zero_counter << '\n';
        cout << "one = " << *one_counter << '\n';
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                file << "counting 27 array elements to find 1, 0, value...\n\nresults\n";
                file << "zero = " << *zero_counter << '\n';
                file << "one = " << *one_counter << '\n';
            }
    
            file.close();
        }
    
        if ( *one_counter > *zero_counter )
        {
            cout << "\none is greater, \nmeaning the winning team actually won in real life.\n\n";
    
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << "\none is greater, \nmeaning the winning team actually won in real life.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
        }
        else
        {
            cout << "\none is less than or equal to zero value,\nmeaning the winning team actually lost in real life.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << "\none is less than or equal to zero value,\nmeaning the winning team actually lost in real life.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
            int first_array_one_counter = 0;
            int first_array_zero_counter = 0;
    
            int second_array_one_counter = 0;
            int second_array_zero_counter = 0;
    
            int third_array_one_counter = 0;
            int third_array_zero_counter = 0;
    
            int array[ 27 ];
    
            // reading 27 numbers from array file into array so I can count the three arrays zero one values
            for ( int i = 0; i < 27; i++ )
            {
                input >> array[ i ];
            }
    
            // input array that does not match the generated array
            for ( int i = 0; i < 8; i++ )
            {
                if ( array [ i ] == 0 )
                {
                    first_array_zero_counter++;
                }
                else if ( array [ i ] == 1 )
                {
                    first_array_one_counter++;
                }
            }
    
            // input array that matches the generated array
            for ( int i = 9; i < 17; i++ )
            {
                if ( array [ i ] == 0 )
                {
                    second_array_zero_counter++;
                }
                else if ( array [ i ] == 1 )
                {
                    second_array_one_counter++;
                }
            }
    
            // the generated output array
            for ( int i = 18; i < 26; i++ )
            {
                if ( array [ i ] == 0 )
                {
                    third_array_zero_counter++;
                }
                else if ( array [ i ] == 1 )
                {
                    third_array_one_counter++;
                }
            }
    
            cout << "\ncounting 24 array elements, not 27\n";
    
            cout << "\n# of 0 in first array = " << first_array_zero_counter << '\n';
            cout << "# of 1 in first array = " << first_array_one_counter << '\n';
    
            cout << "\n# of 0 in second array = " << second_array_zero_counter << '\n';
            cout << "# of 1 in second array = " << second_array_one_counter << '\n';
    
            cout << "\n# of 0 in third array = " << third_array_zero_counter << '\n';
            cout << "# of 1 in third array = " << third_array_one_counter << '\n';
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << "\ncounting 24 array elements, not 27\n";
    
                    file << "\n# of 0 in first array = " << first_array_zero_counter << '\n';
                    file << "# of 1 in first array = " << first_array_one_counter << '\n';
    
                    file << "\n# of 0 in second array = " << second_array_zero_counter << '\n';
                    file << "# of 1 in second array = " << second_array_one_counter << '\n';
    
                    file << "\n# of 0 in third array = " << third_array_zero_counter << '\n';
                    file << "# of 1 in third array = " << third_array_one_counter << '\n';
                }
    
                file.close();
            }
    
            int stack_layer_one = 0;
            int stack_layer_two = 0;
            int stack_layer_three = 0;
            int stack_layer_four = 0;
    
            display_message_about_stack_layer_part_one( array,
                                                       &first_array_one_counter,
                                                        &second_array_one_counter,
                                                        &third_array_one_counter,
                                                        &stack_layer_one,
                                                        &stack_layer_two,
                                                        &stack_layer_three,
                                                        &stack_layer_four);
    
            cout << "\nWhich stack layer needs to be changed?\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << "\nWhich stack layer needs to be changed?\n\n";
                }
    
                file.close();
            }
    
             display_message_about_stack_layer_part_two( &stack_layer_one,
                                                         &stack_layer_two,
                                                         &stack_layer_three,
                                                         &stack_layer_four);
    
             cout << "\nstack layer 1 value: " << stack_layer_one << '\n';
             cout << "\nstack layer 2 value: " << stack_layer_two << '\n';
             cout << "\nstack layer 3 value: " << stack_layer_three << '\n';
             cout << "\nstack layer 4 value: " << stack_layer_four << '\n' << '\n';
    
             {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << "\nstack layer 1 value: " << stack_layer_one << '\n';
                    file << "\nstack layer 2 value: " << stack_layer_two << '\n';
                    file << "\nstack layer 3 value: " << stack_layer_three << '\n';
                    file << "\nstack layer 4 value: " << stack_layer_four << '\n' << '\n';
                }
    
                file.close();
            }
        }
    
        input.close();
    
    }
    
    void listening_to_the_sound_made_by_the_array()
    {
        int zero_counter = 0;
        int one_counter = 0;
    
    
        int i;
        int counter = 0;
        int counter_to_add_new_sound = 0;
    
        ifstream input("array_used_for_sound.txt");
    
        if( input.fail() )
        {
            cout << "error while opening the file in the main function" << endl;
        }
    
        cout << "\nListen...";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nListen...";
            }
    
            file.close();
        }
    
        while ( input >> i)
        {
            counter_to_add_new_sound += 1;
            counter += 1;
    
            if( counter == 2)
            {
                Sleep( 400 );
            }
            else if ( counter == 4 )
            {
                Sleep( 250 );
            }
            if ( counter_to_add_new_sound  == 4 )
            {
                Beep(400,210);
                Beep(500,210);
                Beep(600,210);
            }
            else if ( counter_to_add_new_sound  == 8 )
            {
                Beep(400,210);
                Beep(500,210);
                Beep(600,210);
            }
            else if ( counter_to_add_new_sound  == 12 )
            {
                Beep(400,210);
                Beep(500,210);
                Beep(600,210);
    
            }
            else if ( counter_to_add_new_sound  == 16 )
            {
                Beep(1000,210);
                Beep(1100,210);
                Beep(1200,210);
                counter_to_add_new_sound = 0;
            }
    
    
            if ( i == 0 )
            {
                zero_counter += 1;
                Beep(400,150);
            }
            else if ( i == 1 )
            {
                one_counter += 1;
                Beep(900, 150);
            }
                counter = 0;
        }
    
        input.close();
    
        cout << "I can hear it!\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "I can hear it!\n\n";
            }
    
            file.close();
        }
    
        for ( int i = 0; i < zero_counter; i+= 1 )
        {
            Beep(400,150);
        }
    
        for ( int i = 0; i < one_counter; i+= 1 )
        {
            Beep(900, 150);
        }
    
        reading_the_results_of_listening_to_the_sound_made_by_the_array_function( &zero_counter, &one_counter );
    }
    
    void writing_array_to_file_to_listen_to_after_program_ends( int array[])
    {
        for ( int i = 0; i < 9; i++ )
        {
            fstream file("array_used_for_sound.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << array[ i ] << endl;
            }
    
            file.close();
        }
    }
    
    int displaying_the_test_results_from_running_the_two_main_function(
                                                                       int compare_to_output_array_1[],
                                                                       int compare_to_output_array_2[],
                                                                       int the_random_list_generated_by_the_left_node_results_array[],
                                                                       int *counting_matching_array_elements_1,
                                                                       int *counting_matching_array_elements_2,
                                                                       int *counting_left_nodes_1,
                                                                       int *counting_left_nodes_2,
                                                                       int *try_again,
                                                                       int *good_job)
    {
        int break_or_not = 0;
    
        if ( *counting_matching_array_elements_1 > *counting_matching_array_elements_2 )
            {
                if ( *counting_left_nodes_1 < *counting_left_nodes_2 )
                {
    
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was met: Good job!.\n\n";
                    cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was met: Good job!.\n\n";
                            file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
    
                    writing_array_to_file_to_listen_to_after_program_ends( compare_to_output_array_2);
                    writing_array_to_file_to_listen_to_after_program_ends( compare_to_output_array_1);
                    writing_array_to_file_to_listen_to_after_program_ends( the_random_list_generated_by_the_left_node_results_array);
                    displayArray( compare_to_output_array_1, 9 );
                    *good_job += 1;
                    break_or_not = 1;
                }
                else
                {
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was not met: Try again.\n\n";
                    cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was not met: Try again.\n\n";
                            file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_1, 9 );
    
                    *try_again += 1;
                }
            }
            else if ( *counting_matching_array_elements_2 > *counting_matching_array_elements_1 )
            {
                if ( *counting_left_nodes_2 < *counting_left_nodes_1 )
                {
                    cout << "The goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was met: Good job!.\n\n";
                    cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "The goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was met: Good job!.\n\n";
                            file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    writing_array_to_file_to_listen_to_after_program_ends( compare_to_output_array_1);
                    writing_array_to_file_to_listen_to_after_program_ends( compare_to_output_array_2);
                    writing_array_to_file_to_listen_to_after_program_ends( the_random_list_generated_by_the_left_node_results_array);
                    displayArray( compare_to_output_array_2, 9 );
                    *good_job += 1;
                    break_or_not = 1;
                }
                else
                {
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was not met: Try again.\n\n";
                    cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was not met: Try again.\n\n";
                            file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    displayArray( compare_to_output_array_2, 9 );
                    *try_again += 1;
                }
            }
    
            return break_or_not;
    }
    
    void running_the_two_main_functions( int compare_to_output_array_1[],
                                        int compare_to_output_array_2[],
                                        int the_random_list_generated_by_the_left_node_results_array[],
                                        int *try_again,
                                        int *good_job )
    {
        string lowest_value_feeler_1_try_1[ 9 ];
        string lowest_value_feeler_1_try_2[ 9 ];
        string left_or_right[ 4 ];
        int north_array[ 9 ];
        int south_array[ 9 ];
        int east_array[ 9 ];
        int west_array[ 9 ];
        string feeler_1_lowest_value_array_direction = "";
        string feeler_one_element_zero_equal = "";
        int north_count_1 = 0;
        int south_count_1 = 0;
        int east_count_1 = 0;
        int west_count_1 = 0;
        int less_than_node = 0;
        int result_of_left_node_test = 0;
    
            while ( 1 )
        {
            north_count_1 = 0;
            south_count_1 = 0;
            east_count_1 = 0;
            west_count_1 = 0;
            less_than_node = 0;
            result_of_left_node_test = 0;
            int counting_matching_array_elements_1 = 0;
            int counting_matching_array_elements_2 = 0;
            int counting_left_nodes_1 = 0;
            int counting_left_nodes_2 = 0;
    
            for ( int i = 0; i < 9; i++ )
            {
                the_master_function_part_one(lowest_value_feeler_1_try_1,
                                         lowest_value_feeler_1_try_2,
                                         left_or_right,
                                         north_array,
                                         south_array,
                                         east_array,
                                         west_array,
                                         &feeler_one_element_zero_equal,
                                         &feeler_1_lowest_value_array_direction,
                                         &north_count_1,
                                         &south_count_1,
                                         &east_count_1,
                                         &west_count_1,
                                         &less_than_node);
    
            the_master_function_part_two(lowest_value_feeler_1_try_1,
                                         lowest_value_feeler_1_try_2,
                                         left_or_right,
                                         north_array,
                                         south_array,
                                         east_array,
                                         west_array,
                                         &feeler_one_element_zero_equal,
                                         &feeler_1_lowest_value_array_direction,
                                         &north_count_1,
                                         &south_count_1,
                                         &east_count_1,
                                         &west_count_1,
                                         &less_than_node,
                                         &result_of_left_node_test);
    
            the_random_list_generated_by_the_left_node_results_array[ i ] = result_of_left_node_test;
            }
    
            for ( int i = 0; i < 9; i++ )
            {
                // keep the numbers small so they're easy to read
                compare_to_output_array_2[ i ] = rand() % 2;
            }
    
            for ( int i = 0; i < 9; i++ )
            {
                // counting left nodes in the 2 arrays
                if ( compare_to_output_array_1[ i ] == 0 )
                {
                    counting_left_nodes_1 += 1;
                }
                if ( compare_to_output_array_2[ i ] == 0 )
                {
                    counting_left_nodes_2 += 1;
                }
    
                // comparing the elements of the two arrays to the results array to find matching elements
                if (compare_to_output_array_1[ i ] == the_random_list_generated_by_the_left_node_results_array [ i ] )
                {
                    counting_matching_array_elements_1 += 1;
                }
                if (compare_to_output_array_2[ i ] == the_random_list_generated_by_the_left_node_results_array[ i ] )
                {
                    counting_matching_array_elements_2 += 1;
                }
            }
    
            int break_or_not = displaying_the_test_results_from_running_the_two_main_function(
                                                                        compare_to_output_array_1,
                                                                        compare_to_output_array_2,
                                                                        the_random_list_generated_by_the_left_node_results_array,
                                                                        &counting_matching_array_elements_1,
                                                                        &counting_matching_array_elements_2,
                                                                        &counting_left_nodes_1,
                                                                        &counting_left_nodes_2,
                                                                        try_again,
                                                                        good_job);
    
            if ( break_or_not == 1 )
            {
                break;
            }
        }
    }
    
    int main ()
    {
        int compare_to_output_array_1[ 9 ];
        int compare_to_output_array_2[ 9 ];
        int the_random_list_generated_by_the_left_node_results_array[ 9 ];
        int try_again = 0;
        int good_job = 0;
        srand( time( NULL ) );
    
    
        set_array_value_to_zero( compare_to_output_array_1 );
        set_array_value_to_zero( compare_to_output_array_2 );
        set_array_value_to_zero( the_random_list_generated_by_the_left_node_results_array );
    
        // clear text file
        {
            fstream file("text_from_program.txt", ios::out | ios::trunc);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
    
    
            file.close();
        }
    
        // clear text file
        {
            fstream file("array_used_for_sound.txt", ios::out | ios::trunc);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
    
    
            file.close();
        }
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            cout << "Starting program\n";
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "Starting program\n\n";
            }
            file.close();
        }
    
        for ( int i = 0; i < 9; i++ )
        {
            // keep the numbers small so they're easy to read
            compare_to_output_array_1[ i ] = rand() % 2;
        }
    
        running_the_two_main_functions( compare_to_output_array_1,
                                        compare_to_output_array_2,
                                        the_random_list_generated_by_the_left_node_results_array,
                                        &try_again,
                                        &good_job );
    
    
    
        cout << '\n';
        cout << "\ngenerated input list 1\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "\ngenerated input list 1\n";
            }
    
            file.close();
        }
    
        displayArray( compare_to_output_array_1, 9 );
        cout << '\n';
        cout << "generated input list 2\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated input list 2\n";
            }
    
            file.close();
        }
    
        displayArray( compare_to_output_array_2, 9 );
        cout << '\n';
        cout << "generated results list\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated results list\n";
            }
    
            file.close();
        }
    
        displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
        cout << "\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
        cout << "\n\nscore:\n";
        cout << "Number of times won = " << good_job << '\n';
        cout << "Number of retries until won = " << try_again << '\n';
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                file << "\n\nscore:\n";
                file << "Number of times won = " << good_job << '\n';
                file << "Number of retries until won = " << try_again << '\n';
            }
    
            file.close();
        }
    
        which_team_scored( &try_again, &good_job );
    
        cout << "\nEnding program\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
        cout << "Begin analysis of the sound the 27 array elements make.\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\n\n";
    
                file << "\nEnding program\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                file << "Begin analysis of the sound the 27 array elements make.\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            }
    
            file.close();
        }
    
        cout << "listening to the sound the arrays make\n";
        listening_to_the_sound_made_by_the_array();
    
        getchar();
    
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recursion slows down mysteriously
    By brane_sail in forum C++ Programming
    Replies: 9
    Last Post: 03-20-2008, 07:03 AM
  2. My script slows down how do I fix this??
    By JordanCason in forum C++ Programming
    Replies: 10
    Last Post: 11-25-2007, 11:43 PM
  3. What slows down if statements?
    By Hunter2 in forum C++ Programming
    Replies: 3
    Last Post: 05-30-2003, 03:37 PM
  4. directory and file crawl
    By atari400 in forum C++ Programming
    Replies: 4
    Last Post: 04-24-2003, 05:04 PM
  5. Program slows down system
    By Mox in forum Windows Programming
    Replies: 1
    Last Post: 10-23-2001, 08:11 AM

Tags for this Thread