Author Topic: [RELEASE] Last Dozen/Column generator v0.1  (Read 4771 times)

0 Members and 1 Guest are viewing this topic.

Offline VLS

  • OneNumber.cc
  • Hero Member
  • *****
  • Posts: 2968
  • Gender: Male
  • OneNumber.cc
    • View Profile
[RELEASE] Last Dozen/Column generator v0.1
« on: December 10, 2012, 02:15:31 am »
This humble program is a workhorse programmed in C++



Download: * LasDC_Lw_Generator_0-1.zip

It takes a file with roulette numbers (one per line) and outputs:

<file>-dozens.txt
<file>-dozens-debug.txt
<file>-columns.txt
<file>-columns-debug.txt

Even Gigabyte files are welcomed by it ;)

Enjoy!  :nod:
Vic

Code: (cpp) [Select]
#include <windows.h>
#include <fstream>
#include <deque>
#include <string>

// Identifiers.
#define IDC_BUTTON 2000

// Globals
HINSTANCE instance;
HWND hwnd;
HFONT h_font;
std::deque<int> dozens; // Deque as LIFO queue for dozens
std::deque<int> columns; // Deque as LIFO queue for columns

// Prototypes
int GetDozen(int num);
int GetColumn(int num);

// Declare window procedure
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

// Class name as global
char szClassName[ ] = "LastDCGen";

// Program's entrypoint
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
    instance = hThisInstance;
    MSG messages;
    WNDCLASSEX wincl;

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;
    wincl.style = CS_DBLCLKS;
    wincl.cbSize = sizeof (WNDCLASSEX);
    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;
    wincl.cbClsExtra = 0;
    wincl.cbWndExtra = 0;
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
               0,
               szClassName, /* Classname */
               "LastDC Lw Generator",  /* Title Text */
               WS_OVERLAPPEDWINDOW &~ WS_MAXIMIZEBOX &~ WS_MINIMIZEBOX, /* no min/max button */
               CW_USEDEFAULT,
               CW_USEDEFAULT,
               190, /* Width */
               100, /* Height */
               HWND_DESKTOP, /* The window is a child-window to desktop */
               NULL, /* No menu */
               hThisInstance,  /* Program Instance handler */
               NULL
           );

    // Center it
    RECT rc;
    int screenWidth = GetSystemMetrics(SM_CXSCREEN);
    int screenHeight = GetSystemMetrics(SM_CYSCREEN);
    GetWindowRect(hwnd, &rc);
    SetWindowPos(hwnd, 0, (screenWidth - rc.right)/2, (screenHeight - rc.bottom)/2, 0, 0, SWP_NOZORDER|SWP_NOSIZE);

    // Set Font
    h_font = CreateFont(-13, 0, 0, 0, FW_NORMAL, 0,
                        0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
                        DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Times New Roman");

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);

        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

// Window Procedure
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    // Handle messages
    switch (message)
    {

        // Form creation
    case WM_CREATE:

        // Create button
        HWND wnd;
        wnd = CreateWindowEx(0x00000000, "Button", "Select file", 0x50010001, 8, 16, 96, 32, hwnd, (HMENU) IDC_BUTTON, instance, NULL);
        SendMessage(wnd, WM_SETFONT, (WPARAM) h_font, TRUE);

        // Emulate button press
        break;

        // Handle user command
    case WM_COMMAND:
        switch (wParam)
        {
        case IDC_BUTTON:
            // Open file name
            OPENFILENAME ofn;

            // Memory buffer to contain file name
            char szFile[MAX_PATH+1];

            // Open file dialog
            ZeroMemory( &ofn , sizeof( ofn));
            ofn.lStructSize = sizeof ( ofn );
            ofn.hwndOwner = NULL ;
            ofn.lpstrFile = szFile ;
            ofn.lpstrFile[0] = '\0';
            ofn.nMaxFile = sizeof( szFile );
            ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
            ofn.nFilterIndex =1;
            ofn.lpstrFileTitle = NULL ;
            ofn.nMaxFileTitle = 0 ;
            ofn.lpstrInitialDir=NULL ;
            ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ;

            // Invoke file dialog
            if (GetOpenFileName( &ofn ))
            {
                // ifstream from file
                std::ifstream file(ofn.lpstrFile);

                // base name
                std::string ofbase;

                // Set base to opened file
                ofbase = ofn.lpstrFile;

                // Remove extension
                if (ofbase.find(".")!=std::string::npos)
                {
                    ofbase.erase(ofbase.find_last_of("."), std::string::npos);
                }

                // Declare filenames passing base
                std::string ofdozn(ofbase); // dozens
                std::string ofdozdbn(ofbase); // dozens debug
                std::string ofcoln(ofbase); // columns
                std::string ofcoldbn(ofbase); // columns debug

                // Append to dozens file
                ofdozn.append("-dozens.txt");

                // Append to dozens debug
                ofdozdbn.append("-dozens_debug.txt");

                // Append to columns file
                ofcoln.append("-columns.txt");

                // Append to columns debug
                ofcoldbn.append("-columns_debug.txt");

                // ofstream to files
                std::ofstream ofdoz(ofdozn.c_str());
                std::ofstream ofdozdb(ofdozdbn.c_str());
                std::ofstream ofcol(ofcoln.c_str());
                std::ofstream ofcoldb(ofcoldbn.c_str());

                // string for line
                std::string s;

                // Walk file
                while (std::getline(file, s))
                {
                    // Resize to two characters
                    s.resize(2);

                    // Halt if it isn't numeric
                    for (int i = 0; i < s.length(); ++i)
                    {
                        // Check
                        if (!isdigit(s[i]))
                        {
                            // skip iteration
                            continue;
                        }
                    }

                    // Set number
                    int number = atoi(s.c_str());

                    // Check it's 0-36 (roulette range)
                    if (number < 0 || number > 36)
                    {
                        // skip iteration
                        continue;
                    }

                    // Get current dozen
                    int dozen = GetDozen(number);

                    // Check if empty
                    if (dozens.size() == 0)
                    {
                        // Add element to deque's front
                        dozens.push_front(dozen);

                        // Skip iteration
                        continue;
                    }

                    // Look for an instance in deque
                    if (std::find(dozens.begin(), dozens.end(), dozen) != dozens.end())
                    {
                        // win to regular file
                        ofdoz << "W" << std::endl;

                        // win to debug file
                        ofdozdb << number << " " << dozen << " " << "W" << std::endl;
                    }
                    else
                    {
                        // lose
                        ofdoz << "L" << std::endl;

                        // lose to debug file
                        ofdozdb << number << " " << dozen << " " << "L" << std::endl;
                    }

                    // Handle one element
                    if (dozens.size() == 1 )
                    {
                        // Check for the same
                        if (dozen != dozens[0])
                        {
                            // Add second element to deque's front
                            dozens.push_front(dozen);
                        }

                        // Skip iteration
                        continue;
                    }

                    // Handle two elements
                    if (dozen != dozens[1])
                    {
                        // Pop first one
                        dozens.pop_back();

                        // Add new element to deque's front
                        dozens.push_front(dozen);
                    }

                    /* Columns */

                    // Get current column
                    int column = GetColumn(number);

                    // Check if empty
                    if (columns.size() == 0)
                    {
                        // Add element to deque's front
                        columns.push_front(column);

                        // Skip iteration
                        continue;
                    }

                    // Look for an instance in deque
                    if (std::find(columns.begin(), columns.end(), column) != columns.end())
                    {
                        // win to regular file
                        ofcol << "W" << std::endl;

                        // win to debug file
                        ofcoldb << number << " " << column << " " << "W" << std::endl;
                    }
                    else
                    {
                        // lose
                        ofcol << "L" << " " << std::endl;

                        // lose to debug file
                        ofcoldb << number << " " << column << " " << "L" << std::endl;
                    }

                    // Handle one element
                    if (columns.size() == 1 )
                    {
                        // Check for the same
                        if (column != columns[0])
                        {
                            // Add second element to deque's front
                            columns.push_front(column);
                        }

                        // Skip iteration
                        continue;
                    }

                    // Handle two elements
                    if (column != columns[1])
                    {
                        // Pop first one
                        columns.pop_back();

                        // Add new element to deque's front
                        columns.push_front(column);
                    }

                   
                }
               
                // Close ofstreams
                ofdoz.close();
                ofdozdb.close();
                ofcol.close();
                ofcoldb.close();
               
                // Clear deques
                dozens.clear();
                columns.clear();

                // Inform user we have processed everything
                MessageBox ( NULL , "Finished!" , "File Name" , MB_OK);
            }
        }

        break;

        // Form close
    case WM_DESTROY:

        // Launch BetSelection.cc
        ShellExecute(NULL, "open", "http://betselection.cc", NULL, NULL, SW_SHOWNORMAL);

        // Good bye!
        PostQuitMessage (0);
        break;

        // Process other messages
    default:
        return DefWindowProc (hwnd, message, wParam, lParam);
    }
    return 0;
}

/* Roulette Functions */

// Determines the dozen that a number belongs to
// Returns 0, 1, 2, 3.
int GetDozen(int num)
{
    switch (num)
    {
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 11:
    case 12:
        // First dozen
        return 1;
    case 13:
    case 14:
    case 15:
    case 16:
    case 17:
    case 18:
    case 19:
    case 20:
    case 21:
    case 22:
    case 23:
    case 24:
        // Second dozen
        return 2;
    case 25:
    case 26:
    case 27:
    case 28:
    case 29:
    case 30:
    case 31:
    case 32:
    case 33:
    case 34:
    case 35:
    case 36:
        // Third dozen
        return 3;
    default:
        // No dozen
        return 0;
    }
}


// Determines the column that a number belongs to
// Returns 0, 1, 2, 3.
int GetColumn(int num)
{
    switch (num)
    {
    case 1:
    case 4:
    case 7:
    case 10:
    case 13:
    case 16:
    case 19:
    case 22:
    case 25:
    case 28:
    case 31:
    case 34:
        // First column
        return 1;
    case 2:
    case 5:
    case 8:
    case 11:
    case 14:
    case 17:
    case 20:
    case 23:
    case 26:
    case 29:
    case 32:
    case 35:
        // Second column
        return 2;
    case 3:
    case 6:
    case 9:
    case 12:
    case 15:
    case 18:
    case 21:
    case 24:
    case 27:
    case 30:
    case 33:
    case 36:
        // Third column
        return 3;
    default:
        // No column
        return 0;
    }
}
New site: https://onenumber.cc

Email: betselectiongmail.com
-- Victor

Offline VLS

  • OneNumber.cc
  • Hero Member
  • *****
  • Posts: 2968
  • Gender: Male
  • OneNumber.cc
    • View Profile
Re: [RELEASE] Last Dozen/Column generator v0.1
« Reply #1 on: December 10, 2012, 11:29:31 am »
You must feed the program a properly formatted file:

- One number per line.

- No blanks/white-spaces.
New site: https://onenumber.cc

Email: betselectiongmail.com
-- Victor

Offline KingsRoulette

  • Full Member
  • ***
  • Posts: 155
  • The king of the game!
    • View Profile
Re: [RELEASE] Last Dozen/Column generator v0.1
« Reply #2 on: December 11, 2012, 03:32:06 am »
Why does it generate 4 files, instead of two? one each for dozens and columns and one their debug?
It is very correct though. We need a last "X" numbers tracker with W/L in same manner.
Nothing can perfectly beat a random session but luck. If someone claims perfection in every session, he is either a fool himself or think all to be fools.

Offline VLS

  • OneNumber.cc
  • Hero Member
  • *****
  • Posts: 2968
  • Gender: Male
  • OneNumber.cc
    • View Profile
Re: [RELEASE] Last Dozen/Column generator v0.1
« Reply #3 on: December 13, 2012, 07:31:11 pm »
Hi matey, thanks for the feedback.

I can work a bit more on this prior to moving to LastXsplits.

Why does it generate 4 files, instead of two? one each for dozens and columns and one their debug?
OK next release with a "Debug" checkbox to skip the extra files.

It is very correct though.
i'm glad to hear that.

We need a last "X" numbers tracker with W/L in same manner.
You can sponsor it for the community:

http://betselection.cc/coding-marketplace/sponsor-a-community-software!

Maybe others interested can churn-in a little towards the charge. Knocking the door is not entering!

If you aren't in for this Christmas, then feel free to request it for when the framework is operative later down in 2013 or as a free release next year as well.

Cheers!
New site: https://onenumber.cc

Email: betselectiongmail.com
-- Victor