3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/scrambler/square1.rb', line 3
def scramble(length = 0)
scramble = []
up_layer = (0..7).map{|i| i%2 == 0 ? 30 : 60}
down_layer = [up_layer].flatten!
length = 0
begin
up_moves = possible_moves up_layer
down_moves = possible_moves down_layer
up_move = up_moves.sample
down_moves.delete 0 if up_move == 0
down_move = down_moves.sample
scramble << [humanize_sq_one_move(up_layer, up_move), humanize_sq_one_move(down_layer, down_move) * -1]
do_move up_layer, up_move
do_move down_layer, down_move
length += up_move == 0 ? 0 : 1
length += down_move == 0 ? 0 : 1
do_slice(up_layer, down_layer)
length += 1
end while length <= 40 + 1
scramble.map {|s| "(#{s.join(',')})"}.join(' ')
end
|