cube.sed

qwr

Legend
Joined
Jul 24, 2019
Messages
4,350
YouTube
Visit Channel

cube3d.gif


if you don't know what sed is, it's basically a string search-and-replace tool. So basically the cube is represented internally as

Code:
# internal representation (largely speffz + weird extra characters):
#     AaB
#     d!b
#     DcC
# EeF IiJ MmN QqR
# h@f l#j p$n t%r
# HgG LkK PoO TsS
#     UuV
#     x^v
#     XwW


# initial cube state
1 {
x
s/$/AaBd!bDcCEeFIiJMmNQqRh@fl#jp$nt%rHgGLkKPoOTsSUuVx^vXwW/
x
}

then moves are represented as string operations like

Code:
/^U/ {
x
#   A         B           D         C    D   A   C   B
s/\(.\)\(.\)\(.\)\(...\)\(.\)\(.\)\(.\)/\5\2\1\4\7\6\3/
#        a         d         b         c      d   c   a   b
s/\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\1\4\3\8\5\2\7\6/
#             E          I          M          Q      I   M   Q   E
s/\(.\{9\}\)\(.\)\(..\)\(.\)\(..\)\(.\)\(..\)\(.\)/\1\4\3\6\5\8\7\2/
#              e          i          m          q      i   m   q   e
s/\(.\{10\}\)\(.\)\(..\)\(.\)\(..\)\(.\)\(..\)\(.\)/\1\4\3\6\5\8\7\2/
#              F          J          N          R      J   N   R   F
s/\(.\{11\}\)\(.\)\(..\)\(.\)\(..\)\(.\)\(..\)\(.\)/\1\4\3\6\5\8\7\2/
b next
}

This is actually not too far off from how a normal cube sim would represent internal state (with some optimizations)
 
Back
Top