Liberty BASIC Community Forum
« NOT 3 »

Welcome Guest. Please Login or Register.
Mar 29th, 2017, 04:16am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: NOT 3  (Read 191 times)
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 857
xx NOT 3
« Thread started on: May 26th, 2016, 06:02am »


error :
it dont print anything

Code:
dim bord( 9 ) , borden( 9 ) , zetten( 9 ) , mem$( 512 )

for i = 0 to 511
    zz$ = ""
    for m = 0 to 8
        if i and 2 ^ m then
            for q = 0 to 3
                zz$ = zz$ + str$( m + 1 )
            next q
        end if
    next m
    mem$( i ) = zz$
next i

''test
print mem$( 0 )
call remove 0 , 5
print mem$( 0 )
call killal 0 , 5
print mem$( 0 )

end
in$ = "y"
while in$ = "y"
    spel = choise()
    if spel = 3 then
        input "How many times autoplay ? " ; in$
        for i = 0 to val( in$ )
            print a - i
            call evaluate game( spel )
        next i
    else
        call evaluate game( spel )
    end if
    input "Again ? ( y / n ) : " ; in$
wend


sub newbord
  for i = 0 to 9
    bord( i ) = i
  next i
  bord( 1 ) = 1
end sub

function rij( a , b , c )
    rij = not( bord( a ) ) _
      and not( bord( b ) ) _
      and not( bord( c ) )
end function

function ry()
    ry = rij( 1 , 2 , 3 ) _
      or rij( 4 , 5 , 6 ) _
      or rij( 7 , 8 , 9 ) _
      or rij( 1 , 4 , 7 ) _
      or rij( 2 , 5 , 8 ) _
      or rij( 3 , 6 , 9 )
end function

function p$( i )
    uit$ = "X"
    if i then uit$ = str$( bord( i ) )
    p$ = uit$
end function

sub showbord
    print "+-+-+-+"
    print "|" + p$( 1 ) _
           + "|" + p$( 2 ) _
           + "|" + p$( 3 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 4 ) _
           + "|" + p$( 5 ) _
           + "|" + p$( 6 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 7 ) _
           + "|" + p$( 8 ) _
           + "|" + p$( 9 ) + "|"
    print "+-+-+-+"
end sub

function humanmove()
    i = 0
    while ( i < 1 ) or ( i > 9 ) or bord( i )
        input "Your move : " ; in$
        i = val( in$ )
    wend
    humanmove = i
end function

function randomove()
    i = 0
    while bord( i )
        i = int( rnd(0) * 9 + 1 )
    wend
    randomove = i
end function

function aimove( no )
    i = int( rnd(0) * ( len( mem$( no ) ) - 1 ) )
    aimove = val( mid$( mem$( no ) , i + 1 , 1  ) )
end function

function choise()
    spel = 0
    while spel < 1 and spel > 5
        print "Welkome by not3 :"
        print "a game by bluatigro ."
        print "Target of the game :"
        print "Move your X so that"
        print "the computer moves the 3e X in a row ."
        print "1 : you - rando ."
        print "2 : rando - you ."
        print "3 : rando - rando ."
        print "4 : you - ai ."
        print "5 : ai - you ."
        input "Choise ? [ 1 , 2 , 3 , 4 , 5 ] : " ; in$
        spel = val( in$ )
    wend
    choise = spel
end function

function game( spel )
    player = 0
    tel = 0
    u = 0
    call newbord
    while not( ry() )
        if spel <> 3 then
            call showbord
        end if
        select case spel
        case 1
            if player then
                z = randomove()
            else
                z = humanmove()
            end if
        case 2
            if player then
                 z = humanmove()
            else
                 z = randomove()
            end if
        case 4
            if player then
                z = aimove( u )
            else
                z = humanmove()
            end if
        case 5
            if player then
                z = humanmove()
            else
                z = aimove( u )
            end if
        case else
            z = randomove()
        end select
        tel = tel + 1
        bord( z ) = 0
        zetten( tel ) = z
        u = u or ( 2 ^ ( z - 1 ) )
        borden( tel ) = u
        player = 1 - player
    wend
    game = tel
end function

sub remove no , z
    if instr( mem$( no ) , str$( z ) ) then
        q = instr( mem$( no ) , str$( z ) )
        l$ = left$( mem$( no ) , q  - 1 )
        r$ = mid$( mem$( no ) , q + 1 )
        mem$( no ) = l$ + r$
    end if
end sub

sub add no , z
    if len( mem$( no ) ) < 100 then
        mem$( no ) = mem$( no ) + str$( z )
    end if
end sub

sub killal no , z
    while instr( mem$( no ) , str$( z ) )
        call remove no , z
    wend
end sub

sub evaluate q
    select case q
        case 3
            call add borden( 2 ) , zetten( 2 )
            call killal borden( 3 ) , zetten( 3 )
        case 4
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call killal borden( 4 ) , zetten( 4 )
       case 5
            call add borden( 2 ) , zetten( 2 )
            call remove borden( 3 ) , zetten( 3 )
            call add borden( 4 ) , zetten( 4 )
            call remove borden( 5 ) , zetten( 5 )  '' or killal ?
       case 6
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call remove borden( 4 ) , zetten( 4 )
            call add borden( 5 ) , zetten( 5 )
            call remove borden( 6 ) , zetten( 6 )  '' or killal ?
        case else
    end select
end sub

 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 857
xx Re: NOT 3
« Reply #1 on: May 26th, 2016, 06:09am »

Code:
dim bord( 9 ) , borden( 9 ) , zetten( 9 ) , mem$( 512 )

for i = 0 to 511
    zz$ = ""
    for m = 0 to 8
        if i and 2 ^ m then
            for q = 0 to 3
                zz$ = zz$ + str$( m + 1 )
            next q
        end if
    next m
    mem$( i ) = zz$
next i

''test
print mem$( 0 )
call remove 0 , 5
print mem$( 0 )
call killal 0 , 5
print mem$( 0 )

end
in$ = "y"
while in$ = "y"
    spel = choise()
    if spel = 3 then
        input "How many times autoplay ? " ; in$
        a = val( in$ )
        for i = 0 to a
            print a - i
            call evaluate game( spel )
        next i
    else
        call evaluate game( spel )
    end if
    input "Again ? ( y / n ) : " ; in$
wend


sub newbord
  for i = 0 to 9
    bord( i ) = i
  next i
  bord( 1 ) = 1
end sub

function rij( a , b , c )
    rij = not( bord( a ) ) _
      and not( bord( b ) ) _
      and not( bord( c ) )
end function

function ry()
    ry = rij( 1 , 2 , 3 ) _
      or rij( 4 , 5 , 6 ) _
      or rij( 7 , 8 , 9 ) _
      or rij( 1 , 4 , 7 ) _
      or rij( 2 , 5 , 8 ) _
      or rij( 3 , 6 , 9 )
end function

function p$( i )
    uit$ = "X"
    if i then uit$ = str$( bord( i ) )
    p$ = uit$
end function

sub showbord
    print "+-+-+-+"
    print "|" + p$( 1 ) _
           + "|" + p$( 2 ) _
           + "|" + p$( 3 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 4 ) _
           + "|" + p$( 5 ) _
           + "|" + p$( 6 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 7 ) _
           + "|" + p$( 8 ) _
           + "|" + p$( 9 ) + "|"
    print "+-+-+-+"
end sub

function humanmove()
    i = 0
    while ( i < 1 ) or ( i > 9 ) or bord( i )
        input "Your move : " ; in$
        i = val( in$ )
    wend
    humanmove = i
end function

function randomove()
    i = 0
    while bord( i )
        i = int( rnd(0) * 9 + 1 )
    wend
    randomove = i
end function

function aimove( no )
    i = int( rnd(0) * ( len( mem$( no ) ) - 1 ) )
    aimove = val( mid$( mem$( no ) , i + 1 , 1  ) )
end function

function choise()
    spel = 0
    while spel < 1 and spel > 5
        print "Welkome by not3 :"
        print "a game by bluatigro ."
        print "Target of the game :"
        print "Move your X so that"
        print "the computer moves the 3e X in a row ."
        print "1 : you - rando ."
        print "2 : rando - you ."
        print "3 : rando - rando ."
        print "4 : you - ai ."
        print "5 : ai - you ."
        input "Choise ? [ 1 , 2 , 3 , 4 , 5 ] : " ; in$
        spel = val( in$ )
    wend
    choise = spel
end function

function game( spel )
    player = 0
    tel = 0
    u = 0
    call newbord
    while not( ry() )
        if spel <> 3 then
            call showbord
        end if
        select case spel
        case 1
            if player then
                z = randomove()
            else
                z = humanmove()
            end if
        case 2
            if player then
                 z = humanmove()
            else
                 z = randomove()
            end if
        case 4
            if player then
                z = aimove( u )
            else
                z = humanmove()
            end if
        case 5
            if player then
                z = humanmove()
            else
                z = aimove( u )
            end if
        case else
            z = randomove()
        end select
        tel = tel + 1
        bord( z ) = 0
        zetten( tel ) = z
        u = u or ( 2 ^ ( z - 1 ) )
        borden( tel ) = u
        player = 1 - player
    wend
    game = tel
end function

sub remove no , z
    if instr( mem$( no ) , str$( z ) ) then
        q = instr( mem$( no ) , str$( z ) )
        l$ = left$( mem$( no ) , q  - 1 )
        r$ = mid$( mem$( no ) , q + 1 )
        mem$( no ) = l$ + r$
    end if
end sub

sub add no , z
    if len( mem$( no ) ) < 100 then
        mem$( no ) = mem$( no ) + str$( z )
    end if
end sub

sub killal no , z
    while instr( mem$( no ) , str$( z ) )
        call remove no , z
    wend
end sub

sub evaluate q
    select case q
        case 3
            call add borden( 2 ) , zetten( 2 )
            call killal borden( 3 ) , zetten( 3 )
        case 4
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call killal borden( 4 ) , zetten( 4 )
       case 5
            call add borden( 2 ) , zetten( 2 )
            call remove borden( 3 ) , zetten( 3 )
            call add borden( 4 ) , zetten( 4 )
            call remove borden( 5 ) , zetten( 5 )  '' or killal ?
       case 6
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call remove borden( 4 ) , zetten( 4 )
            call add borden( 5 ) , zetten( 5 )
            call remove borden( 6 ) , zetten( 6 )  '' or killal ?
        case else
    end select
end sub

 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 857
xx Re: NOT 3
« Reply #2 on: May 26th, 2016, 06:36am »


update :
now whit memory on dics

i m not sure about :
loadmem
savemem
ismemondisc()

i need help whit this

the target is a game that lerns
and that every time you start it is getting smarter

Code:
dim bord( 9 ) , borden( 9 ) , zetten( 9 ) , mem$( 512 ) , info$( 10 , 10 )

for i = 0 to 511
    zz$ = ""
    for m = 0 to 8
        if i and 2 ^ m then
            for q = 0 to 3
                zz$ = zz$ + str$( m + 1 )
            next q
        end if
    next m
    mem$( i ) = zz$
next i

''call loadmem

''test
print mem$( 0 )
call remove 0 , 5
print mem$( 0 )
call killal 0 , 5
print mem$( 0 )

end
in$ = "y"
while in$ = "y"
    spel = choise()
    if spel = 3 then
        input "How many times autoplay ? " ; in$
        a = val( in$ )
        for i = 0 to a
            print a - i
            call evaluate game( spel )
        next i
    else
        call evaluate game( spel )
    end if
    input "Again ? ( y / n ) : " ; in$
wend

''call savemem

end

sub loadmem
    if ismemondisc() then
        open "not3mem.txt" for input as #i
            for i = 0 to 511
                inputline #i , mem$( i )
            next i
        close #i
    else
        for i = 0 to 511
            zz$ = ""
            for m = 0 to 8
                if i and 2 ^ m then
                    for q = 0 to 3
                        zz$ = zz$ + str$( m + 1 )
                    next q
                end if
            next m
            mem$( i ) = zz$
        next i
    end if
end sub

sub savemem
    open "not3mem.txt" for output as #o
        for i = 0 to 511
            #o mem$( i )
        next i
    close #o
end sub

function ismemondisc()
    files "not3mem.txt" , info$()
    ismemondisc = val( info$( 0 , 0 ) )
end function

sub newbord
    for i = 0 to 9
        bord( i ) = i
    next i
    bord( 0 ) = 1
end sub

function rij( a , b , c )
    rij = not( bord( a ) ) _
      and not( bord( b ) ) _
      and not( bord( c ) )
end function

function ry()
    ry = rij( 1 , 2 , 3 ) _
      or rij( 4 , 5 , 6 ) _
      or rij( 7 , 8 , 9 ) _
      or rij( 1 , 4 , 7 ) _
      or rij( 2 , 5 , 8 ) _
      or rij( 3 , 6 , 9 )
end function

function p$( i )
    uit$ = "X"
    if i then uit$ = str$( bord( i ) )
    p$ = uit$
end function

sub showbord
    print "+-+-+-+"
    print "|" + p$( 1 ) _
           + "|" + p$( 2 ) _
           + "|" + p$( 3 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 4 ) _
           + "|" + p$( 5 ) _
           + "|" + p$( 6 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 7 ) _
           + "|" + p$( 8 ) _
           + "|" + p$( 9 ) + "|"
    print "+-+-+-+"
end sub

function humanmove()
    i = 0
    while ( i < 1 ) or ( i > 9 ) or bord( i )
        input "Your move : " ; in$
        i = val( in$ )
    wend
    humanmove = i
end function

function randomove()
    i = 0
    while bord( i )
        i = int( rnd(0) * 9 + 1 )
    wend
    randomove = i
end function

function aimove( no )
    i = int( rnd(0) * ( len( mem$( no ) ) - 1 ) )
    aimove = val( mid$( mem$( no ) , i + 1 , 1  ) )
end function

function choise()
    spel = 0
    while spel < 1 and spel > 5
        print "Welkome by not3 :"
        print "a game by bluatigro ."
        print "Target of the game :"
        print "Move your X so that"
        print "the computer moves the 3e X in a row ."
        print "1 : you - rando ."
        print "2 : rando - you ."
        print "3 : rando - rando ."
        print "4 : you - ai ."
        print "5 : ai - you ."
        input "Choise ? [ 1 , 2 , 3 , 4 , 5 ] : " ; in$
        spel = val( in$ )
    wend
    choise = spel
end function

function game( spel )
    player = 0
    tel = 0
    u = 0
    call newbord
    while not( ry() )
        if spel <> 3 then
            call showbord
        end if
        select case spel
        case 1
            if player then
                z = randomove()
            else
                z = humanmove()
            end if
        case 2
            if player then
                 z = humanmove()
            else
                 z = randomove()
            end if
        case 4
            if player then
                z = aimove( u )
            else
                z = humanmove()
            end if
        case 5
            if player then
                z = humanmove()
            else
                z = aimove( u )
            end if
        case else
            z = randomove()
        end select
        tel = tel + 1
        bord( z ) = 0
        zetten( tel ) = z
        u = u or ( 2 ^ ( z - 1 ) )
        borden( tel ) = u
        player = 1 - player
    wend
    game = tel
end function

sub remove no , z
    if instr( mem$( no ) , str$( z ) ) then
        q = instr( mem$( no ) , str$( z ) )
        l$ = left$( mem$( no ) , q  - 1 )
        r$ = mid$( mem$( no ) , q + 1 )
        mem$( no ) = l$ + r$
    end if
end sub

sub add no , z
    if len( mem$( no ) ) < 100 then
        mem$( no ) = mem$( no ) + str$( z )
    end if
end sub

sub killal no , z
    while instr( mem$( no ) , str$( z ) )
        call remove no , z
    wend
end sub

sub evaluate q
    select case q
        case 3
            call add borden( 2 ) , zetten( 2 )
            call killal borden( 3 ) , zetten( 3 )
        case 4
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call killal borden( 4 ) , zetten( 4 )
        case 5
            call add borden( 2 ) , zetten( 2 )
            call remove borden( 3 ) , zetten( 3 )
            call add borden( 4 ) , zetten( 4 )
            call remove borden( 5 ) , zetten( 5 )  '' or killal ?
        case 6
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call remove borden( 4 ) , zetten( 4 )
            call add borden( 5 ) , zetten( 5 )
            call remove borden( 6 ) , zetten( 6 )  '' or killal ?
        case else
    end select
end sub

 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 857
xx Re: NOT 3
« Reply #3 on: May 27th, 2016, 06:19am »


now it shoot work

file stuf removed

test this please

Code:

dim bord( 9 ) , borden( 9 ) , zetten( 9 ) , mem$( 512 ) , info$( 10 , 10 )

for i = 0 to 511
    zz$ = ""
    for m = 0 to 8
        if ( i and  2 ^ m ) = 0 then
            for q = 0 to 3
                zz$ = zz$ + str$( m + 1 )
            next q
        end if
    next m
    mem$( i ) = zz$
next i

in$ = "y"
while in$ = "y"
    spel = choise()
    if spel = 3 then
        input "How many times autoplay ? " ; in$
        a = val( in$ )
        for i = 0 to a
            print a - i
            call evaluate game( spel )
        next i
    else
        call evaluate game( spel )
    end if
    input "Again ? ( y / n ) : " ; in$
wend

end
sub newbord
    for i = 0 to 9
        bord( i ) = i
    next i
    bord( 0 ) = 1
end sub

function rij( a , b , c )
    rij = not( bord( a ) ) _
      and not( bord( b ) ) _
      and not( bord( c ) )
end function

function ry()
    ry = rij( 1 , 2 , 3 ) _
      or rij( 4 , 5 , 6 ) _
      or rij( 7 , 8 , 9 ) _
      or rij( 1 , 4 , 7 ) _
      or rij( 2 , 5 , 8 ) _
      or rij( 3 , 6 , 9 )
end function

function p$( i )
    uit$ = "X"
    if i then uit$ = str$( bord( i ) )
    p$ = uit$
end function

sub showbord
    print "+-+-+-+"
    print "|" + p$( 1 ) _
           + "|" + p$( 2 ) _
           + "|" + p$( 3 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 4 ) _
           + "|" + p$( 5 ) _
           + "|" + p$( 6 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 7 ) _
           + "|" + p$( 8 ) _
           + "|" + p$( 9 ) + "|"
    print "+-+-+-+"
end sub

function humanmove()
    i = 0
    while ( i < 1 ) or ( i > 9 ) or bord( i )
        input "Your move : " ; in$
        i = val( in$ )
    wend
    humanmove = i
end function

function randomove()
    i = 0
    while bord( i )
        i = int( rnd(0) * 9 + 1 )
    wend
    randomove = i
end function

function aimove( no )
    i = int( rnd(0) * ( len( mem$( no ) ) - 1 ) )
    aimove = val( mid$( mem$( no ) , i + 1 , 1  ) )
end function

function choise()
    spel = 0
    while spel < 1 or spel > 5
        print "Welkome by not3 :"
        print "a game by bluatigro ."
        print "Target of the game :"
        print "Move your X so that"
        print "the computer moves the 3e X in a row ."
        print "1 : you - rando ."
        print "2 : rando - you ."
        print "3 : rando - rando . [ autoplay ] "
        print "4 : you - ai ."
        print "5 : ai - you ."
        input "Choise ? [ 1 , 2 , 3 , 4 , 5 ] : " ; in$
        spel = val( in$ )
    wend
    choise = spel
end function

function game( spel )
    player = 0
    tel = 0
    u = 0
    call newbord
    while not( ry() )
        if spel <> 3 then
            call showbord
        end if
        select case spel
        case 1
            if player then
                z = randomove()
            else
                z = humanmove()
            end if
        case 2
            if player then
                 z = humanmove()
            else
                 z = randomove()
            end if
        case 4
            if player then
                z = aimove( u )
            else
                z = humanmove()
            end if
        case 5
            if player then
                z = humanmove()
            else
                z = aimove( u )
            end if
        case else
            z = randomove()
        end select
        tel = tel + 1
        bord( z ) = 0
        zetten( tel ) = z
        u = u or ( 2 ^ ( z - 1 ) )
        borden( tel ) = u
        player = 1 - player
    wend
    game = tel
end function

sub remove no , z
    if instr( mem$( no ) , str$( z ) ) then
        q = instr( mem$( no ) , str$( z ) )
        l$ = left$( mem$( no ) , q  - 1 )
        r$ = mid$( mem$( no ) , q + 1 )
        mem$( no ) = l$ + r$
    end if
end sub

sub add no , z
    if len( mem$( no ) ) < 100 then
        mem$( no ) = mem$( no ) + str$( z )
    end if
end sub

sub killal no , z
    while instr( mem$( no ) , str$( z ) )
        call remove no , z
    wend
end sub

sub evaluate q
    select case q
        case 3
            call add borden( 2 ) , zetten( 2 )
            call killal borden( 3 ) , zetten( 3 )
        case 4
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call killal borden( 4 ) , zetten( 4 )
        case 5
            call add borden( 2 ) , zetten( 2 )
            call remove borden( 3 ) , zetten( 3 )
            call add borden( 4 ) , zetten( 4 )
            call remove borden( 5 ) , zetten( 5 )  '' or killal ?
        case 6
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call remove borden( 4 ) , zetten( 4 )
            call add borden( 5 ) , zetten( 5 )
            call remove borden( 6 ) , zetten( 6 )  '' or killal ?
        case else
    end select
end sub

 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 857
xx Re: NOT 3
« Reply #4 on: May 30th, 2016, 05:07am »



i only get a bord
i shoot get gameinfo + gamechoise
Code:
dim bord( 9 ) , borden( 9 ) , zetten( 9 ) , mem$( 512 ) , info$( 10 , 10 )

for i = 0 to 511
    zz$ = ""
    for m = 0 to 8
        if i and ( 2 ^ m ) then
            for q = 0 to 3
                zz$ = zz$ + str$( m + 1 )
            next q
        end if
    next m
    mem$( i ) = zz$
next i

''call loadmem

in$ = "y"
while in$ = "y"
    spel = choise()
    if spel = 3 then
        input "How many times autoplay ? " ; in$
        a = val( in$ )
        for i = 0 to a
            print a - i
            call evaluate game( spel )
        next i
    else
        call evaluate game( spel )
    end if
    input "Again ? ( y / n ) : " ; in$
wend

''call savemem

end

sub loadmem
''    if ismemondisc() then
''        open "not3mem.txt" for input as #i
''            for i = 0 to 511
''                input #i , mem$( i )
''            next i
''        close #i
''    else
        for i = 0 to 511
            zz$ = ""
            for m = 0 to 8
                if i and 2 ^ m then
                    for q = 0 to 3
                        zz$ = zz$ + str$( m + 1 )
                    next q
                end if
            next m
            mem$( i ) = zz$
        next i
''    end if
end sub

sub savemem
''    open "not3mem.txt" for output as #o
''        for i = 0 to 511
''            #o mem$( i )
''        next i
''    close #o
end sub

function ismemondisc()
    files "not3mem.txt" , info$()
    ismemondisc = val( info$( 0 , 0 ) )
end function

sub newbord
    for i = 0 to 9
        bord( i ) = i
    next i
    bord( 0 ) = 1
end sub

function rij( a , b , c )
    rij = not( bord( a ) ) _
      and not( bord( b ) ) _
      and not( bord( c ) )
end function

function ry()
    ry = rij( 1 , 2 , 3 ) _
      or rij( 4 , 5 , 6 ) _
      or rij( 7 , 8 , 9 ) _
      or rij( 1 , 4 , 7 ) _
      or rij( 2 , 5 , 8 ) _
      or rij( 3 , 6 , 9 )
end function

function p$( i )
    uit$ = "X"
    if i then uit$ = str$( bord( i ) )
    p$ = uit$
end function

sub showbord
    print "+-+-+-+"
    print "|" + p$( 1 ) _
           + "|" + p$( 2 ) _
           + "|" + p$( 3 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 4 ) _
           + "|" + p$( 5 ) _
           + "|" + p$( 6 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 7 ) _
           + "|" + p$( 8 ) _
           + "|" + p$( 9 ) + "|"
    print "+-+-+-+"
end sub

function humanmove()
    i = 0
    while ( i < 1 ) or ( i > 9 ) or not( bord( i ) )
        input "Your move : " ; in$
        i = val( in$ )
    wend
    humanmove = i
end function

function randomove()
    i = 0
    while not( bord( i ) )
        i = int( rnd(0) * 9 + 1 )
    wend
    randomove = i
end function

function aimove( no )
    i = int( rnd(0) * ( len( mem$( no ) ) - 1 ) )
    aimove = val( mid$( mem$( no ) , i + 1 , 1  ) )
end function

function choise()
    spel = 0
    while spel < 1 and spel > 5
        print "Welkome by not3 :"
        print "a game by bluatigro ."
        print "Target of the game :"
        print "Move your X so that"
        print "the computer moves the 3e X in a row ."
        print "1 : you - rando ."
        print "2 : rando - you ."
        print "3 : rando - rando ."
        print "4 : you - ai ."
        print "5 : ai - you ."
        input "Choise ? [ 1 , 2 , 3 , 4 , 5 ] : " ; in$
        spel = val( in$ )
    wend
    choise = spel
end function

function game( spel )
    player = 0
    tel = 0
    u = 0
    call newbord
    while not( ry() )
        if spel <> 3 then
            call showbord
        end if
        select case spel
        case 1
            if player then
                z = randomove()
            else
                z = humanmove()
            end if
        case 2
            if player then
                 z = humanmove()
            else
                 z = randomove()
            end if
        case 4
            if player then
                z = aimove( u )
            else
                z = humanmove()
            end if
        case 5
            if player then
                z = humanmove()
            else
                z = aimove( u )
            end if
        case else
            z = randomove()
        end select
        tel = tel + 1
        bord( z ) = 0
        zetten( tel ) = z
        u = u or ( 2 ^ ( z - 1 ) )
        borden( tel ) = u
        player = 1 - player
    wend
    game = tel
end function

sub remove no , z
    if instr( mem$( no ) , str$( z ) ) then
        q = instr( mem$( no ) , str$( z ) )
        l$ = left$( mem$( no ) , q  - 1 )
        r$ = mid$( mem$( no ) , q + 1 )
        mem$( no ) = l$ + r$
    end if
end sub

sub add no , z
    if len( mem$( no ) ) < 100 then
        mem$( no ) = mem$( no ) + str$( z )
    end if
end sub

sub killal no , z
    while instr( mem$( no ) , str$( z ) )
        call remove no , z
    wend
end sub

sub evaluate q
    select case q
        case 3
            call add borden( 2 ) , zetten( 2 )
            call killal borden( 3 ) , zetten( 3 )
        case 4
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call killal borden( 4 ) , zetten( 4 )
        case 5
            call add borden( 2 ) , zetten( 2 )
            call remove borden( 3 ) , zetten( 3 )
            call add borden( 4 ) , zetten( 4 )
            call remove borden( 5 ) , zetten( 5 )  '' or killal ?
        case 6
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call remove borden( 4 ) , zetten( 4 )
            call add borden( 5 ) , zetten( 5 )
            call remove borden( 6 ) , zetten( 6 )  '' or killal ?
        case else
    end select
end sub

 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
cundo
Guru
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 602
xx Re: NOT 3
« Reply #5 on: May 30th, 2016, 12:49pm »

There is something with this line of Code:
        u = u or ( 2 ^ ( z - 1 ) ) 
, inside the function game( spel ).
I actually don't know what it does.
User IP Logged

cundo
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 857
xx Re: NOT 3
« Reply #6 on: Jun 1st, 2016, 04:19am »

@ cundo :


explanation :
it is zetting bit z - 1 of u

example :
if u = 10000000 [ binaer ] 80 [ hex ]
and z = 5
then u wil change into 10001000 [ binaer ] 88 [ hex ]
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 857
xx Re: NOT 3
« Reply #7 on: Jun 1st, 2016, 04:29am »



if you want to reset a bit to 0 :

[ in a 9 bit byte ]

Code:
number = number and ( 511 - ( 2  ^ bitnr ) )
 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 857
xx Re: NOT 3
« Reply #8 on: Jun 1st, 2016, 06:50am »

update :
moving a X is now fixed

error :
isempty

help needed whit :
sub randomove
sub loadmem
sub savemem
function fileexists()

Code:

dim bord( 9 ) , borden( 9 ) , zetten( 9 ) , mem$( 512 ) , info$( 10 , 10 )

for i = 0 to 511
    zz$ = ""
    for m = 0 to 8
        if ( i and  2 ^ m ) = 0 then
            for q = 0 to 3
                zz$ = zz$ + str$( m + 1 )
            next q
        end if
    next m
    mem$( i ) = zz$
next i

in$ = "y"
while in$ = "y"
    spel = choise()
    if spel = 3 then
        input "How many times autoplay ? " ; in$
        a = val( in$ )
        for i = 0 to a
            print a - i
            call evaluate game( spel )
        next i
    else
        call evaluate game( spel )
    end if
    input "Again ? ( y / n ) : " ; in$
wend

end

sub newbord
    for i = 0 to 9
        bord( i ) = i
    next i
    bord( 0 ) = 1
end sub

function rij( a , b , c )
    rij = not( bord( a ) ) _
      and not( bord( b ) ) _
      and not( bord( c ) )
end function

function ry()
    ry = rij( 1 , 2 , 3 ) _
      or rij( 4 , 5 , 6 ) _
      or rij( 7 , 8 , 9 ) _
      or rij( 1 , 4 , 7 ) _
      or rij( 2 , 5 , 8 ) _
      or rij( 3 , 6 , 9 )
end function

function p$( i )
    if bord( i ) then
        uit$ = str$( bord( i ) )
    else
        uit$ = "X"
    end if
    p$ = uit$
end function

sub showbord
    print "+-+-+-+"
    print "|" + p$( 1 ) _
           + "|" + p$( 2 ) _
           + "|" + p$( 3 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 4 ) _
           + "|" + p$( 5 ) _
           + "|" + p$( 6 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 7 ) _
           + "|" + p$( 8 ) _
           + "|" + p$( 9 ) + "|"
    print "+-+-+-+"
end sub

function humanmove()
    i = 0
    while ( i < 1 ) or ( i > 9 ) or not( bord( i ) )
        input "Your move : " ; in$
        i = val( in$ )
    wend
    humanmove = i
end function

function randomove()
    i = 0
    while not( bord( i ) )
        i = int( rnd(0) * 9 + 1 )
    wend
    randomove = i
end function

function aimove( no )
    i = int( rnd(0) * ( len( mem$( no ) ) - 1 ) )
    aimove = val( mid$( mem$( no ) , i + 1 , 1  ) )
end function

function choise()
    spel = 0
    while spel < 1 or spel > 5
        print "Welkome by not3 :"
        print "a game by bluatigro ."
        print "Target of the game :"
        print "Move your X so that"
        print "the computer moves the 3e X in a row ."
        print "1 : you - rando ."
        print "2 : rando - you ."
        print "3 : rando - rando . [ autoplay ] "
        print "4 : you - ai ."
        print "5 : ai - you ."
        input "Choise ? [ 1 , 2 , 3 , 4 , 5 ] : " ; in$
        spel = val( in$ )
    wend
    choise = spel
end function

function game( spel )
    player = 0
    tel = 0
    u = 0
    call newbord
    while not( ry() )
        if spel <> 3 then
            call showbord
        end if
        select case spel
        case 1
            if player then
                z = randomove()
            else
                z = humanmove()
            end if
        case 2
            if player then
                 z = humanmove()
            else
                 z = randomove()
            end if
        case 4
            if player then
                z = aimove( u )
            else
                z = humanmove()
            end if
        case 5
            if player then
                z = humanmove()
            else
                z = aimove( u )
            end if
        case else
            z = randomove()
        end select
        tel = tel + 1
        bord( z ) = 0
        zetten( tel ) = z
        u = u or ( 2 ^ ( z - 1 ) )
        borden( tel ) = u
        player = 1 - player
    wend
    game = tel
end function

sub remove no , z
    if instr( mem$( no ) , str$( z ) ) then
        q = instr( mem$( no ) , str$( z ) )
        l$ = left$( mem$( no ) , q  - 1 )
        r$ = mid$( mem$( no ) , q + 1 )
        mem$( no ) = l$ + r$
    end if
end sub

sub add no , z
    if len( mem$( no ) ) < 100 then
        mem$( no ) = mem$( no ) + str$( z )
    end if
end sub

sub killal no , z
    while instr( mem$( no ) , str$( z ) )
        call remove no , z
    wend
end sub

sub evaluate q
    select case q
        case 3
            call add borden( 2 ) , zetten( 2 )
            call killal borden( 3 ) , zetten( 3 )
        case 4
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call killal borden( 4 ) , zetten( 4 )
        case 5
            call add borden( 2 ) , zetten( 2 )
            call remove borden( 3 ) , zetten( 3 )
            call add borden( 4 ) , zetten( 4 )
            call remove borden( 5 ) , zetten( 5 )  '' or killal ?
        case 6
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call remove borden( 4 ) , zetten( 4 )
            call add borden( 5 ) , zetten( 5 )
            call remove borden( 6 ) , zetten( 6 )  '' or killal ?
        case else
    end select
end sub

 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 857
xx Re: NOT 3
« Reply #9 on: Jun 5th, 2016, 06:15am »


update
try at file stuf

is this [ the gray stuf ] now corect ?

Code:

dim bord( 9 ) , borden( 9 ) , zetten( 9 ) , mem$( 512 ) , info$( 10 , 10 )
global timesplayed

call readmem

in$ = "y"
while in$ = "y"
    spel = choise()
    if spel = 3 then
        input "How many times autoplay ? " ; in$
        a = val( in$ )
        for i = 0 to a
            print a - i
            call evaluate game( spel )
        next i
    else
        print "Times played : " ; timesplayed
        call evaluate game( spel )
    end if
    input "Again ? ( y / n ) : " ; in$
wend

''call writemem

end

sub newbord
    for i = 0 to 9
        bord( i ) = i
    next i
    bord( 0 ) = 1
end sub

function rij( a , b , c )
    rij = not( bord( a ) ) _
      and not( bord( b ) ) _
      and not( bord( c ) )
end function

function ry()
    ry = rij( 1 , 2 , 3 ) _
      or rij( 4 , 5 , 6 ) _
      or rij( 7 , 8 , 9 ) _
      or rij( 1 , 4 , 7 ) _
      or rij( 2 , 5 , 8 ) _
      or rij( 3 , 6 , 9 )
end function

function p$( i )
    if bord( i ) then
        uit$ = str$( bord( i ) )
    else
        uit$ = "X"
    end if
    p$ = uit$
end function

sub showbord
    print "+-+-+-+"
    print "|" + p$( 1 ) _
           + "|" + p$( 2 ) _
           + "|" + p$( 3 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 4 ) _
           + "|" + p$( 5 ) _
           + "|" + p$( 6 ) + "|"
    print "+-+-+-+"
    print "|" + p$( 7 ) _
           + "|" + p$( 8 ) _
           + "|" + p$( 9 ) + "|"
    print "+-+-+-+"
end sub

function humanmove()
    i = 0
    while ( i < 1 ) or ( i > 9 ) or not( bord( i ) )
        input "Your move : " ; in$
        i = val( in$ )
    wend
    humanmove = i
end function

function randomove()
    i = 0
    while not( bord( i ) )
        i = int( rnd(0) * 9 + 1 )
    wend
    randomove = i
end function

function aimove( no )
    i = int( rnd(0) * ( len( mem$( no ) ) - 1 ) )
    aimove = val( mid$( mem$( no ) , i + 1 , 1  ) )
end function

function choise()
    spel = 0
    while spel < 1 or spel > 5
        print "Welkome by not3 :"
        print "a game by bluatigro ."
        print "Target of the game :"
        print "Move your X so that"
        print "the computer moves the 3e X in a row ."
        print "1 : you - rando ."
        print "2 : rando - you ."
        print "3 : rando - rando . [ autoplay ] "
        print "4 : you - ai ."
        print "5 : ai - you ."
        input "Choise ? [ 1 , 2 , 3 , 4 , 5 ] : " ; in$
        spel = val( in$ )
    wend
    choise = spel
end function

function game( spel )
    timesplayed = timesplayed + 1
    player = 0
    tel = 0
    u = 0
    call newbord
    while not( ry() )
        if spel <> 3 then
            call showbord
        end if
        select case spel
        case 1
            if player then
                z = randomove()
            else
                z = humanmove()
            end if
        case 2
            if player then
                 z = humanmove()
            else
                 z = randomove()
            end if
        case 4
            if player then
                z = aimove( u )
            else
                z = humanmove()
            end if
        case 5
            if player then
                z = humanmove()
            else
                z = aimove( u )
            end if
        case else
            z = randomove()
        end select
        tel = tel + 1
        bord( z ) = 0
        zetten( tel ) = z
        u = u or ( 2 ^ ( z - 1 ) )
        borden( tel ) = u
        player = 1 - player
    wend
    game = tel
end function

sub remove no , z
    if instr( mem$( no ) , str$( z ) ) then
        q = instr( mem$( no ) , str$( z ) )
        l$ = left$( mem$( no ) , q  - 1 )
        r$ = mid$( mem$( no ) , q + 1 )
        mem$( no ) = l$ + r$
    end if
end sub

sub add no , z
    if len( mem$( no ) ) < 100 then
        mem$( no ) = mem$( no ) + str$( z )
    end if
end sub

sub killal no , z
    while instr( mem$( no ) , str$( z ) )
        call remove no , z
    wend
end sub

sub evaluate q
    select case q
        case 3
            call add borden( 2 ) , zetten( 2 )
            call killal borden( 3 ) , zetten( 3 )
        case 4
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call killal borden( 4 ) , zetten( 4 )
        case 5
            call add borden( 2 ) , zetten( 2 )
            call remove borden( 3 ) , zetten( 3 )
            call add borden( 4 ) , zetten( 4 )
            call remove borden( 5 ) , zetten( 5 )  '' or killal ?
        case 6
            call remove borden( 2 ) , zetten( 2 )
            call add borden( 3 ) , zetten( 3 )
            call remove borden( 4 ) , zetten( 4 )
            call add borden( 5 ) , zetten( 5 )
            call remove borden( 6 ) , zetten( 6 )  '' or killal ?
        case else
    end select
end sub

sub readmem
''    if isfile( "not3-mem.txt" ) then
''        open "not3-mem.txt" for input as #in
''            input #in ; timesplayed
''            for i = 0 to 511
''                input #in , mem$( i )
''            next i
''        close #in
''    else
        for i = 0 to 511
            zz$ = ""
            for m = 0 to 8
                if ( i and  2 ^ m ) = 0 then
                    for q = 0 to 3
                        zz$ = zz$ + str$( m + 1 )
                    next q
                end if
            next m
            mem$( i ) = zz$
        next i
''    end if
end sub

sub writeman
''    open "not3-mem.txt" for output as #uit
''        #uit , timesplayed
''        for i = 0 to 511
''            #uit , mem$( i )
''        next i
''    close #uit
end sub

function isfile( file$ )
  files file$ , info$()
  isfile = val( info$( 0 , 0 ) )
end function

 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 857
xx Re: NOT 3
« Reply #10 on: Jun 6th, 2016, 06:26am »


this game is based on the story about someone
who made a tic tac toe computer out of many matchboxes
whitch worked as folows :
on every box was a diagram whit the curent bord
situation whit on the empty places a number
of the box that folowed that move
in the box were papers whit the same numbers
a move of the box computer was determent
by taking a paper out of the box in question
after every game the bad moves were taken out
of the box of that move and good moves were
put in so every time you played the box computer
was stronger

the only thing i changed was the type of game
so i have 2^9 = 512 bord situations


User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls