Our members are dedicated to PASSION and PURPOSE without drama!

Random Unique Line Generator v0.1 (Numbers/Split/Streets/DS/Dozen-Column)

Started by VLS, October 21, 2012, 12:18:32 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

VLS

Here's a free release for all the community  :)

Random Unique Line Generator is an aid for those players who need to generate a text string with all locations in a non-repetitive fashion.

Perhaps to create unique "virtual wheels", to bet for or against those unique patterns or to use them as part of a bigger strategy.

Here it is. Enjoy!

Download:
[attachmini=1]




Assembly works on Windows:

[attachimg=2]

As well as Linux/Mac (Via MONO runtime):

[attachimg=3]




It was programmed in cross-platform C#, targeting .NET 2.0 for maximum compatibility.

Main form's source code:

Code (csharp) Select

// C-sharp
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;


/*
* Source code provided as a compliment. Use for your own learning.
* Feel free to submit your modifications for inclusion at: http://betselection.cc
* Do *not* publicly distribute modified versions (as to keep one (1) canonical version).
* Thanks for appreciating this program. Enjoy!
* Vic
*/


// Main program's namespace
namespace BetSelection_cc_Random_Unique_Line_Generator_v0_1
{
    // Program's form
    public partial class Form1 : Form
    {
        /// <summary>
        /// Constructor
        /// </summary>
        public Form1()
        {
            InitializeComponent();
        }


        /// <summary>
        /// Start-up routine
        /// </summary>
        private void Form1_Load(object sender, EventArgs e)
        {
            // Check numbers's radio
            rbN.Checked = true;


            // Set tooltips
            setTooltip(bFile, "Save to file", "Click to pick target file");
            setTooltip(bClipboard, "Copy to clipboard", "Copies generated lines to clipboard");
            setTooltip(tbSep, "Escape sequences:", "\\n = new line. \\t = tabulator.");
        }


        /// <summary>
        /// Handle generate button
        /// </summary>
        private void bGenerate_Click(object sender, EventArgs e)
        {
            // Declare a string array for lines
            string[] lines = new string[0];


            // Declare single string for all lines
            string all_lines = "";
           
            // Act on selected radio button
            switch(getCheckedRadioButton().Name)
            {
                // Numbers
                case "rbN":
                    // Set lines
                    lines = generateRandomLines(37);
                    break;


                // Splits
                case "rbS":
                    lines = generateRandomLines(18);
                    break;


                // Streets
                case "rbSt":
                    lines = generateRandomLines(12);
                    break;


                // Double-streets
                case "rbDS":
                    lines = generateRandomLines(6);
                    break;


                // Dozens/columns
                case "rbDC":
                    lines = generateRandomLines(3);
                    break;
            }


            // Set all_lines
            foreach(string line in lines)
            {
                // Append current line
                all_lines += line + Environment.NewLine;
            }


            /* Handle Clipboard or File*/


            // Message
            string msg = "";


            switch (((Button)sender).Name)
            {
                // Set lines into clipboard
                case "bClipboard":
                   
                    // Clear it
                    Clipboard.Clear();


                    // Set data to it
                    Clipboard.SetText(all_lines);


                    // Set message
                    msg = "Generated lines have been copied to clipboard.";
                   
                    break;


                // Write lines to file
                case "bFile":
                   
                    // Prepare save file dialog
                    sfdLines.Filter = "Text files|*.txt|All files|*.*";
                    sfdLines.Title = "Save generated lines to file";


                    // Show save file dialog
                    sfdLines.ShowDialog();


                    // Check if there's something
                    if (sfdLines.FileName != "")
                    {
                        // Insert lines into file
                        File.WriteAllText(sfdLines.FileName, all_lines);


                        // Set message
                        msg = "Saved all generated lines to:" + Environment.NewLine + sfdLines.FileName;
                    }
                    else
                    {
                        // Cut the flow
                        return;
                    }
                   
                    break;
            }


            // Show success message
            MessageBox.Show(msg, "Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }


        /// <summary>
        /// Ancillary function to assist in generation
        /// </summary>
        /// <param name="elements">Items to hold</param>
        /// <returns>String array with a random sequence of elements on each string</returns>
        string[] generateRandomLines(byte elements)
        {
            // String array to hold all lines
            string[] lines = new string[Convert.ToInt32(nudTimes.Value)];


            // Byte array to hold a generated line
            byte[] line = new byte[elements];


            // Set amount to add. 0 for singles and splits, 1 for the rest
            byte add = Convert.ToByte(elements == 37 || elements == 18 ? 0 : 1);


            // Set variable for splits translation
            string[] splits = new string[] {"1/4", "2/5", "3/6", "7/10", "8/11", "9/12", "13/16", "14/17", "15/18", "19/22", "20/23", "21/24", "25/28", "26/29", "27/30", "31/34", "32/35", "33/36"};


            // Populate with sequential values
            for (byte seq = 0; seq < line.Length; ++seq)
            {
                // Set current
                line[seq] = Convert.ToByte(seq + add);
            }


            // Generation loop
            for (int g = 0; g < Convert.ToInt32(nudTimes.Value); ++g)
            {
                // Declare separator
                string sep = tbSep.Text;


                // Check if separator must be set to newline or tab
                switch (tbSep.Text)
                {
                    // New line
                    case "\\n":
                        sep = Environment.NewLine;
                        break;


                    // Tab
                    case "\\t":
                        sep = "\t";
                        break;
                }


                // Prepare a "good-enough" seed
                int seed = Convert.ToInt32(Regex.Replace(Guid.NewGuid().ToString().ToLower(), "[a-z-]", "").Substring(0, 9));
               
                // Shuffle
                new Random(seed + g).Shuffle(line);


                // Declare variable for resulting line
                string r_line = "";


                // Loop through elements in order to build the line string
                for (byte l = 0; l < line.Length; ++l)
                {
                    // Add current, accounting for split, separator and excluding last instance of it
                    r_line += (elements == 18 ? splits[line[l]] : line[l].ToString()) + (l != line.Length - 1 ? sep : "");
                }


                // Add it
                lines[g] = r_line;
            }


            // Return result
            return lines;
        }


        /// <summary>
        /// Retrieve currently checked location
        /// </summary>
        /// <returns>The checked RadioButton</returns>
        private RadioButton getCheckedRadioButton()
        {
            // Iterate through form controls
            foreach (Control c in this.Controls)
            {
                // Check if it's a RadioButton
                if (c is RadioButton)
                {
                    // Cast
                    RadioButton r = c as RadioButton;
                   
                    // Test for check
                    if(r.Checked)
                    {
                        // It's checked, return it
                        return r;
                    }
                }
            }


            // Nothing
            return null;
        }


        /// <summary>
        /// Launches BetSelection site when program ends.
        /// </summary>
        private void Form1_FormClosing(Object sender, FormClosingEventArgs e)
        {
            // Launch BetSelection.cc in default browser
            System.Diagnostics.Process.Start("http://betselection.cc");
        }


        /// <summary>
        /// Creates and attaches a tooltip to control
        /// </summary>
        /// <param name="ctrl">Control to which the tooltip wil be attached to</param>
        /// <param name="title">Tooltip's title</param>
        /// <param name="text">Tooltip's text</param>
        private void setTooltip(Control ctrl, string title, string text)
        {
            ToolTip ttToolTip = new ToolTip();
            ttToolTip.ToolTipTitle = title;
            ttToolTip.UseFading = true;
            ttToolTip.UseAnimation = true;
            ttToolTip.ShowAlways = true;
            ttToolTip.AutoPopDelay = 5000;
           
            // Shorter initial delay for separator
            ttToolTip.InitialDelay = (ctrl.Name == "tbSep" ? 100 : 1000);
           
            ttToolTip.ReshowDelay = 500;
            ttToolTip.SetToolTip(ctrl, text);
        }


        /// <summary>
        /// Status label link
        /// </summary>
        private void tsslLink_Click(object sender, EventArgs e)
        {
            // Launch BetSelection.cc site
            System.Diagnostics.Process.Start("http://betselection.cc");
        }


        /// <summary>
        /// Handles MouseEnter event for RadioButtons
        /// </summary>
        private void rb_MouseEnter(object sender, EventArgs e)
        {
            // Change to red
            ((RadioButton)sender).ForeColor = Color.Red;
        }


        /// <summary>
        /// Handles MouseLeave event for RadioButtons
        /// </summary>
        private void rb_MouseLeave(object sender, EventArgs e)
        {
            // Change back to black
            ((RadioButton)sender).ForeColor = Color.Black;
        }
    }


    // Generics to enable Shuffle
    static class RandomExtensions
    {
        // Shuffle method
        public static void Shuffle<T>(this Random RNG, T[] array)
        {
            // Knuth-Fisher-Yates shuffling
            for (int i = array.Length - 1; i > 0; i--)
            {
                int n = RNG.Next(i + 1);
                Swap(ref array[i], ref array[n]);
            }
        }


        // Swap method
        static void Swap<T>(ref T lhs, ref T rhs)
        {
            T temp;
            temp = lhs;
            lhs = rhs;
            rhs = temp;
        }
    }
}


// Required for RandomExtensions
namespace System.Runtime.CompilerServices
{
    [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class
         | AttributeTargets.Method)]
    public sealed class ExtensionAttribute : Attribute { }
}


Full project sources:
[attachmini=4]
Email/Paypal: betselectiongmail.com
-- Victor

Albalaha

Wow Victor,
            It is so useful. It is like having an RNG of our own. Isn't it possible to export output in txt file as:
4
23
0
15
2
27
1
       ?


     With comma as seperator, the txt file is not usable for data analysis with different bots/trackers and even for excel export. Please let me know.
Email: earnsumit@gmail.com - Visit my blog: http://albalaha.lefora.com
Can mentor a real, regular and serious player

VLS

I'm glad you liked it dear Sumit. There is a way to make it output each number on its own line.

When hovering your mouse over the separator box, you can see the hint:

Quote\n = new line. \t = tabulator.

So you only need to replace the comma by \n for the program to insert each number in a new line.

Enjoy!   :thumbsup:
Email/Paypal: betselectiongmail.com
-- Victor

Albalaha

Indeed,
        I just generated 5000 straight-up numbers with the help of "\n" separator.
Email: earnsumit@gmail.com - Visit my blog: http://albalaha.lefora.com
Can mentor a real, regular and serious player

VLS

Hello dear friends, please remember this isn't a standard random number generator, but a random *UNIQUE LINE* generator.


This means there are no repeats in the sequence by design. Unlike regular random. This artificial arrangement is useful for the people who want to build these sort of sequences, but isn't suitable when regular random number generation is required.
Email/Paypal: betselectiongmail.com
-- Victor

Albalaha

Email: earnsumit@gmail.com - Visit my blog: http://albalaha.lefora.com
Can mentor a real, regular and serious player