ok... I was intrigued.......

so here it is ... not too bad for 20 min work

create a window with two controls

CANVAS1 (400 x 400)

PUSHBUTTON1 - Label it "New Puzzle"

Global Properties

Dim PUZZLE(3,3) as INTEGER

dim RND_NUM as RANDOM

dim SQUARE_SIZE as integer

Global CONSTANT

puzzle_size=3 ' this should match the dimensions of PUZZLE()

Global Method - NAME = NEW_PUZZLE

dim i as integer

dim x as integer

dim y as integer

dim cnt as integer

cnt=((puzzle_size+1)*(puzzle_size+1))-1

for x=0 to puzzle_size

for y=0 to puzzle_size

puzzle(x,y)=0 ' empty square

next y

next x

x=rnd_num.InRange(0,puzzle_size)

y=rnd_num.InRange(0,puzzle_size)

for i=0 to cnt

while puzzle(x,y)>0

x=rnd_num.InRange(0,puzzle_size)

y=rnd_num.InRange(0,puzzle_size)

wend

puzzle(x,y)=i

next i

square_size=(canvas1.width\(puzzle_size+1))

Canvas1.refresh

WINDOW1.OPEN EVENT

rnd_num=new random

New_Puzzle

PUSHBUTTON1.ACTION EVENT

CANVA1.PAINT EVENT

dim x as integer

dim y as integer

dim ypos as integer

dim xpos as integer

dim s as string

g.ForeColor=&c00ff00

g.fillrect 0,0,g.width,g.height

g.textsize=72

for x=0 to puzzle_size

xpos=(x*square_size)

for y=0 to puzzle_size

ypos=(y*square_size)

if puzzle(x,y)>0 then ' draw the piece

g.ForeColor=&cffffff

g.fillrect xpos,ypos,square_size,square_size

g.ForeColor=&c0000ff

g.drawrect xpos,ypos,square_size,square_size

s=str(puzzle(x,y))

g.drawstring s,xpos+((square_size-g.StringWidth(s))\2),ypos+((square_size-g.textheight)\2)+g.TextAscent

end if

next y

next x

g.ForeColor=&c000000

g.drawrect 0,0,g.width,g.height

CANVAS1.MOUSEDOWN EVENT

dim good_move as boolean

x=x\square_size

y=y\Square_Size

good_move=false

if puzzle(x,y)>0 then ' can't move the empty square

' check if move up

if y>0 and not good_move then

if puzzle(x,y-1)=0 then

puzzle(x,y-1)=puzzle(x,y)

puzzle(x,y)=0

good_move=true

end if

end if

' check if move down

if y<puzzle_size and not good_move then

if puzzle(x,y+1)=0 then

puzzle(x,y+1)=puzzle(x,y)

puzzle(x,y)=0

good_move=true

end if

end if

' check if move left

if x>0 and not good_move then

if puzzle(x-1,y)=0 then

puzzle(x-1,y)=puzzle(x,y)

puzzle(x,y)=0

good_move=true

end if

end if

' check if move right

if x<puzzle_size and not good_move then

if puzzle(x+1,y)=0 then

puzzle(x+1,y)=puzzle(x,y)

puzzle(x,y)=0

good_move=true

end if

end if

end if

if not good_move then

beep

return true

end if

canvas1.refresh