BetSelection.cc

Please login or register.

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

0 Members and 1 Guest are viewing this topic.

Offline VLS

  • On the main seat
  • Administrator
  • *****
  • Posts: 2941
  • Gender: Male
  • Software Architech
    • View Profile
[RELEASE] Last Dozen/Column generator v0.1
« on: December 10, 2012, 02:15:31 am »
  • ReplyReply
  • 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: C++
    1. #include <windows.h>
    2. #include <fstream>
    3. #include <deque>
    4. #include <string>
    5.  
    6. // Identifiers.
    7. #define IDC_BUTTON 2000
    8.  
    9. // Globals
    10. HINSTANCE instance;
    11. HWND hwnd;
    12. HFONT h_font;
    13. std::deque<int> dozens; // Deque as LIFO queue for dozens
    14. std::deque<int> columns; // Deque as LIFO queue for columns
    15.  
    16. // Prototypes
    17. int GetDozen(int num);
    18. int GetColumn(int num);
    19.  
    20. // Declare window procedure
    21. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
    22.  
    23. // Class name as global
    24. char szClassName[ ] = "LastDCGen";
    25.  
    26. // Program's entrypoint
    27. int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
    28. {
    29.     instance = hThisInstance;
    30.     MSG messages;
    31.     WNDCLASSEX wincl;
    32.  
    33.     /* The Window structure */
    34.     wincl.hInstance = hThisInstance;
    35.     wincl.lpszClassName = szClassName;
    36.     wincl.lpfnWndProc = WindowProcedure;
    37.     wincl.style = CS_DBLCLKS;
    38.     wincl.cbSize = sizeof (WNDCLASSEX);
    39.     /* Use default icon and mouse-pointer */
    40.     wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    41.     wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    42.     wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    43.     wincl.lpszMenuName = NULL;
    44.     wincl.cbClsExtra = 0;
    45.     wincl.cbWndExtra = 0;
    46.     /* Use Windows's default color as the background of the window */
    47.     wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
    48.  
    49.     /* Register the window class, and if it fails quit the program */
    50.     if (!RegisterClassEx (&wincl))
    51.         return 0;
    52.  
    53.     /* The class is registered, let's create the program*/
    54.     hwnd = CreateWindowEx (
    55.                0,
    56.                szClassName, /* Classname */
    57.                "LastDC Lw Generator",  /* Title Text */
    58.                WS_OVERLAPPEDWINDOW &~ WS_MAXIMIZEBOX &~ WS_MINIMIZEBOX, /* no min/max button */
    59.                CW_USEDEFAULT,
    60.                CW_USEDEFAULT,
    61.                190, /* Width */
    62.                100, /* Height */
    63.                HWND_DESKTOP, /* The window is a child-window to desktop */
    64.                NULL, /* No menu */
    65.                hThisInstance,  /* Program Instance handler */
    66.                NULL
    67.            );
    68.  
    69.     // Center it
    70.     RECT rc;
    71.     int screenWidth = GetSystemMetrics(SM_CXSCREEN);
    72.     int screenHeight = GetSystemMetrics(SM_CYSCREEN);
    73.     GetWindowRect(hwnd, &rc);
    74.     SetWindowPos(hwnd, 0, (screenWidth - rc.right)/2, (screenHeight - rc.bottom)/2, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
    75.  
    76.     // Set Font
    77.     h_font = CreateFont(-13, 0, 0, 0, FW_NORMAL, 0,
    78.                         0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
    79.                         DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Times New Roman");
    80.  
    81.     /* Make the window visible on the screen */
    82.     ShowWindow (hwnd, nFunsterStil);
    83.  
    84.     /* Run the message loop. */
    85.     while (GetMessage (&messages, NULL, 0, 0))
    86.     {
    87.         /* Translate virtual-key messages into character messages */
    88.         TranslateMessage(&messages);
    89.  
    90.         /* Send message to WindowProcedure */
    91.         DispatchMessage(&messages);
    92.     }
    93.  
    94.     /* The program return-value is 0 - The value that PostQuitMessage() gave */
    95.     return messages.wParam;
    96. }
    97.  
    98. // Window Procedure
    99. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    100. {
    101.     // Handle messages
    102.     switch (message)
    103.     {
    104.  
    105.         // Form creation
    106.     case WM_CREATE:
    107.  
    108.         // Create button
    109.         HWND wnd;
    110.         wnd = CreateWindowEx(0x00000000, "Button", "Select file", 0x50010001, 8, 16, 96, 32, hwnd, (HMENU) IDC_BUTTON, instance, NULL);
    111.         SendMessage(wnd, WM_SETFONT, (WPARAM) h_font, TRUE);
    112.  
    113.         // Emulate button press
    114.         break;
    115.  
    116.         // Handle user command
    117.     case WM_COMMAND:
    118.         switch (wParam)
    119.         {
    120.         case IDC_BUTTON:
    121.             // Open file name
    122.             OPENFILENAME ofn;
    123.  
    124.             // Memory buffer to contain file name
    125.             char szFile[MAX_PATH+1];
    126.  
    127.             // Open file dialog
    128.             ZeroMemory( &ofn , sizeof( ofn));
    129.             ofn.lStructSize = sizeof ( ofn );
    130.             ofn.hwndOwner = NULL ;
    131.             ofn.lpstrFile = szFile ;
    132.             ofn.lpstrFile[0] = '\0';
    133.             ofn.nMaxFile = sizeof( szFile );
    134.             ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
    135.             ofn.nFilterIndex =1;
    136.             ofn.lpstrFileTitle = NULL ;
    137.             ofn.nMaxFileTitle = 0 ;
    138.             ofn.lpstrInitialDir=NULL ;
    139.             ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ;
    140.  
    141.             // Invoke file dialog
    142.             if (GetOpenFileName( &ofn ))
    143.             {
    144.                 // ifstream from file
    145.                 std::ifstream file(ofn.lpstrFile);
    146.  
    147.                 // base name
    148.                 std::string ofbase;
    149.  
    150.                 // Set base to opened file
    151.                 ofbase = ofn.lpstrFile;
    152.  
    153.                 // Remove extension
    154.                 if (ofbase.find(".")!=std::string::npos)
    155.                 {
    156.                     ofbase.erase(ofbase.find_last_of("."), std::string::npos);
    157.                 }
    158.  
    159.                 // Declare filenames passing base
    160.                 std::string ofdozn(ofbase); // dozens
    161.                 std::string ofdozdbn(ofbase); // dozens debug
    162.                 std::string ofcoln(ofbase); // columns
    163.                 std::string ofcoldbn(ofbase); // columns debug
    164.  
    165.                 // Append to dozens file
    166.                 ofdozn.append("-dozens.txt");
    167.  
    168.                 // Append to dozens debug
    169.                 ofdozdbn.append("-dozens_debug.txt");
    170.  
    171.                 // Append to columns file
    172.                 ofcoln.append("-columns.txt");
    173.  
    174.                 // Append to columns debug
    175.                 ofcoldbn.append("-columns_debug.txt");
    176.  
    177.                 // ofstream to files
    178.                 std::ofstream ofdoz(ofdozn.c_str());
    179.                 std::ofstream ofdozdb(ofdozdbn.c_str());
    180.                 std::ofstream ofcol(ofcoln.c_str());
    181.                 std::ofstream ofcoldb(ofcoldbn.c_str());
    182.  
    183.                 // string for line
    184.                 std::string s;
    185.  
    186.                 // Walk file
    187.                 while (std::getline(file, s))
    188.                 {
    189.                     // Resize to two characters
    190.                     s.resize(2);
    191.  
    192.                     // Halt if it isn't numeric
    193.                     for (int i = 0; i < s.length(); ++i)
    194.                     {
    195.                         // Check
    196.                         if (!isdigit(s[i]))
    197.                         {
    198.                             // skip iteration
    199.                             continue;
    200.                         }
    201.                     }
    202.  
    203.                     // Set number
    204.                     int number = atoi(s.c_str());
    205.  
    206.                     // Check it's 0-36 (roulette range)
    207.                     if (number < 0 || number > 36)
    208.                     {
    209.                         // skip iteration
    210.                         continue;
    211.                     }
    212.  
    213.                     // Get current dozen
    214.                     int dozen = GetDozen(number);
    215.  
    216.                     // Check if empty
    217.                     if (dozens.size() == 0)
    218.                     {
    219.                         // Add element to deque's front
    220.                         dozens.push_front(dozen);
    221.  
    222.                         // Skip iteration
    223.                         continue;
    224.                     }
    225.  
    226.                     // Look for an instance in deque
    227.                     if (std::find(dozens.begin(), dozens.end(), dozen) != dozens.end())
    228.                     {
    229.                         // win to regular file
    230.                         ofdoz << "W" << std::endl;
    231.  
    232.                         // win to debug file
    233.                         ofdozdb << number << " " << dozen << " " << "W" << std::endl;
    234.                     }
    235.                     else
    236.                     {
    237.                         // lose
    238.                         ofdoz << "L" << std::endl;
    239.  
    240.                         // lose to debug file
    241.                         ofdozdb << number << " " << dozen << " " << "L" << std::endl;
    242.                     }
    243.  
    244.                     // Handle one element
    245.                     if (dozens.size() == 1 )
    246.                     {
    247.                         // Check for the same
    248.                         if (dozen != dozens[0])
    249.                         {
    250.                             // Add second element to deque's front
    251.                             dozens.push_front(dozen);
    252.                         }
    253.  
    254.                         // Skip iteration
    255.                         continue;
    256.                     }
    257.  
    258.                     // Handle two elements
    259.                     if (dozen != dozens[1])
    260.                     {
    261.                         // Pop first one
    262.                         dozens.pop_back();
    263.  
    264.                         // Add new element to deque's front
    265.                         dozens.push_front(dozen);
    266.                     }
    267.  
    268.                     /* Columns */
    269.  
    270.                     // Get current column
    271.                     int column = GetColumn(number);
    272.  
    273.                     // Check if empty
    274.                     if (columns.size() == 0)
    275.                     {
    276.                         // Add element to deque's front
    277.                         columns.push_front(column);
    278.  
    279.                         // Skip iteration
    280.                         continue;
    281.                     }
    282.  
    283.                     // Look for an instance in deque
    284.                     if (std::find(columns.begin(), columns.end(), column) != columns.end())
    285.                     {
    286.                         // win to regular file
    287.                         ofcol << "W" << std::endl;
    288.  
    289.                         // win to debug file
    290.                         ofcoldb << number << " " << column << " " << "W" << std::endl;
    291.                     }
    292.                     else
    293.                     {
    294.                         // lose
    295.                         ofcol << "L" << " " << std::endl;
    296.  
    297.                         // lose to debug file
    298.                         ofcoldb << number << " " << column << " " << "L" << std::endl;
    299.                     }
    300.  
    301.                     // Handle one element
    302.                     if (columns.size() == 1 )
    303.                     {
    304.                         // Check for the same
    305.                         if (column != columns[0])
    306.                         {
    307.                             // Add second element to deque's front
    308.                             columns.push_front(column);
    309.                         }
    310.  
    311.                         // Skip iteration
    312.                         continue;
    313.                     }
    314.  
    315.                     // Handle two elements
    316.                     if (column != columns[1])
    317.                     {
    318.                         // Pop first one
    319.                         columns.pop_back();
    320.  
    321.                         // Add new element to deque's front
    322.                         columns.push_front(column);
    323.                     }
    324.  
    325.                    
    326.                 }
    327.                
    328.                 // Close ofstreams
    329.                 ofdoz.close();
    330.                 ofdozdb.close();
    331.                 ofcol.close();
    332.                 ofcoldb.close();
    333.                
    334.                 // Clear deques
    335.                 dozens.clear();
    336.                 columns.clear();
    337.  
    338.                 // Inform user we have processed everything
    339.                 MessageBox ( NULL , "Finished!" , "File Name" , MB_OK);
    340.             }
    341.         }
    342.  
    343.         break;
    344.  
    345.         // Form close
    346.     case WM_DESTROY:
    347.  
    348.         // Launch BetSelection.cc
    349.         ShellExecute(NULL, "open", "https://betselection.cc", NULL, NULL, SW_SHOWNORMAL);
    350.  
    351.         // Good bye!
    352.         PostQuitMessage (0);
    353.         break;
    354.  
    355.         // Process other messages
    356.     default:
    357.         return DefWindowProc (hwnd, message, wParam, lParam);
    358.     }
    359.     return 0;
    360. }
    361.  
    362. /* Roulette Functions */
    363.  
    364. // Determines the dozen that a number belongs to
    365. // Returns 0, 1, 2, 3.
    366. int GetDozen(int num)
    367. {
    368.     switch (num)
    369.     {
    370.     case 1:
    371.     case 2:
    372.     case 3:
    373.     case 4:
    374.     case 5:
    375.     case 6:
    376.     case 7:
    377.     case 8:
    378.     case 9:
    379.     case 10:
    380.     case 11:
    381.     case 12:
    382.         // First dozen
    383.         return 1;
    384.     case 13:
    385.     case 14:
    386.     case 15:
    387.     case 16:
    388.     case 17:
    389.     case 18:
    390.     case 19:
    391.     case 20:
    392.     case 21:
    393.     case 22:
    394.     case 23:
    395.     case 24:
    396.         // Second dozen
    397.         return 2;
    398.     case 25:
    399.     case 26:
    400.     case 27:
    401.     case 28:
    402.     case 29:
    403.     case 30:
    404.     case 31:
    405.     case 32:
    406.     case 33:
    407.     case 34:
    408.     case 35:
    409.     case 36:
    410.         // Third dozen
    411.         return 3;
    412.     default:
    413.         // No dozen
    414.         return 0;
    415.     }
    416. }
    417.  
    418.  
    419. // Determines the column that a number belongs to
    420. // Returns 0, 1, 2, 3.
    421. int GetColumn(int num)
    422. {
    423.     switch (num)
    424.     {
    425.     case 1:
    426.     case 4:
    427.     case 7:
    428.     case 10:
    429.     case 13:
    430.     case 16:
    431.     case 19:
    432.     case 22:
    433.     case 25:
    434.     case 28:
    435.     case 31:
    436.     case 34:
    437.         // First column
    438.         return 1;
    439.     case 2:
    440.     case 5:
    441.     case 8:
    442.     case 11:
    443.     case 14:
    444.     case 17:
    445.     case 20:
    446.     case 23:
    447.     case 26:
    448.     case 29:
    449.     case 32:
    450.     case 35:
    451.         // Second column
    452.         return 2;
    453.     case 3:
    454.     case 6:
    455.     case 9:
    456.     case 12:
    457.     case 15:
    458.     case 18:
    459.     case 21:
    460.     case 24:
    461.     case 27:
    462.     case 30:
    463.     case 33:
    464.     case 36:
    465.         // Third column
    466.         return 3;
    467.     default:
    468.         // No column
    469.         return 0;
    470.     }
    471. }
    :thumbsup: Your support in appreciation needed:

    https://www.paypal.me/victorvls


    (You can set the amount manually)

    Email: betselectiongmail.com
    -- Victor


    Offline VLS

    • On the main seat
    • Administrator
    • *****
    • Posts: 2941
    • Gender: Male
    • Software Architech
      • View Profile
    Re: [RELEASE] Last Dozen/Column generator v0.1
    « Reply #1 on: December 10, 2012, 11:29:31 am »
  • ReplyReply
  • You must feed the program a properly formatted file:

    - One number per line.

    - No blanks/white-spaces.
    :thumbsup: Your support in appreciation needed:

    https://www.paypal.me/victorvls


    (You can set the amount manually)

    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 »
  • ReplyReply
  • 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

    • On the main seat
    • Administrator
    • *****
    • Posts: 2941
    • Gender: Male
    • Software Architech
      • View Profile
    Re: [RELEASE] Last Dozen/Column generator v0.1
    « Reply #3 on: December 13, 2012, 07:31:11 pm »
  • ReplyReply
  • 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:

    https://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!
    :thumbsup: Your support in appreciation needed:

    https://www.paypal.me/victorvls


    (You can set the amount manually)

    Email: betselectiongmail.com
    -- Victor