Post by bluatigro on Jul 30, 2018 13:06:58 GMT
error :
the code does not play the game
it stops right after start
the code does not play the game
it stops right after start
dim p( 14 , 14 ) , z$( 1000 )
global empty,white,black,dan,wal,player
white = 1
black = 2
dan = 4
wal = 8
WindowWidth = DisplayWidth - 300
WindowHeight = DisplayHeight - 100
nomainwin
open "dammen 0.1" for graphics as #m
#m "trapclose [quit]"
#m "size 7"
player = 1
call newgame
timer 1000 , [timer]
wait
[timer]
scan
call drawbord
q$ = ai$( player )
if q$ = "no moves" then
timer 0
notice "GAME OVER !!"
end if
i = val( word$( q$ , 1 ) )
j = val( word$( q$ , 2 ) )
i2 = val( word$( q$ , 3 ) )
j2 = val( word$( q$ , 4 ) )
p( i2 , j2 ) = p( i , j )
if instr( q$ , "hit" ) then
p( ( i + i2 ) / 2 , ( j + j2 ) / 2 ) = empty
end if
p( i , j ) = empty
player = 3 - player
wait
[quit]
close #m
end
function ai$( kl )
''move or hit whit color kl by computer
for i = 0 to 1000
z$( i ) = ""
next i
if kl = black then q = 1
if kl = white then q = -1
ztel = 0
''look on board for hit's
for i = 2 to 11
for j = 2 to 11
''look if p.kl = good color
if p( i , j ) = ( kl and 3 ) then
''look if p can hit
if p( i + q , j + q ) and 3 then
if p( i , j ) <> p( i + q , j + q ) then
if p( i + q * 2 , j + q * 2 ) = empty then
z$( ztel ) = str$( i ) ; " " ; j _
; " " ; i + q * 2 ; " " ; j + q * 2 ; " hit"
ztel = ztel + 1
end if
end if
end if
if p( i - q , j + q ) and 3 then
if p( i , j ) <> p( i - q , j + q ) then
if p( i - q * 2 , j + q * 2 ) = empty then
z$( ztel ) = str$( i ) ; " " ; j _
; " " ; i - q * 2 ; " " ; j + q * 2 ; " hit"
ztel = ztel + 1
end if
end if
end if
end if
next j
next i
if ztel = 0 then
''if no hit's are fount
''look on board for any move
for i = 2 to 11
for j = 0 to 11
''look if p.kl = good color
if p( x , y ) and ( kl and 3 ) then
''look if p can move
if p( i + q , j + q ) = empty then
z$( ztel ) = str$( i ) ; " " ; j _
; " " ; i + q ; " " ; j + q
ztel = ztel + 1
end if
if p( i - q , j + q ) = empty then
z$( ztel ) = str$( i ) ; " " ; j _
; " " ; i - q ; " " ; j + q
ztel = ztel + 1
end if
end if
next j
next i
end if
if ztel = 0 then
uit$ = "no moves"
else
uit$ = z$( int( rnd( 0 ) * ztel ) )
end if
ai$ = uit$
end function
function human$( kl )
end function
sub newgame
restore
for j = 0 to 13
read q$
for i = 1 to len( q$ )
p( i - 1 , j ) = val( mid$( q$ , i , 1 ) )
next i
next j
data "88888888888888"
data "88888888888888"
data "88828282828288"
data "88282828282888"
data "88828282828288"
data "88282828282888"
data "88808080808088"
data "88080808080888"
data "88818181818188"
data "88181818181888"
data "88818181818188"
data "88181818181888"
data "88888888888888"
data "88888888888888"
end sub
sub rond x , y , r , kl1$ , kl2$
#m "goto " ; x ; " " ; y
#m "color " ; kl2$
#m "backcolor " ; kl1$
#m "down"
#m "circlefilled " ; r
#m "up"
end sub
sub drawbord
#m "fill black"
for i = 2 to 11
for j = 2 to 11
if ( i + j ) and 1 then
#m "color lightgray"
#m "backcolor lightgray"
else
#m "color darkgray"
#m "backcolor darkgray"
end if
#m "goto " ; i * 60 ; " " ; ( j - 2 ) * 60
#m "down"
#m "boxfilled " ; i * 60 + 60 ; " " ; ( j - 2 ) * 60 + 60
#m "up"
select case p( i , j )
case white
call rond i * 60 + 30 , ( j - 2 ) * 60 + 30 _
, 10 , "white" , "black"
case white or dan
call rond i * 60 + 30 , ( j - 2 ) * 60 + 30 _
, 17 , "white" , "black"
case black
call rond i * 60 + 30 , ( j - 2 ) * 60 + 30 _
, 10 , "black" , "white"
case black or dan
call rond i * 60 + 30 , ( j - 2 ) * 60 + 30 _
, 17 , "black" , "white"
case else
end select
next j
next i
end sub