home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 32
/
032.d81
/
yahtzee
(
.txt
)
< prev
Wrap
Commodore BASIC
|
2022-08-26
|
8KB
|
319 lines
1 dimb%(39):poke53281,0:poke53280,6:poke646,1
5 remnocas converter
10 rem
15 rem **********************
18 rem
20 rem computer yahtzee
30 rem
40 rem copyright 1986
45 rem
50 rem by: christine benoit
60 rem
65 rem **********************
70 rem
80 rem
100 gosub960:remtitlepage
110 gosub800:reminitialize
115 gosub1100:reminstrucs
120 print"[147]"chr$(142);:gosub900:remborder
130 gosub700:remscreen
140 gosub750:remclear
150 gosub200:remplay
160 gosub914:remtotalup
170 ifagn=1then120
180 printchr$(147);:
190 print:goto63000
200 gosub300:remrolldice
210 gosub450:remsort
220 gosub500:remscore
225 numleft=numleft-1
230 ifnumleft>0then200
240 return
250 print"";:vt=10:ht=1:gosub50000:printchr$(18);:printsp$;
255 vt=10:ht=1:x=41-len(x$):y=int(x/2)
260 printspc(y);x$;
265 x=fre(0):return
270 rem sound routine
280 rem
290 return
300 trial=1:print"[158]";
305 fori=5to7:vt=i:ht=5:gosub50000:printspc(30);:next
310 fori=1to5:rl(i)=1:next
315 print"[158]";:fori=1to5
320 ifrl(i)=0then328
325 dice(i)=int(rnd(1)*6)+1:d=i:gosub400:rl(i)=0
328 nexti
330 iftrial=3thenprint"";:return
335 trial=trial+1
340 :
345 :
350 :
355 :
356 :
360 x$="select dice--press return: 1 2 3 4 5 ":gosub250
365 r=5:n=0
370 poke198,0:wait198,1
375 getk$:k=asc(k$+chr$(0)):ifk$="q"thengosub60000:ifk=141then315
376 ifk=13then315
380 k=k-48:ifk<1ork>5then370
385 v=10:ifrl(k)=0thenrl(k)=1:n=n+1:goto395
390 rl(k)=0:n=n-1
395 print"[146]";:ifrl(k)=0thenprint"";
396 vt=v+1:ht=26+2*k:gosub50000
397 printmid$(str$(k),2);"";
398 goto370
400 v=5:h=6*d
410 forx=3to12:vt=v+x-3*int(x/3):ht=h:gosub50000:print"[209][209][209]";:ht=h
412 gosub50000:print" ";:next
415 d=dice(d)
420 vt=v:ht=h:gosub50000:printdice$(d,1);
425 vt=v+1:ht=h:gosub50000:printdice$(d,2);
430 vt=v+2:ht=h:gosub50000:printdice$(d,3);
435 rem
440 return
450 fori=1to4
455 forj=i+1to5
460 ifdice(j)>=dice(i)then470
465 x=dice(j):dice(j)=dice(i):dice(i)=x
470 nextj
475 nexti
480 return
500 x$="select score with cursor and return ":gosub250:print"[129]";
505 c=1:dc=1:goto555
510 poke198,0:wait198,1:print"[129]";
515 getk$:k=asc(k$+chr$(0)):ifk$="q"thengosub60000:ifk=13then570
516 ifk=13then570
520 ifk=17thendc=1:goto535
525 ifk=145thendc=-1:goto535
530 goto510
535 vt=vrt(c):ht=2+15*abs((c>6)):gosub50000:print"[146][129]"choice$(c)
540 c=c+dc
545 ifc=0thenc=13
550 ifc=14thenc=1
555 ifsc(c,2)=1then540
560 print"";:vt=vrt(c):ht=2+15*abs((c>6)):gosub50000:printchoice$(c)
565 goto510
570 ifc<7then637
571 onc-6goto577,585,593,603,617,627,632
572 sc(c,1)=temp:sc(c,2)=1:vt=vrt(c)
573 ht=2+15*abs((c>6)):gosub50000:printchoice$(c);
574 ht=10+23*abs((c>6)):gosub50000:printspc(abs((temp<10)));
575 s$=mid$(str$(temp),2):iflen(s$)<2thenprint"[157] ";
576 print"[158]";s$;"[129]";:gosub690:return
577 rem***3ofakind
578 rem
579 ifdice(1)=dice(2)anddice(2)=dice(3)then583
580 ifdice(2)=dice(3)anddice(3)=dice(4)then583
581 ifdice(3)=dice(4)anddice(4)=dice(5)then583
582 goto646:remerror
583 temp=dice(1)+dice(2)+dice(3)+dice(4)+dice(5)
584 goto572
585 rem
586 rem***4ofakind
587 rem
588 ifdice(1)=dice(4)then591
589 ifdice(2)=dice(5)then591
590 goto646:remerror
591 temp=dice(1)+dice(2)+dice(3)+dice(4)+dice(5)
592 goto572
593 rem
594 rem***fullhouse
595 rem
596 ifdice(1)<>dice(3)then599
597 ifdice(4)=dice(5)then601
598 goto646:remerror
599 ifdice(3)=dice(5)anddice(1)=dice(2)then601
600 goto646:remerror
601 temp=25:goto572
602 s1=0
603 rem
604 rem***smallstraight
605 rem
606 s1=0
607 ifdice(1)+1=dice(2)thens2=1:goto609
608 s2=2
609 forj=s2to4
610 ifdice(j)+1=dice(j+1)thens1=10*s1+dice(j)
611 nextj
612 ifdice(5)-dice(4)=2thens1=10*s1+dice(4):goto614
613 ifdice(5)-dice(4)<2thens1=10*s1+dice(5)
614 ifs1=1234ors1=2345ors1=3456ors1=12345ors1=23456then616
615 goto646:remerror
616 temp=30:goto572
617 rem
618 rem***largestraight
619 rem
620 si=0
621 forj=1to4
622 ifdice(j)+1=dice(j+1)thensi=si+1:goto624
623 si=0
624 nextj
625 ifsi<>4then646:remerror
626 temp=40:goto572
627 rem
628 rem***yahtzee
629 rem
630 ifdice(1)<>dice(5)then646:remerror
631 temp=50:goto572
632 rem
633 rem***chance
634 rem
635 temp=dice(1)+dice(2)+dice(3)+dice(4)+dice(5)
636 goto572
637 rem
638 rem***1'sthrough6's
639 rem
640 temp=0
641 forj=1to5
642 ifdice(j)=cthentemp=temp+c
643 nextj
644 iftemp=0then646:remerror
645 goto572
646 rem
647 rem***errorroutine
648 rem
649 x$=sp$:gosub250:x$="you don't have "
650 ifc<7thenx$=x$+"any ":goto652
651 ifc=9orc=10orc=11thenx$=x$+"a "
652 x$=x$+choice$(c):gosub250:gosub270
653 fort=1to1000:next
654 x$="do you want to take a zero? (y/n)":gosub250:gosub280
655 poke198,0:wait198,1:getr$:printr$;
656 ifr$="y"thentemp=0:x$=sp$:gosub250:print"[146][129]";:goto572
657 ifr$="n"thenx$="select score with cursor and return":gosub250:goto510
658 goto654
690 t=0:fori=1to6:t=t+sc(i,1):next
694 bn=35*abs((t>62))
696 vt=20:ht=10:gosub50000:print"[158]";spc(abs((bn<10)));mid$(str$(bn),2);
698 return
700 print"";spc(6);
705 fori=1to5:printchr$(18);:print"[159]"i"[157] [146] ";:next:printspc(5);:print
706 print:print:print
710 fori=1to3:print"";sp$;:next:print
715 printspc(2)"[129]ones....[158]$$ [129]3 of a kind.....[158]$$"spc(5);
720 printspc(2)"[129]twos....[158]$$ [129]4 of a kind.....[158]$$"spc(5);
725 printspc(2)"[129]threes..[158]$$ [129]full house......[158]$$"spc(5);
730 printspc(2)"[129]fours...[158]$$ [129]small straight..[158]$$"spc(5);
735 printspc(2)"[129]fives...[158]$$ [129]large straight..[158]$$"spc(5);
740 printspc(2)"[129]sixes...[158]$$ [129]yahtzee.........[158]$$"spc(5);
745 printspc(2)"[129]bonus...[158] 0 [129]chance..........[158]$$"spc(5)
746 print"[158] press q[158] to quit."
748 print"":return
750 fori=1to13:sc(i,1)=0:sc(i,2)=0:next
760 numleft=13:bn=0
770 return
800 dimdice(5),dice$(6,3),choice$(13),sc(13,2),rl(5)
802 dimvrt(13)
805 rem
810 fori=1to6:forj=1to3:readdice$(i,j):next:next
815 fori=1to13:readchoice$(i):next
818 fori=1to13:readvrt(i):next
820 rem
830 data" "," [209] "," "," [209]"," ","[209] "
840 data" [209]"," [209] ","[209] ","[209] [209]"," ","[209] [209]"
850 data"[209] [209]"," [209] ","[209] [209]","[209] [209]","[209] [209]","[209] [209]"
860 dataones,twos,threes,fours,fives,sixes,3 of a kind
862 data4 of a kind,full house,small straight
864 datalarge straight,yahtzee,chance
865 data14,15,16,17,18,19,14,15,16,17,18,19,20
870 games = 0:bst=0:wrst=999:ttl=0
875 vt=22:ht=11:gosub50000:print"[ [208][210][197][211][211] [193][206][217] [203][197][217] ]";
877 rem
880 poke198,0:wait198,1:rem****rnd(1):ifk<128then880
885 getk$
890 return
900 printchr$(147);"[146]";
902 print"[154][176][192][192][179][159]c o m p u t e r y a h t z e e[146][154][171][192][192][192][174]";
904 rem
906 fori=1to23:vt=i:ht=0:gosub50000:print"[221]";:ht=39:gosub50000:print"[221]";:next
908 vt=24:ht=0:gosub50000:print"[173][192][192][179][159]b y c h r i s b e n o i t[146][154][171][192][192][192]";:
909 poke2023,125:poke2023+54272,14
910 rem
912 return
914 printdn$
915 print"";:printchr$(18);
916 print"[159] c o m p u t e r y a h t z e e ";
917 tp=bn:fori=1to6:tp=tp+sc(i,1):next
918 bt=0:fori=7to13:bt=bt+sc(i,1):next
920 gt=tp+bt:games=games+1:ttl=ttl+gt:avg=int(ttl/games)
922 ifgt<wrstthenwrst=gt
924 ifgt>bstthenbst=gt
926 vt=9:ht=9:gosub50000:print"[146]---";:ht=32:gosub50000:print"---"
928 vt=10:ht=8:gosub50000:nm=tp:gosub956
930 ht=31:gosub50000:nm=bt:gosub956
932 h=6:vt=14
934 ht=h:vt=vt+1:gosub50000:print"[129]score for this game......[158]";:nm=gt:gosub956
936 ht=h:vt=vt+1:gosub50000:print"[129]number of games played...[158]";:nm=games:gosub956
938 ht=h:vt=vt+1:gosub50000:print"[129]best score so far........[158]";:nm=bst:gosub956
940 ht=h:vt=vt+1:gosub50000:print"[129]worst score so far.......[158]";:nm=wrst:gosub956
942 ht=h:vt=vt+1:gosub50000:print"[129]average score............[158]";:nm=avg:gosub956
944 fort=1to3000:next
946 print:print:agn=0
947 vt=vt+2:ht=11:gosub50000
948 print"[159]play again? ([154]y[159]/[154]n[159])[145]";:gosub280:agn=0
949 poke198,0:wait198,1:getr$
950 ifr$="y"thenagn=1:goto954
952 ifr$<>"n"then949
954 return
956 printspc(abs((nm<100)));spc(abs((nm<10)));nm:return
960 :printchr$(147);: