Latest version to have a play with,now 'j' jumbles up the cube and 's' starts to solve it,only does 2 of the rows for now,it did more but an editor that i wont name until i can duplicate the fault,ate about 500 lines of the scripted rules it uses to solve the remainder and left me with a blank dba file instead!
`%DARK CUBE EZRotate + Sparkys Collision Example%
`======================
`©P.Parkinson
`======================
`Main Source File
sync on
sync rate 60
autocam off
color backdrop 0,rgb(125,125,255)
set text font "Arial"
set text size 12
set text transparent
position camera 50,50,-50
point camera 0,0,0
set spot light 0,1,5.5
position light 0,400,400,-400
point light 0,0,0,0
set light range 0,5000
set ambient light 20
`declarations and setup starts here
dim puzzle(3,3,3)
dim temp_puzzle(3,3,3)
global piece_size as float:piece_size=13.0
dim faces(27,6)
dim temp_faces(27,6)
dim overlay(9,12)
global flashing as integer=0
global solving as integer=0
global jumbling as integer=0
`globals used for color textures
global red as integer=1
global blue as integer=2
global yellow as integer=3
global green as integer=4
global white as integer=5
global orange as integer=6
global black as integer=7
global gui as integer=15
`globals used for faces
global top as integer=1
global bottom as integer=2
global left as integer=3
global right as integer=4
global back as integer=5
global front as integer=6
make_textures()`makes all the textures
make_cube()`makes the completed cube
jumble_cube(0)`jumbles up the cube x number of times
`objects and globals used for collision check and gui
global target as integer=100
make object cube target,5
hide object target
global decal as integer=101
make object box decal,piece_size,piece_size,0.1
texture object decal,gui
set object transparency decal,2
hide object decal
global cx as float
global cy as float
global cz as float
global nx as float
global ny as float
global nz as float
global hit as integer
`global fix_cube as integer
`main loop starts here
sync
do
if leftkey() then rotate_cube_y(-1)
if rightkey() then rotate_cube_y(1)
if upkey() then rotate_cube_x(-1)
if downkey() then rotate_cube_x(1)
if inkey$()="-" then rotate_cube_z(-1)
if inkey$()="+" then rotate_cube_z(1)
if inkey$()="s" then solver()
if inkey$()="j" then jumble_cube(20)
px=mousex():py=mousey():pz=10000
pick screen px,py,pz
px=get pick vector x():py=get pick vector y():pz=get pick vector z()
position object target,px,py,pz
hit=0
hit=sc_raycast(0,camera position x(),camera position y(),camera position z(),object position x(target),object position y(target),object position z(target),decal)
if hit>0
cx=sc_getstaticcollisionx()
cy=sc_getstaticcollisiony()
cz=sc_getstaticcollisionz()
nx=sc_getcollisionnormalx()*10
ny=sc_getcollisionnormaly()*10
nz=sc_getcollisionnormalz()*10
nx=int(nx):ny=int(ny):nz=int(nz)
add_gui_decal()
else
hide object decal
endif
text 0,0," Arrow Keys and +/- To Rotate Cube"
text 0,15," Click On Edge Piece To Rotate In Direction Shown"
text 0,30," 'j' to jumble up the cube 's' to start solving it"
show_overlay()
sync
` inc fix_cube
` if fix_cube>120
` fix_cube_angles()
` fix_cube=0
` endif
loop
`functions start here
function make_textures()
make_texture(red,255,0,0)
make_texture(blue,50,50,255)
make_texture(yellow,255,255,0)
make_texture(green,0,255,0)
make_texture(white,255,255,255)
make_texture(orange,255,125,0)
make_texture(black,0,0,0)
create_gui_decal()
endfunction
function make_cube()
restore cube_data
x=1:y=1:z=1
for l=1 to 27
read col1$,col2$,col3$,col4$,col5$,col6$,posx,posy,posz
col1=convert_color_string(col1$)
col2=convert_color_string(col2$)
col3=convert_color_string(col3$)
col4=convert_color_string(col4$)
col5=convert_color_string(col5$)
col6=convert_color_string(col6$)
make_piece(col1,col2,col3,col4,col5,col6,posx,posy,posz,l)
puzzle(x,y,z)=l
faces(l,top)=col1
faces(l,bottom)=col2
faces(l,left)=col3
faces(l,right)=col4
faces(l,back)=col5
faces(l,front)=col6
inc x
if x>3 then inc z:x=1
if z>3 then inc y:z=1
next l
endfunction
function convert_color_string(col$)
if col$="red" then col=red
if col$="blue" then col=blue
if col$="yellow" then col=yellow
if col$="green" then col=green
if col$="white" then col=white
if col$="orange" then col=orange
if col$="black" then col=black
endfunction col
function convert_face_string(face$)
if face$="top" then face=top
if face$="bottom" then face=bottom
if face$="back" then face=back
if face$="front" then face=front
if face$="left" then face=left
if face$="right" then face=right
endfunction face
function create_memblockobject(memnum,v)
make memblock memnum,12+(36*v)
write memblock dword memnum,0,274
write memblock dword memnum,4,32
write memblock dword memnum,8,v
endfunction
function create_vertex(memnum,v,vposx#,vposy#,vposz#,color as dword,u#,v#)
write memblock float memnum,v*32+12,vposx#
write memblock float memnum,v*32+16,vposy#
write memblock float memnum,v*32+20,vposz#
write memblock float memnum,v*32+36,u#
write memblock float memnum,v*32+40,v#
endfunction
function make_piece(col1,col2,col3,col4,col5,col6,posx,posy,posz,obj_num)
make object cube obj_num,piece_size/2.0
`size of each square
grid_size#=piece_size/16.0
offset#=piece_size/2.0
`step for the uv co ordinates
global ustep as double float
global vstep as double float
ustep=1.0/16.0
vstep=1.0/16.0
`make a memblock big enough to hold the data
memblock_size=16*16*6
if memblock exist(1) then delete memblock 1
create_memblockobject(1,memblock_size)
`make a mesh and use it to build the 6 sides of the cube
v_num=0
for lz=0 to 15
for lx=0 to 15
create_vertex(1,v_num,lx*grid_size#-offset#,0,lz*grid_size#-offset#,rgb(255,255,255),ustep*lx,vstep*lz)
inc v_num
create_vertex(1,v_num,lx*grid_size#-offset#,0,(lz+1)*grid_size#-offset#,rgb(255,255,255),ustep*lx,vstep*(lz+1))
inc v_num
create_vertex(1,v_num,(lx+1)*grid_size#-offset#,0,lz*grid_size#-offset#,rgb(255,255,255),ustep*(lx+1),vstep*lz)
inc v_num
create_vertex(1,v_num,(lx+1)*grid_size#-offset#,0,lz*grid_size#-offset#,rgb(255,255,255),ustep*(lx+1),vstep*lz)
inc v_num
create_vertex(1,v_num,lx*grid_size#-offset#,0,(lz+1)*grid_size#-offset#,rgb(255,255,255),ustep*lx,vstep*(lz+1))
inc v_num
create_vertex(1,v_num,(lx+1)*grid_size#-offset#,0,(lz+1)*grid_size#-offset#,rgb(255,255,255),ustep*(lx+1),vstep*(lz+1))
inc v_num
next lx
next lz
make mesh from memblock 1,1
`top
add limb obj_num,1,1
offset limb obj_num,1,0,offset#,0
if obj_num=5
texture limb obj_num,1,0,col1+7
else
texture limb obj_num,1,0,col1
endif
`bottom
add limb obj_num,2,1
rotate limb obj_num,2,180,0,0
offset limb obj_num,2,0,0-offset#,0
if obj_num=23
texture limb obj_num,2,0,col2+7
else
texture limb obj_num,2,0,col2
endif
`left
add limb obj_num,3,1
rotate limb obj_num,3,0,0,90
offset limb obj_num,3,0-offset#,0,0
if obj_num=13
texture limb obj_num,3,0,col3+7
else
texture limb obj_num,3,0,col3
endif
`right
add limb obj_num,4,1
rotate limb obj_num,4,0,0,270
offset limb obj_num,4,offset#,0,0
if obj_num=15
texture limb obj_num,4,0,col4+7
else
texture limb obj_num,4,0,col4
endif
`back
add limb obj_num,5,1
rotate limb obj_num,5,90,0,0
offset limb obj_num,5,0,0,offset#
if obj_num=17
texture limb obj_num,5,0,col5+7
else
texture limb obj_num,5,0,col5
endif
`front
add limb obj_num,6,1
rotate limb obj_num,6,270,0,0
offset limb obj_num,6,0,0,0-offset#
if obj_num=11
texture limb obj_num,6,0,col6+7
else
texture limb obj_num,6,0,col6
endif
set object normals obj_num
position object obj_num,posx*piece_size,posy*piece_size,posz*piece_size
sc_setupobject obj_num,0,0
endfunction
function rotate_y(direction,layer)
if direction<0
for ang=1 to 9
obj=puzzle(1,layer,3):global_rotate_y(obj,10.0)
obj=puzzle(2,layer,3):global_rotate_y(obj,10.0)
obj=puzzle(3,layer,3):global_rotate_y(obj,10.0)
obj=puzzle(1,layer,2):global_rotate_y(obj,10.0)
obj=puzzle(2,layer,2):global_rotate_y(obj,10.0)
obj=puzzle(3,layer,2):global_rotate_y(obj,10.0)
obj=puzzle(1,layer,1):global_rotate_y(obj,10.0)
obj=puzzle(2,layer,1):global_rotate_y(obj,10.0)
obj=puzzle(3,layer,1):global_rotate_y(obj,10.0)
sync
next ang
copy_to_temp()
temp_puzzle(1,layer,3)=puzzle(1,layer,1)
temp_puzzle(1,layer,2)=puzzle(2,layer,1)
temp_puzzle(1,layer,1)=puzzle(3,layer,1)
temp_puzzle(2,layer,3)=puzzle(1,layer,2)
temp_puzzle(2,layer,2)=puzzle(2,layer,2)
temp_puzzle(2,layer,1)=puzzle(3,layer,2)
temp_puzzle(3,layer,3)=puzzle(1,layer,3)
temp_puzzle(3,layer,2)=puzzle(2,layer,3)
temp_puzzle(3,layer,1)=puzzle(3,layer,3)
copy_to_puzzle()
update_collision()
endif
if direction>0
for ang=1 to 9
obj=puzzle(1,layer,3):global_rotate_y(obj,-10.0)
obj=puzzle(2,layer,3):global_rotate_y(obj,-10.0)
obj=puzzle(3,layer,3):global_rotate_y(obj,-10.0)
obj=puzzle(1,layer,2):global_rotate_y(obj,-10.0)
obj=puzzle(2,layer,2):global_rotate_y(obj,-10.0)
obj=puzzle(3,layer,2):global_rotate_y(obj,-10.0)
obj=puzzle(1,layer,1):global_rotate_y(obj,-10.0)
obj=puzzle(2,layer,1):global_rotate_y(obj,-10.0)
obj=puzzle(3,layer,1):global_rotate_y(obj,-10.0)
sync
next ang
copy_to_temp()
temp_puzzle(3,layer,1)=puzzle(1,layer,1)
temp_puzzle(3,layer,2)=puzzle(2,layer,1)
temp_puzzle(3,layer,3)=puzzle(3,layer,1)
temp_puzzle(2,layer,1)=puzzle(1,layer,2)
temp_puzzle(2,layer,2)=puzzle(2,layer,2)
temp_puzzle(2,layer,3)=puzzle(3,layer,2)
temp_puzzle(1,layer,1)=puzzle(1,layer,3)
temp_puzzle(1,layer,2)=puzzle(2,layer,3)
temp_puzzle(1,layer,3)=puzzle(3,layer,3)
copy_to_puzzle()
update_collision()
endif
endfunction
function rotate_x(direction,layer)
if direction<0
for ang=1 to 9
obj=puzzle(layer,1,1):global_rotate_x(obj,10.0)
obj=puzzle(layer,1,2):global_rotate_x(obj,10.0)
obj=puzzle(layer,1,3):global_rotate_x(obj,10.0)
obj=puzzle(layer,2,1):global_rotate_x(obj,10.0)
obj=puzzle(layer,2,2):global_rotate_x(obj,10.0)
obj=puzzle(layer,2,3):global_rotate_x(obj,10.0)
obj=puzzle(layer,3,1):global_rotate_x(obj,10.0)
obj=puzzle(layer,3,2):global_rotate_x(obj,10.0)
obj=puzzle(layer,3,3):global_rotate_x(obj,10.0)
sync
next ang
copy_to_temp()
temp_puzzle(layer,1,3)=puzzle(layer,1,1)
temp_puzzle(layer,2,3)=puzzle(layer,1,2)
temp_puzzle(layer,3,3)=puzzle(layer,1,3)
temp_puzzle(layer,1,2)=puzzle(layer,2,1)
temp_puzzle(layer,2,2)=puzzle(layer,2,2)
temp_puzzle(layer,3,2)=puzzle(layer,2,3)
temp_puzzle(layer,1,1)=puzzle(layer,3,1)
temp_puzzle(layer,2,1)=puzzle(layer,3,2)
temp_puzzle(layer,3,1)=puzzle(layer,3,3)
copy_to_puzzle()
update_collision()
endif
if direction>0
for ang=1 to 9
obj=puzzle(layer,1,1):global_rotate_x(obj,-10.0)
obj=puzzle(layer,1,2):global_rotate_x(obj,-10.0)
obj=puzzle(layer,1,3):global_rotate_x(obj,-10.0)
obj=puzzle(layer,2,1):global_rotate_x(obj,-10.0)
obj=puzzle(layer,2,2):global_rotate_x(obj,-10.0)
obj=puzzle(layer,2,3):global_rotate_x(obj,-10.0)
obj=puzzle(layer,3,1):global_rotate_x(obj,-10.0)
obj=puzzle(layer,3,2):global_rotate_x(obj,-10.0)
obj=puzzle(layer,3,3):global_rotate_x(obj,-10.0)
sync
next ang
copy_to_temp()
temp_puzzle(layer,3,1)=puzzle(layer,1,1)
temp_puzzle(layer,2,1)=puzzle(layer,1,2)
temp_puzzle(layer,1,1)=puzzle(layer,1,3)
temp_puzzle(layer,3,2)=puzzle(layer,2,1)
temp_puzzle(layer,2,2)=puzzle(layer,2,2)
temp_puzzle(layer,1,2)=puzzle(layer,2,3)
temp_puzzle(layer,3,3)=puzzle(layer,3,1)
temp_puzzle(layer,2,3)=puzzle(layer,3,2)
temp_puzzle(layer,1,3)=puzzle(layer,3,3)
copy_to_puzzle()
update_collision()
endif
endfunction
function rotate_z(direction,layer)
if direction<0
for ang=1 to 9
obj=puzzle(1,1,layer):global_rotate_z(obj,10.0)
obj=puzzle(2,1,layer):global_rotate_z(obj,10.0)
obj=puzzle(3,1,layer):global_rotate_z(obj,10.0)
obj=puzzle(1,2,layer):global_rotate_z(obj,10.0)
obj=puzzle(2,2,layer):global_rotate_z(obj,10.0)
obj=puzzle(3,2,layer):global_rotate_z(obj,10.0)
obj=puzzle(1,3,layer):global_rotate_z(obj,10.0)
obj=puzzle(2,3,layer):global_rotate_z(obj,10.0)
obj=puzzle(3,3,layer):global_rotate_z(obj,10.0)
sync
next ang
copy_to_temp()
temp_puzzle(1,3,layer)=puzzle(1,1,layer)
temp_puzzle(1,2,layer)=puzzle(2,1,layer)
temp_puzzle(1,1,layer)=puzzle(3,1,layer)
temp_puzzle(2,1,layer)=puzzle(3,2,layer)
temp_puzzle(2,2,layer)=puzzle(2,2,layer)
temp_puzzle(2,3,layer)=puzzle(1,2,layer)
temp_puzzle(3,3,layer)=puzzle(1,3,layer)
temp_puzzle(3,2,layer)=puzzle(2,3,layer)
temp_puzzle(3,1,layer)=puzzle(3,3,layer)
copy_to_puzzle()
update_collision()
endif
if direction>0
for ang=1 to 9
obj=puzzle(1,1,layer):global_rotate_z(obj,-10.0)
obj=puzzle(2,1,layer):global_rotate_z(obj,-10.0)
obj=puzzle(3,1,layer):global_rotate_z(obj,-10.0)
obj=puzzle(1,2,layer):global_rotate_z(obj,-10.0)
obj=puzzle(2,2,layer):global_rotate_z(obj,-10.0)
obj=puzzle(3,2,layer):global_rotate_z(obj,-10.0)
obj=puzzle(1,3,layer):global_rotate_z(obj,-10.0)
obj=puzzle(2,3,layer):global_rotate_z(obj,-10.0)
obj=puzzle(3,3,layer):global_rotate_z(obj,-10.0)
sync
next ang
copy_to_temp()
temp_puzzle(3,1,layer)=puzzle(1,1,layer)
temp_puzzle(3,2,layer)=puzzle(2,1,layer)
temp_puzzle(3,3,layer)=puzzle(3,1,layer)
temp_puzzle(2,3,layer)=puzzle(3,2,layer)
temp_puzzle(2,2,layer)=puzzle(2,2,layer)
temp_puzzle(2,1,layer)=puzzle(1,2,layer)
temp_puzzle(1,1,layer)=puzzle(1,3,layer)
temp_puzzle(1,2,layer)=puzzle(2,3,layer)
temp_puzzle(1,3,layer)=puzzle(3,3,layer)
copy_to_puzzle()
update_collision()
endif
endfunction
function rotate_cube_y(direction)
if direction>0
for l=1 to 9
for x=1 to 3
for y=1 to 3
for z=1 to 3
obj=puzzle(x,y,z):global_rotate_y(obj,-10.0)
next z
next y
next x
sync
next l
for layer=1 to 3
copy_to_temp()
temp_puzzle(3,layer,1)=puzzle(1,layer,1)
temp_puzzle(3,layer,2)=puzzle(2,layer,1)
temp_puzzle(3,layer,3)=puzzle(3,layer,1)
temp_puzzle(2,layer,1)=puzzle(1,layer,2)
temp_puzzle(2,layer,2)=puzzle(2,layer,2)
temp_puzzle(2,layer,3)=puzzle(3,layer,2)
temp_puzzle(1,layer,1)=puzzle(1,layer,3)
temp_puzzle(1,layer,2)=puzzle(2,layer,3)
temp_puzzle(1,layer,3)=puzzle(3,layer,3)
copy_to_puzzle()
next layer
update_collision()
endif
if direction<0
for l=1 to 9
for x=1 to 3
for y=1 to 3
for z=1 to 3
obj=puzzle(x,y,z):global_rotate_y(obj,10.0)
next z
next y
next x
sync
next l
for layer=1 to 3
copy_to_temp()
temp_puzzle(1,layer,3)=puzzle(1,layer,1)
temp_puzzle(1,layer,2)=puzzle(2,layer,1)
temp_puzzle(1,layer,1)=puzzle(3,layer,1)
temp_puzzle(2,layer,3)=puzzle(1,layer,2)
temp_puzzle(2,layer,2)=puzzle(2,layer,2)
temp_puzzle(2,layer,1)=puzzle(3,layer,2)
temp_puzzle(3,layer,3)=puzzle(1,layer,3)
temp_puzzle(3,layer,2)=puzzle(2,layer,3)
temp_puzzle(3,layer,1)=puzzle(3,layer,3)
copy_to_puzzle()
next layer
update_collision()
endif
endfunction
function rotate_cube_x(direction)
if direction>0
for l=1 to 9
for x=1 to 3
for y=1 to 3
for z=1 to 3
obj=puzzle(x,y,z):global_rotate_x(obj,-10.0)
next z
next y
next x
sync
next l
for layer=1 to 3
copy_to_temp()
temp_puzzle(layer,3,1)=puzzle(layer,1,1)
temp_puzzle(layer,2,1)=puzzle(layer,1,2)
temp_puzzle(layer,1,1)=puzzle(layer,1,3)
temp_puzzle(layer,3,2)=puzzle(layer,2,1)
temp_puzzle(layer,2,2)=puzzle(layer,2,2)
temp_puzzle(layer,1,2)=puzzle(layer,2,3)
temp_puzzle(layer,3,3)=puzzle(layer,3,1)
temp_puzzle(layer,2,3)=puzzle(layer,3,2)
temp_puzzle(layer,1,3)=puzzle(layer,3,3)
copy_to_puzzle()
next layer
update_collision()
endif
if direction<0
for l=1 to 9
for x=1 to 3
for y=1 to 3
for z=1 to 3
obj=puzzle(x,y,z):global_rotate_x(obj,10.0)
next z
next y
next x
sync
next l
for layer=1 to 3
copy_to_temp()
temp_puzzle(layer,1,3)=puzzle(layer,1,1)
temp_puzzle(layer,2,3)=puzzle(layer,1,2)
temp_puzzle(layer,3,3)=puzzle(layer,1,3)
temp_puzzle(layer,1,2)=puzzle(layer,2,1)
temp_puzzle(layer,2,2)=puzzle(layer,2,2)
temp_puzzle(layer,3,2)=puzzle(layer,2,3)
temp_puzzle(layer,1,1)=puzzle(layer,3,1)
temp_puzzle(layer,2,1)=puzzle(layer,3,2)
temp_puzzle(layer,3,1)=puzzle(layer,3,3)
copy_to_puzzle()
next layer
update_collision()
endif
endfunction
function rotate_cube_z(direction)
if direction>0
for l=1 to 9
for x=1 to 3
for y=1 to 3
for z=1 to 3
obj=puzzle(x,y,z):global_rotate_z(obj,-10.0)
next z
next y
next x
sync
next l
for layer=1 to 3
copy_to_temp()
temp_puzzle(3,1,layer)=puzzle(1,1,layer)
temp_puzzle(3,2,layer)=puzzle(2,1,layer)
temp_puzzle(3,3,layer)=puzzle(3,1,layer)
temp_puzzle(2,3,layer)=puzzle(3,2,layer)
temp_puzzle(2,2,layer)=puzzle(2,2,layer)
temp_puzzle(2,1,layer)=puzzle(1,2,layer)
temp_puzzle(1,1,layer)=puzzle(1,3,layer)
temp_puzzle(1,2,layer)=puzzle(2,3,layer)
temp_puzzle(1,3,layer)=puzzle(3,3,layer)
copy_to_puzzle()
next layer
update_collision()
endif
if direction<0
for l=1 to 9
for x=1 to 3
for y=1 to 3
for z=1 to 3
obj=puzzle(x,y,z):global_rotate_z(obj,10.0)
next z
next y
next x
sync
next l
for layer=1 to 3
copy_to_temp()
temp_puzzle(1,3,layer)=puzzle(1,1,layer)
temp_puzzle(1,2,layer)=puzzle(2,1,layer)
temp_puzzle(1,1,layer)=puzzle(3,1,layer)
temp_puzzle(2,1,layer)=puzzle(3,2,layer)
temp_puzzle(2,2,layer)=puzzle(2,2,layer)
temp_puzzle(2,3,layer)=puzzle(1,2,layer)
temp_puzzle(3,3,layer)=puzzle(1,3,layer)
temp_puzzle(3,2,layer)=puzzle(2,3,layer)
temp_puzzle(3,1,layer)=puzzle(3,3,layer)
copy_to_puzzle()
next layer
update_collision()
endif
endfunction
function copy_to_temp()
for x=1 to 3
for y=1 to 3
for z=1 to 3
temp_puzzle(x,y,z)=puzzle(x,y,z)
next z
next y
next x
endfunction
function copy_to_puzzle()
for x=1 to 3
for y=1 to 3
for z=1 to 3
puzzle(x,y,z)=temp_puzzle(x,y,z)
next z
next y
next x
endfunction
function global_rotate_y(obj,ang#)
EZro_SetEuler OBJECT ANGLE X(obj),OBJECT ANGLE Y(obj),OBJECT ANGLE Z(obj)
EZro_SetPos OBJECT POSITION X(obj),OBJECT POSITION Y(obj),OBJECT POSITION Z(obj)
EZro_Orbit 1,0.0,-100.0,0.0,0.0,100.0,0.0,ang#
EZro_FindEuler
rotate object obj,EZro_GetEulerX(),EZro_GetEulerY(),EZro_GetEulerZ()
position object obj,EZro_GetPosX(),EZro_GetPosY(),EZro_GetPosZ()
if ang#<0 and obj<100
for f=1 to 6
temp_faces(obj,f)=faces(obj,f)
next f
temp_faces(obj,front)=faces(obj,left)
temp_faces(obj,left)=faces(obj,back)
temp_faces(obj,back)=faces(obj,right)
temp_faces(obj,right)=faces(obj,front)
for f=1 to 6
faces(obj,f)=temp_faces(obj,f)
next f
endif
if ang#>0 and obj<100
for f=1 to 6
temp_faces(obj,f)=faces(obj,f)
next f
temp_faces(obj,front)=faces(obj,right)
temp_faces(obj,right)=faces(obj,back)
temp_faces(obj,back)=faces(obj,left)
temp_faces(obj,left)=faces(obj,front)
for f=1 to 6
faces(obj,f)=temp_faces(obj,f)
next f
endif
inc flashing
if flashing>100 then flashing=0
if flashing>50 and solving=1 then text 0,0,"SOLVING - Please Wait"
if flashing>50 and jumbling=1 then text 0,0,"JUMBLING - Please Wait"
endfunction
function global_rotate_x(obj,ang#)
EZro_SetEuler OBJECT ANGLE X(obj),OBJECT ANGLE Y(obj),OBJECT ANGLE Z(obj)
EZro_SetPos OBJECT POSITION X(obj),OBJECT POSITION Y(obj),OBJECT POSITION Z(obj)
EZro_Orbit 1,-100.0,0.0,0.0,100.0,0.0,0.0,ang#
EZro_FindEuler
rotate object obj,EZro_GetEulerX(),EZro_GetEulerY(),EZro_GetEulerZ()
position object obj,EZro_GetPosX(),EZro_GetPosY(),EZro_GetPosZ()
if ang#>0 and obj<100
for f=1 to 6
temp_faces(obj,f)=faces(obj,f)
next f
temp_faces(obj,top)=faces(obj,front)
temp_faces(obj,front)=faces(obj,bottom)
temp_faces(obj,bottom)=faces(obj,back)
temp_faces(obj,back)=faces(obj,top)
for f=1 to 6
faces(obj,f)=temp_faces(obj,f)
next f
endif
if ang#<0 and obj<100
for f=1 to 6
temp_faces(obj,f)=faces(obj,f)
next f
temp_faces(obj,top)=faces(obj,back)
temp_faces(obj,back)=faces(obj,bottom)
temp_faces(obj,bottom)=faces(obj,front)
temp_faces(obj,front)=faces(obj,top)
for f=1 to 6
faces(obj,f)=temp_faces(obj,f)
next f
endif
inc flashing
if flashing>100 then flashing=0
if flashing>50 and solving=1 then text 0,0,"SOLVING - Please Wait"
if flashing>50 and jumbling=1 then text 0,0,"JUMBLING - Please Wait"
endfunction
function global_rotate_z(obj,ang#)
EZro_SetEuler OBJECT ANGLE X(obj),OBJECT ANGLE Y(obj),OBJECT ANGLE Z(obj)
EZro_SetPos OBJECT POSITION X(obj),OBJECT POSITION Y(obj),OBJECT POSITION Z(obj)
EZro_Orbit 1,0.0,0.0,-100.0,0.0,0.0,100.0,ang#
EZro_FindEuler
rotate object obj,EZro_GetEulerX(),EZro_GetEulerY(),EZro_GetEulerZ()
position object obj,EZro_GetPosX(),EZro_GetPosY(),EZro_GetPosZ()
if ang#<0 and obj<100
for f=1 to 6
temp_faces(obj,f)=faces(obj,f)
next f
temp_faces(obj,top)=faces(obj,left)
temp_faces(obj,left)=faces(obj,bottom)
temp_faces(obj,bottom)=faces(obj,right)
temp_faces(obj,right)=faces(obj,top)
for f=1 to 6
faces(obj,f)=temp_faces(obj,f)
next f
endif
if ang#>0 and obj<100
for f=1 to 6
temp_faces(obj,f)=faces(obj,f)
next f
temp_faces(obj,top)=faces(obj,right)
temp_faces(obj,right)=faces(obj,bottom)
temp_faces(obj,bottom)=faces(obj,left)
temp_faces(obj,left)=faces(obj,top)
for f=1 to 6
faces(obj,f)=temp_faces(obj,f)
next f
endif
inc flashing
if flashing>100 then flashing=0
if flashing>50 and solving=1 then text 0,0,"SOLVING - Please Wait"
if flashing>50 and jumbling=1 then text 0,0,"JUMBLING - Please Wait"
endfunction
function jumble_cube(amount)
set text size 50
jumbling=1
`sync rate 0
for l=1 to amount
num=rnd(23)+1
if escapekey() then end
if num=1 then rotate_y(-1,1)
if num=2 then rotate_y(1,1)
if num=3 then rotate_y(-1,2)
if num=4 then rotate_y(1,2)
if num=5 then rotate_y(-1,3)
if num=6 then rotate_y(1,3)
if num=7 then rotate_x(-1,1)
if num=8 then rotate_x(1,1)
if num=9 then rotate_x(-1,2)
if num=10 then rotate_x(1,2)
if num=11 then rotate_x(-1,3)
if num=12 then rotate_x(1,3)
if num=13 then rotate_z(-1,1)
if num=14 then rotate_z(1,1)
if num=15 then rotate_z(-1,2)
if num=16 then rotate_z(1,2)
if num=17 then rotate_z(-1,3)
if num=18 then rotate_z(1,3)
if num=19 then rotate_cube_y(-1)
if num=20 then rotate_cube_y(1)
if num=21 then rotate_cube_x(-1)
if num=22 then rotate_cube_x(1)
if num=23 then rotate_cube_z(-1)
if num=24 then rotate_cube_z(1)
next l
`sync rate 60
jumbling=0
set text size 12
endfunction
function make_texture(img,r,g,b)
create bitmap 1,256,256
set current bitmap 1
cls
ink rgb(r,g,b),0
for x=16 to 240
circle x,16,6
next x
for x=16 to 240
circle x,240,6
next x
for y=16 to 240
circle 16,y,6
next y
for y=16 to 240
circle 240,y,6
next y
box 18,18,237,237,rgb(r,g,b),rgb(r,g,b),rgb(r,g,b),rgb(r,g,b)
get image img,0,0,255,255
ink 0,0
set text size 80
set text to bold
text 25,50,"DARK"
text 25,130,"CUBE"
set text size 12
set text to normal
flip bitmap 1
get image img+7,0,0,255,255
set current bitmap 0
delete bitmap 1
endfunction
cube_data:
`top bottom left right back front
`top row
data "red","black","green","black","black","blue",-1,1,-1
data "red","black","black","black","black","blue",0,1,-1
data "red","black","black","yellow","black","blue",1,1,-1
data "red","black","green","black","black","black",-1,1,0
data "red","black","black","black","black","black",0,1,0
data "red","black","black","yellow","black","black",1,1,0
data "red","black","green","black","white","black",-1,1,1
data "red","black","black","black","white","black",0,1,1
data "red","black","black","yellow","white","black",1,1,1
`middle row
data "black","black","green","black","black","blue",-1,0,-1
data "black","black","black","black","black","blue",0,0,-1
data "black","black","black","yellow","black","blue",1,0,-1
data "black","black","green","black","black","black",-1,0,0
data "black","black","black","black","black","black",0,0,0
data "black","black","black","yellow","black","black",1,0,0
data "black","black","green","black","white","black",-1,0,1
data "black","black","black","black","white","black",0,0,1
data "black","black","black","yellow","white","black",1,0,1
`bottom row
data "black","orange","green","black","black","blue",-1,-1,-1
data "black","orange","black","black","black","blue",0,-1,-1
data "black","orange","black","yellow","black","blue",1,-1,-1
data "black","orange","green","black","black","black",-1,-1,0
data "black","orange","black","black","black","black",0,-1,0
data "black","orange","black","yellow","black","black",1,-1,0
data "black","orange","green","black","white","black",-1,-1,1
data "black","orange","black","black","white","black",0,-1,1
data "black","orange","black","yellow","white","black",1,-1,1
function create_gui_decal()
set bitmap format 21
create bitmap 1,256,256
make memblock from bitmap 1,1
delete bitmap 1
pos=12
for y=1 to 256
for x=1 to 256
write memblock byte 1,pos,0:inc pos
write memblock byte 1,pos,0:inc pos
write memblock byte 1,pos,0:inc pos
write memblock byte 1,pos,255:inc pos
next x
next y
make bitmap from memblock 1,1
delete memblock 1
set current bitmap 1
for l=10 to 1 step -1
ink rgb(l*10,l*10,l*10)
line 128-l,30,128-l,220
next l
for l=25 to 1 step -1
ink rgb(l*10,l*10,l*10)
line 128+l,30,128+l,220
next l
for l=25 to 1 step -1
ink rgb(l*10,l*10,l*10)
line 128,30-l,50,100-l
next l
for l=25 to 1 step -1
ink rgb(l*10,l*10,l*10)
line 128,30+l,50,100+l
next l
for l=25 to 1 step -1
ink rgb(l*10,l*10,l*10)
line 128,30+l,205,100+l
next l
for l=25 to 1 step -1
ink rgb(l*10,l*10,l*10)
line 128,30-l,205,100-l
next l
get image gui,0,0,255,255
set current bitmap 0
delete bitmap 1
ink 0,0
endfunction
function update_collision()
for l=1 to 27
sc_updateobject l
next l
endfunction
function add_gui_decal()
position object decal,cx,cy,cz
point object decal,cx+nx,cy+ny,cz+nz
done=0
if nz<0
if hit=puzzle(1,1,1)
position object decal,object position x(puzzle(1,1,1)),object position y(puzzle(1,1,1)),cz
if mouseclick()>0 then rotate_x(-1,1)
done=1
endif
if hit=puzzle(2,1,1)
position object decal,object position x(puzzle(2,1,1)),object position y(puzzle(2,1,1)),cz
if mouseclick()>0 then rotate_x(-1,2)
done=1
endif
if hit=puzzle(3,1,1)
position object decal,object position x(puzzle(3,1,1)),object position y(puzzle(3,1,1)),cz
if mouseclick()>0 then rotate_x(-1,3)
done=1
endif
if hit=puzzle(1,3,1)
position object decal,object position x(puzzle(1,3,1)),object position y(puzzle(1,3,1)),cz
zrotate object decal,180
if mouseclick()>0 then rotate_x(1,1)
done=1
endif
if hit=puzzle(2,3,1)
position object decal,object position x(puzzle(2,3,1)),object position y(puzzle(2,3,1)),cz
zrotate object decal,180
if mouseclick()>0 then rotate_x(1,2)
done=1
endif
if hit=puzzle(3,3,1)
position object decal,object position x(puzzle(3,3,1)),object position y(puzzle(3,3,1)),cz
zrotate object decal,180
if mouseclick()>0 then rotate_x(1,3)
done=1
endif
endif
if nx>0
if hit=puzzle(3,1,1)
global_rotate_x(decal,-90)
position object decal,cx,object position y(puzzle(3,1,1)),object position z(puzzle(3,1,1))
if mouseclick()>0 then rotate_y(-1,1)
done=1
endif
if hit=puzzle(3,2,1)
global_rotate_x(decal,-90)
position object decal,cx,object position y(puzzle(3,2,1)),object position z(puzzle(3,2,1))
if mouseclick()>0 then rotate_y(-1,2)
done=1
endif
if hit=puzzle(3,3,1)
global_rotate_x(decal,-90)
position object decal,cx,object position y(puzzle(3,3,1)),object position z(puzzle(3,3,1))
if mouseclick()>0 then rotate_y(-1,3)
done=1
endif
if hit=puzzle(3,1,3)
global_rotate_x(decal,90)
position object decal,cx,object position y(puzzle(3,1,3)),object position z(puzzle(3,1,3))
if mouseclick()>0 then rotate_y(1,1)
done=1
endif
if hit=puzzle(3,2,3)
global_rotate_x(decal,90)
position object decal,cx,object position y(puzzle(3,2,3)),object position z(puzzle(3,2,3))
if mouseclick()>0 then rotate_y(1,2)
done=1
endif
if hit=puzzle(3,3,3)
global_rotate_x(decal,90)
position object decal,cx,object position y(puzzle(3,3,3)),object position z(puzzle(3,3,3))
if mouseclick()>0 then rotate_y(1,3)
done=1
endif
endif
if ny>0
if hit=puzzle(1,1,1)
global_rotate_y(decal,90)
position object decal,object position x(puzzle(1,1,1)),cy,object position z(puzzle(1,1,1))
if mouseclick()>0 then rotate_z(-1,1)
done=1
endif
if hit=puzzle(1,1,2)
global_rotate_y(decal,90)
position object decal,object position x(puzzle(1,1,2)),cy,object position z(puzzle(1,1,2))
if mouseclick()>0 then rotate_z(-1,2)
done=1
endif
if hit=puzzle(1,1,3)
global_rotate_y(decal,90)
position object decal,object position x(puzzle(1,1,3)),cy,object position z(puzzle(1,1,3))
if mouseclick()>0 then rotate_z(-1,3)
done=1
endif
if hit=puzzle(3,1,1)
global_rotate_y(decal,-90)
position object decal,object position x(puzzle(3,1,1)),cy,object position z(puzzle(3,1,1))
if mouseclick()>0 then rotate_z(1,1)
done=1
endif
if hit=puzzle(3,1,2)
global_rotate_y(decal,-90)
position object decal,object position x(puzzle(3,1,2)),cy,object position z(puzzle(3,1,2))
if mouseclick()>0 then rotate_z(1,2)
done=1
endif
if hit=puzzle(3,1,3)
global_rotate_y(decal,-90)
position object decal,object position x(puzzle(3,1,3)),cy,object position z(puzzle(3,1,3))
if mouseclick()>0 then rotate_z(1,3)
done=1
endif
endif
if done=1
show object decal
else
hide object decal
endif
`text 0,45,"object hit "+str$(hit)+" x ang "+str$(int(object angle x(hit)))+" y ang "+str$(int(object angle y(hit)))+" z ang "+str$(int(object angle z(hit)))
endfunction
function show_overlay()
obj_num=puzzle(1,1,1)
overlay(4,3)=faces(obj_num,top)
overlay(4,4)=faces(obj_num,front)
overlay(3,4)=faces(obj_num,left)
obj_num=puzzle(2,1,1)
overlay(5,3)=faces(obj_num,top)
overlay(5,4)=faces(obj_num,front)
obj_num=puzzle(3,1,1)
overlay(6,3)=faces(obj_num,top)
overlay(6,4)=faces(obj_num,front)
overlay(7,4)=faces(obj_num,right)
obj_num=puzzle(1,1,2)
overlay(4,2)=faces(obj_num,top)
overlay(2,4)=faces(obj_num,left)
obj_num=puzzle(2,1,2)
overlay(5,2)=faces(obj_num,top)
obj_num=puzzle(3,1,2)
overlay(6,2)=faces(obj_num,top)
overlay(8,4)=faces(obj_num,right)
obj_num=puzzle(1,1,3)
overlay(4,1)=faces(obj_num,top)
overlay(4,12)=faces(obj_num,back)
overlay(1,4)=faces(obj_num,left)
obj_num=puzzle(2,1,3)
overlay(5,1)=faces(obj_num,top)
overlay(5,12)=faces(obj_num,back)
obj_num=puzzle(3,1,3)
overlay(6,1)=faces(obj_num,top)
overlay(6,12)=faces(obj_num,back)
overlay(9,4)=faces(obj_num,right)
obj_num=puzzle(1,2,1)
overlay(4,5)=faces(obj_num,front)
overlay(3,5)=faces(obj_num,left)
obj_num=puzzle(2,2,1)
overlay(5,5)=faces(obj_num,front)
obj_num=puzzle(3,2,1)
overlay(6,5)=faces(obj_num,front)
overlay(7,5)=faces(obj_num,right)
obj_num=puzzle(1,2,2)
overlay(2,5)=faces(obj_num,left)
obj_num=puzzle(3,2,2)
overlay(8,5)=faces(obj_num,right)
obj_num=puzzle(1,2,3)
overlay(1,5)=faces(obj_num,left)
overlay(4,11)=faces(obj_num,back)
obj_num=puzzle(3,2,3)
overlay(9,5)=faces(obj_num,right)
overlay(6,11)=faces(obj_num,back)
obj_num=puzzle(2,2,3)
overlay(5,11)=faces(obj_num,back)
obj_num=puzzle(1,3,1)
overlay(4,7)=faces(obj_num,bottom)
overlay(4,6)=faces(obj_num,front)
overlay(3,6)=faces(obj_num,left)
obj_num=puzzle(2,3,1)
overlay(5,7)=faces(obj_num,bottom)
overlay(5,6)=faces(obj_num,front)
obj_num=puzzle(3,3,1)
overlay(6,7)=faces(obj_num,bottom)
overlay(6,6)=faces(obj_num,front)
overlay(7,6)=faces(obj_num,right)
obj_num=puzzle(1,3,2)
overlay(4,8)=faces(obj_num,bottom)
overlay(2,6)=faces(obj_num,left)
obj_num=puzzle(2,3,2)
overlay(5,8)=faces(obj_num,bottom)
obj_num=puzzle(3,3,2)
overlay(6,8)=faces(obj_num,bottom)
overlay(8,6)=faces(obj_num,right)
obj_num=puzzle(1,3,3)
overlay(4,9)=faces(obj_num,bottom)
overlay(4,10)=faces(obj_num,back)
overlay(1,6)=faces(obj_num,left)
obj_num=puzzle(2,3,3)
overlay(5,9)=faces(obj_num,bottom)
overlay(5,10)=faces(obj_num,back)
obj_num=puzzle(3,3,3)
overlay(6,9)=faces(obj_num,bottom)
overlay(6,10)=faces(obj_num,back)
overlay(9,6)=faces(obj_num,right)
for x=1 to 9
for y=1 to 12
if overlay(x,y)=red then ink rgb(255,0,0),0:text x*12+10,y*12+60,"R"
if overlay(x,y)=green then ink rgb(0,255,0),0:text x*12+10,y*12+60,"G"
if overlay(x,y)=blue then ink rgb(50,50,255),0:text x*12+10,y*12+60,"B"
if overlay(x,y)=yellow then ink rgb(255,255,0),0:text x*12+10,y*12+60,"Y"
if overlay(x,y)=white then ink rgb(255,255,255),0:text x*12+10,y*12+60,"W"
if overlay(x,y)=orange then ink rgb(255,125,0),0:text x*12+10,y*12+60,"O"
next y
next x
ink rgb(0,0,0),0
endfunction
function fix_cube_angles()
for z=1 to 3
for y=1 to 3
for x=1 to 3
obj=puzzle(x,y,z)
angx=object angle x(obj)
angy=object angle y(obj)
angz=object angle z(obj)
if angx<-80 and angx>-100 then angx=-90
if angx<-170 and angx>-190 then angx=-180
if angx<-260 and angx>-280 then angx=-270
if angx>-10 and angx<10 then angx=0
if angx>80 and angx<100 then angx=90
if angx>170 and angx<190 then angx=180
if angx>260 and angx<280 then angx=270
if angy<-80 and angy>-100 then angy=-90
if angy<-170 and angy>-190 then angy=-180
if angy<-260 and angy>-280 then angy=-270
if angy>-10 and angy<10 then angy=0
if angy>80 and angy<100 then angy=90
if angy>170 and angy<190 then angy=180
if angy>260 and angy<280 then angy=270
if angz<-80 and angz>-100 then angz=-90
if angz<-170 and angz>-190 then angz=-180
if angz<-260 and angz>-280 then angz=-270
if angz>-10 and angz<10 then angz=0
if angz>80 and angz<100 then angz=90
if angz>170 and angz<190 then angz=180
if angz>260 and angz<280 then angz=270
rotate object obj,angx,angy,angz
next x
next y
next z
endfunction
`**************************************************************************************************
`solver functions start here
`**************************************************************************************************
function solver()
set text size 50
solving=1
`*******************************************************************
`start of top layer soling routines
`*******************************************************************
`start off with the red face at the top in th center
restore rules_for_solving_top_square:
carry_out_rules()
`make a cross on the top with the red pieces
count=0
while not top_cross_complete(red)
restore rules_for_solving_first_layer_part1:
carry_out_rules()
rotate_cube_y(-1)
inc count
if count>4
count=0
rotate_y(-1,3)
endif
if spacekey() then exit
endwhile
`line up center side color to one of the top edge pieces
restore rules_for_solving_first_layer_part2:
carry_out_rules()
`swap top edges middle pieces until they match up with cube side centre pieces
while not top_cross_align()
restore rules_for_solving_first_layer_part3:
carry_out_rules()
rotate_cube_y(-1)
if spacekey() then exit
endwhile
`put in the top 4 corners
count=0
while not top_corners_complete(red)
restore rules_for_solving_first_layer_part4:
carry_out_rules()
rotate_cube_y(-1)
inc count
if count>4
count=0
rotate_y(-1,3)
endif
if spacekey() then exit
endwhile
`swap top edges midle pieces until they match up with cube side centre pieces
while not top_corners_align()
restore rules_for_solving_first_layer_part5:
carry_out_rules()
rotate_cube_y(-1)
if spacekey() then exit
endwhile
`*******************************************************************
`top layer and center side faces are complete and aligned by here
`*******************************************************************
`turn the cube upside down for next step
rotate_cube_z(1)
rotate_cube_z(1)
`put in the middle layer 4 corners
count=0
while not middle_corners_complete()
restore rules_for_solving_middle_layer_part1:
carry_out_rules()
rotate_cube_y(-1)
inc count
if count>4
count=0
rotate_y(-1,1)
endif
if spacekey() then exit
endwhile
solving=0
set text size 12
endfunction
function carry_out_rules()
done=0
rule$=""
while rule$<>"end"
ok=0
ok_count=0
while rule$<>"end conditions" and rule$<>"end"
read rule$
if rule$="condition"
col=0:face1=0:face2=0
read x1,y1,z1,face1$
read opp$
read x2,y2,z2,face2$
read col$
face1=convert_face_string(face1$)
face2=convert_face_string(face2$)
col=convert_color_string(col$)
inc ok_count
`check the condition for true or false
if col>0
if opp$="="
if faces(puzzle(x1,y1,z1),face1)=col
inc ok
endif
endif
if opp$="<>"
if faces(puzzle(x1,y1,z1),face1)<>col
inc ok
endif
endif
else
if opp$="="
if faces(puzzle(x1,y1,z1),face1)=faces(puzzle(x2,y2,z2),face2)
inc ok
endif
endif
if opp$="<>"
if faces(puzzle(x1,y1,z1),face1)<>faces(puzzle(x2,y2,z2),face2)
inc ok
endif
endif
endif
endif
endwhile
`carry out the moves if ok
num_moves=0
if ok_count>0 and ok=ok_count
read num_moves
endif
if num_moves>0
for l=1 to num_moves
read axis$,layer,direction$
if axis$="z"
if direction$="l"
rotate_z(-1,layer)
endif
if direction$="r"
rotate_z(1,layer)
endif
endif
if axis$="x"
if direction$="l"
rotate_x(1,layer)
endif
if direction$="r"
rotate_x(-1,layer)
endif
endif
if axis$="y"
if direction$="l"
rotate_y(-1,layer)
endif
if direction$="r"
rotate_y(1,layer)
endif
endif
next l
done=1
endif
if rule$<>"end" then rule$=""
endwhile
endfunction done
`functions for checking
function top_cross_complete(col)
ok=0
if faces(puzzle(2,1,1),top)=col
if faces(puzzle(1,1,2),top)=col
if faces(puzzle(2,1,3),top)=col
if faces(puzzle(3,1,2),top)=col
if faces(puzzle(2,1,2),top)=col
ok=1
endif
endif
endif
endif
endif
endfunction ok
function top_cross_align()
ok=0
if faces(puzzle(2,1,1),front)=faces(puzzle(2,2,1),front)
if faces(puzzle(3,1,2),right)=faces(puzzle(3,2,2),right)
if faces(puzzle(2,1,3),back)=faces(puzzle(2,2,3),back)
if faces(puzzle(1,1,2),left)=faces(puzzle(1,2,2),left)
ok=1
endif
endif
endif
endif
endfunction ok
function top_corners_complete(col)
ok=0
if faces(puzzle(1,1,1),top)=col
if faces(puzzle(3,1,1),top)=col
if faces(puzzle(1,1,3),top)=col
if faces(puzzle(3,1,3),top)=col
ok=1
endif
endif
endif
endif
endfunction ok
function top_corners_align()
ok=0
if faces(puzzle(1,1,1),front)=faces(puzzle(2,2,1),front) and faces(puzzle(3,1,1),front)=faces(puzzle(2,2,1),front)
if faces(puzzle(3,1,1),right)=faces(puzzle(3,2,2),right) and faces(puzzle(3,1,3),right)=faces(puzzle(3,2,2),right)
if faces(puzzle(3,1,3),back)=faces(puzzle(2,2,3),back) and faces(puzzle(1,1,3),back)=faces(puzzle(2,2,3),back)
if faces(puzzle(1,1,3),left)=faces(puzzle(1,2,2),left) and faces(puzzle(1,1,1),left)=faces(puzzle(1,2,2),left)
ok=1
endif
endif
endif
endif
endfunction ok
function middle_corners_complete()
ok=0
if faces(puzzle(1,2,1),front)=faces(puzzle(2,2,1),front) and faces(puzzle(3,2,1),front)=faces(puzzle(2,2,1),front)
if faces(puzzle(3,2,1),right)=faces(puzzle(3,2,2),right) and faces(puzzle(3,2,3),right)=faces(puzzle(3,2,2),right)
if faces(puzzle(3,2,3),back)=faces(puzzle(2,2,3),back) and faces(puzzle(1,2,3),back)=faces(puzzle(2,2,3),back)
if faces(puzzle(1,2,3),left)=faces(puzzle(1,2,2),left) and faces(puzzle(1,2,1),left)=faces(puzzle(1,2,2),left)
ok=1
endif
endif
endif
endif
endfunction ok
rules_for_solving_top_square:
data "condition"
data 3,2,2,"right"
data "="
data 0,0,0,""
data "red"
data "end conditions"
data 1
data "z",2,"l"
data "condition"
data 1,2,2,"left"
data "="
data 0,0,0,""
data "red"
data "end conditions"
data 1
data "z",2,"r"
data "condition"
data 2,2,1,"front"
data "="
data 0,0,0,""
data "red"
data "end conditions"
data 1
data "x",2,"r"
data "condition"
data 2,2,3,"back"
data "="
data 0,0,0,""
data "red"
data "end conditions"
data 1
data "x",2,"l"
data "condition"
data 2,3,2,"bottom"
data "="
data 0,0,0,""
data "red"
data "end conditions"
data 2
data "x",2,"r","x",2,"r"
data "end"
rules_for_solving_first_layer_part1:
data "condition"
data 2,3,1,"front"
data "="
data 0,0,0,""
data "red"
data "condition"
data 3,1,2,"top"
data "<>"
data 0,0,0,""
data "red"
data "end conditions"
data 3
data "z",2,"r"
data "y",3,"r"
data "z",2,"l"
data "condition"
data 3,1,2,"right"
data "="
data 0,0,0,""
data "red"
data "end conditions"
data 8
data "z",2,"r"
data "y",3,"r","y",3,"r"
data "z",2,"l"
data "y",3,"r"
data "z",2,"r"
data "y",3,"l"
data "z",2,"l"
data "condition"
data 3,2,1,"right"
data "="
data 0,0,0,""
data "red"
data "end conditions"
data 3
data "z",1,"r"
data "y",3,"r"
data "z",1,"l"
data "condition"
data 3,2,1,"front"
data "="
data 0,0,0,""
data "red"
data "end conditions"
data 3
data "z",1,"r"
data "y",3,"r"
data "z",1,"l"
data "condition"
data 3,3,2,"bottom"
data "="
data 0,0,0,""
data "red"
data "condition"
data 3,1,2,"top"
data "<>"
data 0,0,0,""
data "red"
data "end conditions"
data 4
data "z",2,"r"
data "y",3,"r","y",3,"r"
data "z",2,"l"
data "end"
rules_for_solving_first_layer_part2:
data "condition"
data 3,1,2,"right"
data "="
data 2,2,1,"front"
data ""
data "end conditions"
data 1
data "y",1,"l"
data "condition"
data 2,1,3,"back"
data "="
data 2,2,1,"front"
data ""
data "end conditions"
data 2
data "y",1,"l","y",1,"l"
data "condition"
data 1,1,2,"left"
data "="
data 2,2,1,"front"
data ""
data "end conditions"
data 1
data "y",1,"r"
data "end"
rules_for_solving_first_layer_part3:
data "condition"
data 3,1,2,"right"
data "<>"
data 3,2,2,"right"
data ""
data "condition"
data 2,1,3,"back"
data "<>"
data 2,2,3,"back"
data ""
data "end conditions"
data 11
data "z",2,"r"
data "y",3,"l"
data "z",2,"l"
data "y",3,"l"
data "x",2,"r"
data "y",3,"l"
data "x",2,"l"
data "y",3,"l"
data "z",2,"r"
data "y",3,"r"
data "z",2,"l"
data "condition"
data 3,1,2,"right"
data "="
data 1,2,2,"left"
data ""
data "condition"
data 1,1,2,"left"
data "="
data 3,2,2,"right"
data ""
data "end conditions"
data 9
data "z",2,"r"
data "y",3,"l"
data "z",2,"l","z",2,"l"
data "y",3,"l"
data "z",2,"r","z",2,"r"
data "y",3,"l"
data "z",2,"l"
data "end"
rules_for_solving_first_layer_part4:
data "condition"
data 3,3,1,"right"
data "="
data 0,0,0,""
data "red"
data "condition"
data 3,1,1,"top"
data "<>"
data 0,0,0,""
data "red"
data "end conditions"
data 4
data "y",3,"r"
data "z",1,"r"
data "y",3,"l"
data "z",1,"l"
data "condition"
data 3,3,1,"front"
data "="
data 0,0,0,""
data "red"
data "condition"
data 3,1,1,"top"
data "<>"
data 0,0,0,""
data "red"
data "end conditions"
data 4
data "y",3,"l"
data "x",3,"l"
data "y",3,"r"
data "x",3,"r"
data "condition"
data 3,1,1,"front"
data "="
data 0,0,0,""
data "red"
data "end conditions"
data 3
data "z",1,"r"
data "y",3,"r"
data "z",1,"l"
data "condition"
data 3,3,1,"bottom"
data "="
data 0,0,0,""
data "red"
data "condition"
data 3,1,1,"top"
data "<>"
data 0,0,0,""
data "red"
data "end conditions"
data 7
data "z",1,"r"
data "y",3,"l"
data "z",1,"l"
data "x",3,"l"
data "y",3,"l","y",3,"l"
data "x",3,"r"
data "end"
rules_for_solving_first_layer_part5:
data "condition"
data 3,1,1,"front"
data "="
data 3,2,2,"right"
data ""
data "condition"
data 3,1,3,"right"
data "="
data 2,2,1,"front"
data ""
data "end conditions"
data 10
data "x",3,"l"
data "y",3,"l"
data "x",3,"r"
data "z",3,"r"
data "y",3,"l","y",3,"l"
data "z",3,"l"
data "x",3,"l"
data "y",3,"r"
data "x",3,"r"
data "condition"
data 3,1,1,"front"
data "<>"
data 2,2,1,"front"
data ""
data "condition"
data 3,1,1,"right"
data "<>"
data 3,2,2,"right"
data ""
data "condition"
data 1,1,3,"left"
data "<>"
data 1,2,2,"left"
data ""
data "condition"
data 1,1,3,"back"
data "<>"
data 2,2,3,"back"
data ""
data "end conditions"
data 6
data "z",1,"r"
data "z",3,"l"
data "y",3,"l","y",3,"l"
data "z",1,"l"
data "z",3,"r"
data "end"
rules_for_solving_middle_layer_part1:
data "condition"
data 3,1,2,"top"
data "="
data 2,2,1,"front"
data ""
data "condition"
data 3,1,2,"right"
data "="
data 3,2,2,"right"
data ""
data "end conditions"
data 8
data "y",1,"r"
data "z",1,"l"
data "y",1,"l"
data "z",1,"r"
data "y",1,"l"
data "x",3,"r"
data "y",1,"r"
data "x",3,"l"
data "condition"
data 2,1,1,"top"
data "="
data 3,2,2,"right"
data ""
data "condition"
data 2,1,1,"front"
data "="
data 2,2,1,"front"
data ""
data "end conditions"
data 8
data "y",1,"l"
data "x",3,"r"
data "y",1,"r"
data "x",3,"l"
data "y",1,"r"
data "z",1,"l"
data "y",1,"l"
data "z",1,"r"
data "condition"
data 3,2,1,"front"
data "<>"
data 2,2,1,"front"
data ""
data "end conditions"
data 8
data "y",1,"l"
data "x",3,"r"
data "y",1,"r"
data "x",3,"l"
data "y",1,"r"
data "z",1,"l"
data "y",1,"l"
data "z",1,"r"
data "condition"
data 3,2,1,"right"
data "<>"
data 3,2,2,"right"
data ""
data "end conditions"
data 8
data "y",1,"r"
data "z",1,"l"
data "y",1,"l"
data "z",1,"r"
data "y",1,"l"
data "x",3,"r"
data "y",1,"r"
data "x",3,"l"
data "end"
warning- this is about 1800 lines and uses EZRotate and Sparkys,possibley Matrix1 aswell,never can remember if some of the commands are native to DBPro or not.
Exe atatched below.