I'm trying to make a cube scramble generator to make moves to scramble my Rubik's cube.
This is my code:
The scramble generator: -
import random
-
from switcher import *
-
-
-
class AlgGen3x:
-
def __init__(self, move_num, move_set):
-
self.move_num = move_num
-
self.moves = move_set
-
self.alg_generator()
-
-
# Generate a alg for scramble
-
def alg_generator(self):
-
pre_num = ''
-
for n in range(self.move_num):
-
print('Creating move ' + str(n))
-
ran_num = random.randint(1, 18)
-
if not ran_num == pre_num:
-
pre_num = ran_num
-
self.switch(ran_num, self.moves)
-
self.update()
-
-
# Switch for cube 3x
-
@staticmethod
-
def switch(tar_obj, tar_set):
-
global move
-
while Switcher(tar_obj):
-
if case(1, 7, 13):
-
move = 'U'
-
break
-
if case(2, 8, 14):
-
move = 'D'
-
break
-
if case(3, 9, 15):
-
move = 'R'
-
break
-
if case(4, 10, 16):
-
move = 'L'
-
break
-
if case(5, 11, 17):
-
move = 'F'
-
break
-
if case(6, 12, 18):
-
move = 'D'
-
break
-
-
for n in range(7, 13):
-
if tar_obj == n:
-
move += 'i'
-
-
for n in range(13, 19):
-
if tar_obj == n:
-
move += '2'
-
-
return tar_set.add(move)
-
-
def update(self):
-
return self.moves
-
switcher.py: -
class Switcher(object):
-
-
value = None
-
-
def __new__(class_, value):
-
class_.value = value
-
return True
-
-
-
def case(*args):
-
return any((arg == Switcher.value for arg in args))
-
However, when run the code with this: -
# moves = set()
-
-
AlgGen3x(25, moves)
-
for move in moves:
-
print(move)
-
It returns the moves as:
L
R
L2
Di
Fi
F
R2
Ui
D2
U
U2
Help me to change the code or tell me what is the problem
0 1158 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Creativy, writing and more |
last post by:
Hi all,
I'm hoping to find some additional help with a site I'm maintaining for
my landlord. I'm trying to grow a web hosting and web design business. I
was to have this site as a job that would...
|
by: Mekon |
last post by:
I have never written a line of script in my life but I need some help with
it now.
I have this auto generated code which I want to modify if possible
The script generates a strip of...
|
by: Duane Lambe |
last post by:
Hi folks - site's at http://www.datawire.net/files/intranet.html ;
works fine in IE, but open in Firebird/Moz/Opera, and you can see that
the word "Home" near the top doesn't move down to line up...
|
by: Michael |
last post by:
Hi All,
I have a general question. I'm in the process of designing a app that will
allow user to enter data for Medical forms and print the corresponding word
doc. I have about 100 forms I have to...
|
by: maks |
last post by:
Hi!
I need some help in modifying this prime number generator code. How do I modify this code so that it assigns prime numbers to an array and returns it?
I have tried to get it work but it...
|
by: SilencerXXX |
last post by:
Hello All...ok, so here is what I need to do, it's for a computer project I'm working on for school (the teacher said outside help is allowed). What I need to do is similar to a password cracker; I...
|
by: Blubaugh, David A. |
last post by:
To All,
Has anyone worked with the F2PY generator? This is something that is
supposedly built within numpy and scipy for the Python environment. I
was wondering if anyone has encountered any...
|
by: Blubaugh, David A. |
last post by:
Pauli,
Yes, I am utilizing the windows environment. I cannot install f2py.
I obtain the following error when I try to execute the setup.py file
within the f2py folder located within the...
|
by: HerpsForDerps |
last post by:
Hello everyone!
I am new to this forum and currently am enrolled in an intro to ECS class where we are working on python programming. This is our last assignment for python and I have been able...
|
by: MattBrady |
last post by:
Ok, so I just started learning python and I've made a simple random number generator already but now I want the user to define the range in which the number can be generated. This is what I have so...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |