Click here to Skip to main content
13,453,569 members (45,993 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


21 bookmarked
Posted 15 Feb 2008

Stopwatch and Rubik's Cube Shuffle Algorithm Generator

, 15 Feb 2008
Rate this:
Please Sign up or sign in to vote.
A simple program that features a straight forward stopwatch, history and a Rubik's Cube Shuffle Algorithm Generator

Cube AlgGen-Timer (approx 900kb) by pHysiX


This is my first post @ CP and I hope many people will find this useful.


I enjoy speedcubing and have repeatedly looked for a straight-forward stopwatch to no avail. Now, I hope to solve that problem with my own app.

Using the code

There are two main codes in this program; stopwatch and algorithm generator.

Below are the major bits of code:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Diagnostics;
using System.Drawing.Drawing2D;
using System.Security.Cryptography;
using System.IO; 
//Declare these things
private AlgGenerator cgenAlg;
private Stopwatch stopWatch;
private Boolean captureLap;
//These are functions for when you form is called
        public MainFrm()
            stopWatch = new Stopwatch();
            captureLap = false;


private void timerMain_Tick(System.Object sender, System.EventArgs e)
            // When the timer is running, update the displayed timer 
            // value for each tick event.

            if (stopWatch.IsRunning)
                // Get the elapsed time as a TimeSpan value.
                TimeSpan ts = stopWatch.Elapsed;

                // Format and display the TimeSpan value.
                labelTime.Text = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                    ts.Hours, ts.Minutes, ts.Seconds,
                    ts.Milliseconds / 10);

                // If the user has just clicked the "Lap" button,
                // then capture the current time for the lap time.

                if (captureLap)
                    labelLap.Text = labelTime.Text;
                    captureLap = false;

        private void btnGenerate_Click(object sender, System.EventArgs e)
            if (null != cgenAlg)
                if ((null != this.exclude.Text) || (String.Empty != this.exclude.Text))
                    cgenAlg.Exclusions = this.exclude.Text;
                cgenAlg.Maximum = this.maxSize.Value;
                cgenAlg.ConsecutiveCharacters = this.consecutive.Checked;
                cgenAlg.RepeatCharacters = this.repeating.Checked;
                cgenAlg.ExcludeSymbols = this.excludeSymbols.Checked;
                genAlg.Text = cgenAlg.Generate();
//The history function can read the stopwatch time and record it to a text file
private void buttonStartStop_Click(System.Object sender, System.EventArgs e)
            if (stopWatch.IsRunning)
                using (StreamWriter sw = new StreamWriter("Cube History.txt", true))
                    buttonStartStop.Text = "Start";
                    buttonLapReset.Text = "Reset";
                    buttonLapReset.Visible = true;
                    buttonStartStop.Enabled = false;
                    sw.WriteLine("PHYSIX Alg-Gen Cube Timer");
                    sw.WriteLine("Cubing Session:");
                    sw.WriteLine("Your recorded time:");
                    sw.WriteLine("Your shuffle algorithm:");
                buttonStartStop.Text = "Stop";
                buttonLapReset.Visible = false;
                button1.Enabled = false;
                button2.Enabled = false;
                button4.Enabled = false;
                labelLap.Visible = false;
                labelLapPrompt.Visible = false;
                groupBox1.Enabled = false;

Those are just some things that I believe that can help you with using file I/O, a stopwatch and random strings/character generation.

To do

I was more a HTML developer so my C/C# skills will be no where near the skill of those on CP. What I hope to do is add some better aesthetics and make a less buggy algorithm generator (people that understand the names of the Rubik's Cube faces will understand the bug). Feel free to post any suggestions and if you are interested, simply request the SRC code below and I will upload as soon as I am free.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

PHYSIX Coding Corp
Australia Australia
No Biography provided

You may also be interested in...

Comments and Discussions

Questionplease source code Pin
hyderalima28-Oct-11 20:01
memberhyderalima28-Oct-11 20:01 
Generalcode Pin
jskapur30-May-09 6:57
memberjskapur30-May-09 6:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02-2016 | 2.8.180318.3 | Last Updated 15 Feb 2008
Article Copyright 2008 by pHysiX
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid