Just get the red block to the top left corner.
Tested on Linux 64 but should work on 32 bit and Windows.
It may amuse someone for 2 minutes.
Code: Select all
' simplicity.bas
screenres 400,400
width , 400 / 16
const as ulong mask = 4167140895
const as double pi = 3.1415926535897932
dim as integer i, j, move
type board
bb as ulong
colour as integer
end type
dim as board piece(3)
data 8320, 49
data 1572864, 55
data 4192, 40
data 17170432, 44
for i = 0 to 3
read piece(i).bb
read piece(i).colour
next
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub display(piece() as board, move as integer)
dim as integer i, j, k, r, c
windowtitle "Simplicity Move : " +str(move)
screenlock()
cls
print "Get The Red"
print " One here !"
for i = 0 to 3
k = -1
for j = 5 to 26
if bit(mask, j) = 0 then
k += 1
if bit(piece(i).bb, j) = -1 then
r = ( 3 - (k mod 4)) * 100
c = ( 3 - int(k / 4)) * 100
line (r, c) - (r + 100, c + 100), piece(i).colour, bf
end if
end if
next
next
screenunlock()
end sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function getmove( piece() as board) as integer
dim as integer x, y, buttons, res, i ,j, oldx, oldy, r, c, target, z, dum
dim as ulong all,temp
for i = 0 to 3
all or= piece(i).bb
next
do
res=getmouse(x,y,,buttons)
if inkey = chr(255,107) then end
if res = 0 then
oldx = x
oldy = y
end if
res=getmouse(x,y,,buttons)
if res = 0 then
if (buttons and 1) then
z=1
dum = point(x, y)
end if
end if
loop while z = 0
do
getmouse(x,y,,buttons)
loop while (buttons and 1)
r=x-oldx
c=y-oldy
select case dum
case 49
target = 0
case 55
target = 1
case 40
target = 2
case 44
target = 3
case else
return 0
end select
temp = 0
if r<> 0 or c<> 0 then
if abs(r) > abs(c) then
if r > 0 then temp = (piece(target).bb shr 1)
if r < 0 then temp = (piece(target).bb shl 1)
end if
if abs(r) < abs(c) then
if c > 0 then temp = (piece(target).bb shr 6) or (piece(target).bb shl(26))
if c < 0 then temp = (piece(target).bb shl 6) or (piece(target).bb shr(26))
end if
if (temp and mask) = 0 then
if ((all xor piece(target).bb) and temp) = 0 then
piece(target).bb = temp
return 1
end if
else
return 0
end if
end if
return 0
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function wincheck(piece() as board) as integer
dim as integer j
if piece(2).bb = 68681728 then
circle (150,50),25,14, , , , f
circle (140,45),5,0, , , , f
circle (160,45),5,0, , , , f
for j = 1 to 30 step 2
circle (150,55),15,0,pi , 2 * pi, 0.54 + (j * .005)
next
sleep 2000
circle (160,45),5,14, , , , f
circle (160,45),5,0, pi, 2 * pi, .75, f
sleep 500
circle (160,45),5,0, , , , f
return 1
end if
return 0
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' main
display(piece(), move)
do
while getmove(piece()) = 0
wend
move += 1
display(piece(), move)
sleep 50
loop while wincheck(piece()) = 0
sleep