Go Fish/Locomotive Basic: Difference between revisions

m
Fixed syntax highlighting.
(Created page with "<lang locobasic>10 cls:randomize time:defint a-z 20 dim play(13),compu(13),deck(13),guess(13),poss(13) 30 card$="A234567890JQK" 40 remca=4*13-2*9 50 for i=1 to 13:deck(i)=4:next ...")
 
m (Fixed syntax highlighting.)
 
(One intermediate revision by one other user not shown)
Line 1:
<langsyntaxhighlight lang="locobasic">10 cls:randomize time:defint a-z
20 dim play(13),compu(13),deck(13),guess(13),poss(13),asked(13)
30 card$="A234567890JQK"
40 remca=4*13-2*9
50 for i=1 to 13:deck(i)=4:next
60 for i=1 to 9
70 'gosub RND_COMP1250
80 deck(k)=rnd*12+deck(k)-1
90 if deckcompu(k)=0 then 80compu(k)+1
350100 gosub 11001250
100 deck(k)=deck(k)-1
110 compudeck(k)=compudeck(k)+-1
160120 play(k)=play(k)+1
120 ' RND_PLAY
130 k=rnd*12+1next i
140 ifprint deck(k)=0"Go then 130Fish"
150 deck(k)print "=deck(k)-1======"
330160 print
160 play(k)=play(k)+1
170 input "What is your name";name$
170 next i
180 print' "Go Fish"PRINT_HAND
230190 print "Score: "name$;" ";score(0);" Computer: ";score(1)
190 print "======="
200 print ,remca"cards remaining"
210 inputprint "WhatYour ishand: your name";name$
220 'for PRINT_HANDi=1 to 13
270230 if play(i)=0 then 320280
230 print "Score: "name$;score(0);" Computer: ";score(1)
240 for j=1 to play(i)
240 print ,remca"cards remaining"
250 print mid$(card$,i,1);"Your hand: ";
260 fornext i=1 to 13j
270 ' NEXT_CARD
270 if play(i)=0 then 320
280 fornext j=1 to play(i)
290 print mid$(card$,i,1);" ";
300 next' jASK_CARD
310 'gosub NEXT_CARD1100
320 next is$=name$
370330 input "Which card do you ask for";c$
330 print
340 'if ASK_CARDc$="" then 310
380350 cn=instr(card$,upper$(c$))
350 gosub 1100
400360 if play(cn)=0 then print "YouSorry, dothat is not havea thatvalid card!choice.":goto 350310
360 s$=name$
370 if play(cn)=0 then print "You do not have that card!":goto 310
370 input "Which card do you ask for";c$
380 guess(cn)=1
380 cn=instr(card$,upper$(c$))
390 if compu(cn)=0 then print s$"Sorry, thatgo isfish!":print nots$" draws a valid choice";:gosub 800:gosub 920:goto 350470
430400 v=compu(cn)
400 if play(cn)=0 then print "You do not have that card!":goto 350
410 guesscompu(cn)=10
450420 play(cn)=play(cn)+v
420 if compu(cn)=0 then print s$", go fish!":print s$" draws a ";:gosub 760:gosub 920:goto 500
460430 print s$" gets"v"more cards."
430 v=compu(cn)
440 compu(cn)=0gosub 920
600450 goto 650190
450 play(cn)=play(cn)+v
460 ' COMPUTER_TURN_1
460 print s$" gets"v"more cards."
470 gosub 920s$="Computer"
480 gotofor 230i=1 to 13
490 ' COMPUTER_TURNasked(i)=0
500 s$="Computer"next
510 ' COMPUTER_TURN_2
510 po=0
520 forgosub i=1 to 131100
510530 po=0
530 if (compu(i)>0) and (guess(i)>0) then poss(i)=1:po=po+1
540 nextfor i=1 to 13
550 if po=(compu(i)>0) and (guess(i)>0) then 620poss(i)=1:po=po+1
560 ' DRAW_GUESSnext
570 kif po=rnd*12+10 then 650
580 ' DRAW_GUESS
580 if poss(k)=0 then 570
590 guess(k)=0rnd*12+1
580600 if poss(k)=0 then 570590
600 goto 650
610 ' DRAW_RANDguess(k)=0
620 asked(k)=rnd*12+1
730630 goto 230680
630 if compu(k)=0 then 620
640 ' MAKE_TURNDRAW_RAND
650 k=rnd*12+1
650 print "Computer wants a "mid$(card$,k,1)
630660 if compu(k)=0 or asked(k) then 620650
660 if play(k)=0 then print s$", go fish!":print s$" draws a ";:gosub 840:gosub 1010:goto 230
670 v=play(k)' MAKE_TURN
650680 print s$"Computer wants ayour "mid$(card$,k,1)"'s."
680 play(k)=0
690 compuasked(k)=compu(k)+v1
420700 if compuplay(cnk)=0 then print s$", go fish!":print s$" draws a ";:gosub 760860:gosub 9201010:goto 500190
700 print s$" gets"v"more cards."
710 gosub 1010v=play(k)
720 goto 500play(k)=0
730 compu(k)=compu(k)+v
730 goto 230
700740 print s$" gets"v"more cards."
740 end
750 'gosub DRAW_CARD_P1010
760 k=rnd*12+1goto 520
770 goto 190
770 if deck(k)=0 then 760
740780 end
780 print mid$(card$,k,1)
790 ' DRAW_CARD_P
790 deck(k)=deck(k)-1
800 gosub 1250
800 play(k)=play(k)+1
780810 print mid$(card$,k,1)"."
810 remca=remca-1
100820 deck(k)=deck(k)-1
820 return
680830 play(k)=0play(k)+1
830 ' DRAW_CARD_C
840 k=rnd*12+1return
830850 ' DRAW_CARD_C
850 if deck(k)=0 then 840
860 printgosub "card"1250
190870 print "=======card."
870 deck(k)=deck(k)-1
880 compudeck(k)=compudeck(k)+-1
890 remcacompu(k)=remca-compu(k)+1
900 return
910 ' CHECK_BOOK_P
920 for i=1 to 13
930 if play(i)<>4 then 980
940 print s$" completes book of "mid$(card$,i,1)"'s."
950 play(i)=0
960 score(0)=score(0)+1
Line 101:
1010 for i=1 to 13
1020 if compu(i)<>4 then 1070
1030 print s$" completes book of "mid$(card$,i,1)"'s."
1040 compu(i)=0
1050 score(1)=score(1)+1
Line 119:
1190 print "*** Game over! ***"
1200 print
1210 if score(0)>score(1) then print name$" has won.":end
1220 if score(0)<score(1) then print "The computer has won.":end
1230 print "It's a tie!":end</lang>
1240 ' DEAL_CARD
8101250 remca=remca-1
1260 sc=remca*rnd+1
1270 for k=1 to 13
1280 sc=sc-deck(k)
7701290 if deck(k)sc<=0 then 760return
1300 next</syntaxhighlight>
 
Note: 10's are called 0's here to get single-letter rank names.
9,476

edits