Post by bluatigro on Nov 4, 2018 11:16:48 GMT
try at a game that learns
bad move's wil be removed
first step :
create al board's ans move's
error :
i do noit get the results i expect
also when in getMoves() dy = -dy
bad move's wil be removed
first step :
create al board's ans move's
error :
i do noit get the results i expect
also when in getMoves() dy = -dy
'' bluatigro 4 nov 2018
'' hexapawn :
'' a game whit 6 pawn's
'' on a 3 x 3 board
'' you can not move 2 ahead
'' you win when you got a pawn at the opesid side
'' or when the openent can not move
'' or has no pawn's left
dim p( 8 ) , board$( 200 ) , move$( 200 ) , wz$( 2 )
global black , white , empty
black = 1
white = 0
empty = 2
wz$( white ) = "W"
wz$( black ) = "Z"
wz$( empty ) = "."
board$( 0 ) = "ZZZ...WWW"
global tel : tel = 1
print board$( 0 )
print getMove$( board$( 0 ) , white )
print do1move$( board$( 0 ) , "63" )
end
function index( x , y )
index = x * 3 + y
end function
function save( x , y )
save = x >= 0 and x <= 2 and y >= 0 and y <= 2
end function
function getMove$( q$ , kl )
if kl = white then
dy = -1
else
dy = 1
end if
for x = 0 to 2
for y = 0 to 2
if save( x , y + dy ) then
if char$( q$ , x , y ) = wz$( kl ) _
and char$( q$ , x , y + dy ) = wz$( empty ) then
uit$ = uit$ + str$( index( x , y ) )
uit$ = uit$ + str$( index( x , y + dy ) ) + " "
end if
end if
if save( x + 1 , y + dy ) then
if char$( q$ , x , y ) = wz$( kl ) _
and char$( q$ , x + 1 , y + dy ) = wz$( 1 - kl ) then
uit$ = uit$ + str$( index( x , y ) )
uit$ = uit$ + str$( index( x + 1 , y + dy ) ) + " "
end if
end if
if save( x - 1 , y + dy ) then
if char$( q$ , x , y ) = wz$( kl ) _
and char$( q$ , x - 1, y + dy ) = wz$( 1 - kl ) then
uit$ = uit$ + str$( index( x , y ) )
uit$ = uit$ + str$( index( x - 1 , y + dy ) ) + " "
end if
end if
next y
next x
if uit$ = "" then uit$ = "lost"
getMove$ = uit$
end function
function do1move$( q$ , z$ )
a = val( left$( z$ , 1 ) ) '' from
b = val( right$( z$ , 1 ) ) '' to
f$ = mid$( q$ , a + 1 , 1 ) '' take piece
l$ = left$( q$ , b - 1 )
r$ = right$( q$ , 9 - b )
t$ = l$ + f$ + r$ '' move piece to new spot
l$ = left$( t$ , a - 1 )
r$ = right$( t$ , 9 - a )
do1move$ = l$ + "." + r$ '' make old spot empty
end function
function char$( q$ , x , y )
char$ = mid$( q$ , index( x , y ) + 1 , 1 )
end function