CyoobietheCuber
Regular
This will be a thread for coding snippets, projects, and other programming things around cubing. As far I know, there isn't a thread for this, at least recently.
So to start of, here is my little, simple scramble generator. This is not perfect though so help is welcome.
So to start of, here is my little, simple scramble generator. This is not perfect though so help is welcome.
Python:
"""This is a free snippet of code
Please use this code as you wish
as long as do do claim ownership of this
I do not know much about copyright so
if some does, I would appreciate if
you could help with this copyright
contributions are welcome
thanks
"""
# Import the random module
import random
# Make some lists
moves = ["R", "L", "F", "B", "U", "D"]
dir_ = [" ", "' ", "2 "]
# "dir_" stands for direction
# Set the number of moves in the scramble
scramble_moves = 18
# Set how many scrambles you want
freq = 3
# The current scramble we are on
scrambles_done = 1
# Set up the last move that was in the scramble
# There curently is none so we set it to None
last_move = None
# A while loop for printing each scramble
while scrambles_done <= freq:
# Add one to the scrambles that have been done
scrambles_done += 1
# The main loop for generating the scramble
for current_move in range(0, scramble_moves):
# Pick a random move from the list of moves
rand_move = random.choice(moves)
# Pick a random "end notation" symbol
rand_dir = random.choice(dir_)
# Make a loop to pick a new move until it does not
# match the last move in the scramble
while rand_move == last_move:
rand_move = random.choice(moves)
# Print the move with end notation
print(rand_move, end=rand_dir)
# Set the last move to the current one
last_move = rand_move
# Create a new line once a scramble is finished
print("\b")