LB Booster
« button array : not 3 »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:43am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: button array : not 3  (Read 291 times)
bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx button array : not 3
« Thread started on: Aug 21st, 2015, 09:36am »


i solved the button array problem partly

error :
- the AI does not move
Code:
WindowWidth = 600
WindowHeight = 600
nomainwin
dim bord(9),leeg(9)
for x=0 to 2
  for y=0 to 2
    button #m.b,str$(x+3*y+1),bttn,UL,x*200,y*200,200,200
    maphandle #m.b,"#m.b";x+3*y
  next y
next x
global human,comp,player
human=0
comp=1
open "NOT 3" for window as #m
  #m "trapclose [quit]"
  #m "font Corier_new 90 bold"
  #m "setfocus"
  call newgame
wait
sub bttn h$
  q=val(right$(h$,1))
  if bord(q) then 
    notice "Move your X on a empty place !!"
    exit sub
  end if
  #h$ , "X"
  notice "You pressed button ";q+1
  player=comp
end sub
sub ai
  tel=0
  for i=0 to 8
    if not(bord(i)) then 
      leeg(tel)=i
      tel=tel+1 
    end if
  next i
  for i=0 to tel
    dice=int(rnd(0)*tel)
    h=leeg(dice)
    leeg(dice)=leeg(i)
    leeg(i)=h
  next i
  for i=0 to tel
    bord(leeg(i))=1
    if not(anyrow()) then 
      fl=i
      goto [zetfount]
    end if
    bord(leeg(i))=0
  next i
  fl=int(rnd(0)*tel)
[zetfount]
  notice "I move on ";fl+1
  h$ = "m.b";fl
  #h$ , "X"
  player=human
end sub
function row(a,b,c)
  row=bord(a)and bord(b)and bord(c)
end function
function anyrow()
  anyrow=row(0,1,2) _
      or row(3,4,5) _
      or row(6,7,8) _
      or row(0,3,6) _
      or row(1,4,7) _
      or row(2,5,8)
end function
sub newgame
  for i=1 to 9 
    bord(i-1)=0
''    #m.b;i,str$(i)
  next i
  confirm chr$(13)+"Welkome by NOT 3 ."+chr$(13) _
          +"A game by bluatigro ."+chr$(13) _
          +"Target of the game :"+chr$(13) _
          +"move your X so that" +chr$(13) _
          +"the computer moves "+chr$(13) _
          +"the 3e in a row or colom ."+chr$(13) _
          +"You begin ?";ny$
  if ny$="yes" then
    player=human
  else
    player=comp
    call ai
  end if
end sub
[quit]
  close #m
end
 
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls