# GuessNum .bas # a HotPaw Basic applet # new np=4 :' number of pegs nc=6 :' range of digits dim g(np),s(np),cg(nc),cs(nc) dim m$(nc+1) for i=1 to nc:m$(i)=str$(i): next i : m$(nc+1)="" draw -1 form btn 110,130,40,12,"Try",1 form lst 10,130,nc+1,1,m$,1 form lst 34,130,nc+1,1,m$,1 form lst 56,130,nc+1,1,m$,1 form lst 80,130,nc+1,1,m$,1 x=rnd(-timer) nloop: for i=1 to np:s(i)=1+rnd(nc):next i ng=0 draw -1 form redraw 0,0,0,0,"",-1 gloop: k = asc(input$(1)) g$="" for i=1 to np t = val(s$(i-1)) g$=g$+s$(i-1) if t > nc or t < 1 then t = 0 g(i)=t next i gosub numb(np) gosub numw(np,nc) ng = ng+1 a$=str$(ng)+" : "+g$+" -> " a$=a$+str$(numb)+" B " a$=a$+str$(numw)+" W " y=5+11*ng : if y> 118 then y=117 draw a$,10, y if numb s(j)) cg(g(j)) = cg(g(j))+1 cs(s(j)) = cs(s(j))+1 # ? j, g(j),s(j) endif next j w=0 for i=1 to nc t=cg(i) : if t>cs(i) then t=cs(i) w=w+t #? cg(i),cs(i),t,w next i numw=w end sub # end run # # (c)2000 rhn@hotpaw.com