Wednesday, October 6, 2010

20 and out

rem add 1,2, or 3 . The first to get to 20 loses

clg
font "arial",10,100
total=0 : n=1 : Sq=3
play:
input"How much add 1-3? ",a$
a=int(a$): total=total+a
if Sq<=total then
n=n+1
Sq=4*n-1
endif
if Sq-total < 4 then
p=Sq-total
w=1
else
p=int(rand*2)+1
w=0
endif
total=total+p
for c = total-a-p+1 to total-p
color red
circle 30,290-c*15,5
text 60,285-c*15,c
next c
print "Thinking"
pause rand*5
print "computer play "+ p
for c = total-p+1 to total
color blue
circle 30,290-c*15,5
text 60,285-c*15,c
next c
if total<19 then goto play
if total = 19 and w=1 then
Print "I Won"
else
Print "You won"
end if

No comments:

Post a Comment