Code: Select all
dim shared as integer p(14,14) , i , j
dim shared as ulong z(1000)
const as integer empty = 0
const as integer white = 1
const as integer dwhite = 16 or 1
const as integer black = 2
const as integer dblack = 16 or 2
const as integer wal = 7
sub drawbord
for i = 3 to 12
for j = 3 to 12
select case p(i,j)
case white
circle(i*10+5,j*10+5),rgb(255,255,0),3,,,,f
case dwhite
circle(i*10+5,j*10+5),rgb(255,255,0),5,,,,f
case black
circle(i*10+5,j*10+5),rgb(0,0,255),3,,,,f
case dblack
circle(i*10+5,j*10+5),rgb(0,0,255),5,,,,f
case empty
line(i*10,j*10)-step(9,9),rgb(0,255,0),bf
case else
end select
next j
next i
end sub
function random_move( q as integer ) as ulong
''looks for al posible moves
''returns random move
''if no move then 0
dim as integer ztel = 0 , e=1
for i = 3 to 12
for j = 3 to 12
if p(i,j)<>wal andalso ( p(i,j)and q ) then
if q = black then e=-1
if p(i+e,j+e) = empty then
z(ztel)=rgba(i,j,i+e,j+e)
ztel+=1
end if
if p(i-e,j+e) = empty then
z(ztel)=rgba(i,j,i-e,j+e)
ztel+=1
end if
end if
next j
next i
if ztel <> 0 then
return z( int( rnd * ztel ) )
end if
return 0
end function
sub newgame
restore
dim as string a
for i = 0 to 14
read a
for j = 1 to len( a )
p(j,i) = val( mid( a , j , 1 ) )
next j
next i
end sub
data "77777777777777"
data "77777777777777"
data "77272727272777"
data "77727272727277"
data "77272727272777"
data "77707070707077"
data "77070707070777"
data "77717171717177"
data "77171717171777"
data "77717171717177"
data "77777777777777"
data "77777777777777"
screen 20 , 32
randomize timer
newgame
drawbord
sleep