• Welcome to the Speedsolving.com, home of the web's largest puzzle community!
    You are currently viewing our forum as a guest which gives you limited access to join discussions and access our other features.

    Registration is fast, simple and absolutely free so please, join our community of 40,000+ people from around the world today!

    If you are already a member, simply login to hide this message and begin participating in the community!

Ruby scambler

O

Owen

Guest
I just started ruby, so I made a scamble generator. It just comes up with random moves, so it's not very good (I got U U' U'). Made in 15 minutes.


20.times do

number = rand 9
if number == 1
puts "U"
elsif number == 2
puts "D"
elsif number == 3
puts "R"
elsif number == 4
puts "L"
elsif number == 5
puts "U'"
elsif number == 6
puts "R'"
elsif number == 7
puts "L'"
elsif number == 8
puts "B'"
end



end




Note: If you use the facepalm emoticon, on this thread, I will freak out.
 
Last edited by a moderator:

Lucas Garron

Administrator
Joined
Jul 6, 2007
Messages
3,718
Location
California
WCA
2006GARR01
YouTube
Visit Channel
Code:
StringJoin/@Tuples[{{"U", "R", "D", "L"}, {"", "'"}}[[Table[Random[Integer, {1, 8}], {20}]]] // StringJoin
Whee!

Edit: Except that your code is even WORSE than that. Do you even know how rand works in Ruby (or any other decent language)?
 
Last edited:

tim

Member
Joined
Nov 22, 2006
Messages
1,692
Location
Karlsruhe, Germany
WCA
2007HABE01
YouTube
Visit Channel
Code:
20.times do

 number = rand 9
  if number == 1
    puts "U"
  elsif number == 2
    puts "D"
  elsif number == 3
    puts "R"
  elsif number == 4
    puts "L"
  elsif number == 5
    puts "U'"
  elsif number == 6
    puts "R'"
  elsif number == 7
    puts "L'"
  elsif number == 8
    puts "B'"
  end
  
  
  
end

1.) What about the random newlines?
2.) Use arrays like so:
Code:
moves = %w(U D R L F B)
20.times do
  number = rand 6
  puts moves[number]
end

3.) Learn some Ruby by getting this to work:
Code:
moves = %w(U D R L F B)
20.times do
  puts moves.rand
end
 
O

Owen

Guest
Oh, don't complain about my Ruby knowlage. I didn't say it was good.


"I just started ruby, so I made a scamble generator. It just comes up with random moves, so it's not very good (I got U U' U'). Made in 15 minutes."



I also added F.


20.times do

number = rand 11
if number == 1
puts "U"
elsif number == 2
puts "D"
elsif number == 3
puts "R"
elsif number == 4
puts "L"
elsif number == 5
puts "U'"
elsif number == 6
puts "R'"
elsif number == 7
puts "L'"
elsif number == 8
puts "B'"
elsif number == 9
puts "F"
elsif number == 10
puts "F'"
end



end
 
Last edited by a moderator:

qqwref

Member
Joined
Dec 18, 2007
Messages
7,834
Location
a <script> tag near you
WCA
2006GOTT01
YouTube
Visit Channel
Saying "it's not very good" is an incredible understatement. This is seriously the worst attempt at a scrambler I've ever seen. I'm sure you're a beginning programmer, but you should at least put some more work into something before posting it on a forum - test it out, play with it a bit, fix all the really obvious errors (like having no F moves, or D', or B, or double turns...). Your scrambler doesn't even *work* - it doesn't turn all faces, it doesn't do the right number of moves (for random turns you should do 25, not 20), and it doesn't have even the most rudimentary move canceling.
 

keemy

Member
Joined
Dec 29, 2007
Messages
151
WCA
2006CORR01
hey so after seeing this i decided to make a scrambler for the lols it probably took a little more than 15 mins though (because was typed on a calculator darn and i had to learn 1 thing) but yeah it doesn't do F moves either so it must be good right.

less Fs in the scramble less possible to get F perm amirite?
 

Lucas Garron

Administrator
Joined
Jul 6, 2007
Messages
3,718
Location
California
WCA
2006GARR01
YouTube
Visit Channel
How does this deserve to be in "Speedcubing Discussion"?

Your right! This is not a disscusion, but a bunch of people insulting my scrambler! (I acually put this in "Puzzle theory", but I guess it got moved).
It really didn't belong in Puzzle Theory.

I put it there because thats were all the other scramblers were.
False. Second results if you searcher for "Scrambler" in the big Google field at the top. And the first result contains legitimate theory.

EDIT: Actually, NONE of the other results on the first search results page are in puzzle theory. If you're going to post any more in this thread, could you please check your facts? It's embarrassing.
 
Top