CRIBLCrib2 Crib1 CribL !BOOT 3 +q+s#/*BASIC
PAGE=&1900
*FX21
CLOSE#0:CHAIN "CRIBL"
Cribbage Instructions
Version B1.0
Author Graham Crossley
( BEEBUG June 1989
2 Instructions from mag.
<:
F*FX200,3
P/print_titles("CRIBBAGE","Graham Crossley")
Z'" Press 'space' bar to continue";
d*FX15,0
n
=32
x7:23;8202;0;0;0;
130;16);141;"Cribbage"
130;16);141;"Cribbage"'
" Cribbage is a card game for two players, where the object is to score points for certain combinations of cards. The first player to reach 121 points is the winner of the game."
w"In this computer implementation, the Beeb plays one of the hands, and will prove a tough opponent to beat."
x"Cribbage may seem a complex game to master, but a little practice with thisprogram will soon get you going."
+7,23)130"Press any key to continue";
*FX15
G=:28,0,22,39,3:
;"The rules played by this version are as follows:"
"Six cards are dealt to each player after which both must discard 2 in order to make up a third hand called the box."
"The deck is then cut and the top card turned face up and placed to the left between the players. The hands are now played, with opponents laying cards alternately while trying to score points."
n"When both players have used all their cards, the value of their hands is alsoadded to their scores."
^"Players take it in turns to have the value of the box hand added to their score."
*FX15
" G=:
,"SCORING POINTS"
6"Two points may be scored on the cut. If a Jack is cut then the player who owns the box is awarded 2 points. When hands (including the box) are valued they score points as follows:"
@" 1.Firstly the card which was cut becomes a fifth card and is included in the hand's value. The player who does not own the box has his hand counted and added to his total first. This is known as the 'take'."
J" 2.Each different combination of cards which add up to 15 scores 2 points. The Aces counts as 1 and J, Q, K as 10 each."
T" 3.Two cards the same (i.e. a pair) scores 2, while three or four the same scores 6 and 12 points respectively."
^ *FX15
h G=:
r" 4.Runs of three or more cards score the number of points that there are cards in the run, i.e. 3 for a run of three."
" 5.If all four cards in a players hand are of the same suit 4 points are scored, and if the cut card is also of the same suit then a fifth point is added. When the box is being valued"
"then only the 5 points may be scored."
b" 6.If the hand holds the Jack of the same suit as the cut card then 1 point is scored."
" 7.The same card(s) may be used in several combinations, e.g. 6678K would score 10  2 for the 15,2 for the pair and 6 in two runs."
*FX15
G=:
"PLAYING THE HANDS"
"During play the running total of cards played so far is maintained untileither the total reaches 31 or neither player can lay a card without the totalexceeding 31. The player who lays the"
"last card scores 1 point, but 2 points if the total was 31. The cards played are then erased, the running total zeroed and the process repeated until all cards have been played."
"Points may also be scored as follows:"
D" 1.If a player makes the total 15 then 2 points are scored."
}" 2.Two (i.e. a pair), three or four cards the same played in succession score 2, 6 or 12 points respectively."
*FX15
G=:
" 3.An unbroken run of three or more cards played earns a player the number of points as there are cards in the run. The difference here is that runs may be in the reverse order."
" 4.Combinations of the above are possible i.e., if a 6 and 5 have been played making a running total of 11, playing a 4 will score 5; 3 for the runand 2 for the 15."
&"Similarly, if the last card played was a 2 and the total is at 29 then playinganother 2 will score 4; 2 for the pair and 2 for the 31. Three 5's played in succession scores 8; 6 for three cards the same and 2 for the 15."
0 *FX15
:
G=:
D"ABOUT THE PROGRAM"
N"During play a text window shows which player has the 'box' which has the 'take', the players' scores and the number of games won."
X"Messages are displayed below the line of asterisks with the running total, and any points scored shown on the lower line."
b"Cards to be discarded or played are selected by typing the number shown below the appropriate card(s) followed byRETURN.A choice may be cancelled with theDELETEkey, while hitting the"
ll"0key during play indicates that you cannot play. However, if you can play then you must do so."
vG=:26,12
=&1900:"CRIB1"
!print_titles(prog$,author$)
beeb$,row,let
22,7;23;8202;0;0;0;
"beeb$="BEEBUG"+4," BEEBUG")
26::row=0:let=0
:let=let+1
!(let+129);"BEEBUG",let,1);
38);"GBEEBU",let,1)
let=let 6:row=row+1
row=24
beeb$;
26:beeb$
row=28
19(prog$)2,row);prog$
row
*12,11);"PROGRAM AUTHOR"
4!19(author$)2,13);author$
>3,19);
H
Program Cribbage Loader
Version B1.0
Author Graham Crossley
( BEEBUG June 1989
2" Program subject to copyright
<:
dV*KEY0 *TAPEMFORN%=0TOTOPPAGE STEP4:N%!&E00=N%!PAGE:NEXTMPAGE=&E00MOLDMRUNFM
n*KEY1 DEL.10,140MRUNFM
xOtB@:N%=128146:A%,B%,C%,D%,E%,F%,G%,H%:23,N%,A%,B%,C%,D%,E%,F%,G%,H%:
204,204,51,51,204,204,51,51,3,7,15,15,15,7,59,127,128,192,224,224,224,192,184,252,255,255,253,125,57,1,3,7,254,254,126,124,56,0,128,192,24,124,126,255,255,255,255,255,48,124,252,254,254,254,254,254,255,127,127,63,31,15,7,3
254,252,252,248,240,224,192,128,1,3,7,15,31,31,63,63,0,128,192,224,240,240,248,248,63,63,63,31,13,1,3,7,248,248,248,240,96,0,128,192,1,3,7,15,31,63,127,255,128,192,224,240,248,252,254,255,255,127,63,31,15,7,3,1
Z 255,254,252,248,240,224,192,128,206,219,219,219,219,219,206,0,1,3,6,140,216,112,32,0
:"CRIB2"
Program Cribbage
Version B1.0
Author Graham Crossley
( BEEBUG June 1989
2" Program subject to copyright
<:
d>&E00 21:*FX138,0,128
n1:19,2,2;0;:0,130:0,0::0,128:16,656:208,656:208,395:16,395:16,656:24,800;311;1264;1007;::0,131:24,792;319;1256;1015;::0:131:28,25,21,38,1,4,23,1,0;0;0;0;
xn3,0)"CRIBBAGE"'3)"********"''7)"Me You"'7)"~~ ~~~"''"BOX"''"TAKE"''"SCORE"''"GAMES 0 0"''14,"*")
21:*FX138,0,129
*FX18
i::g:w:nm
A=:!4
g
Ix:M%=():G%=0:sc%?0=0:sc%?1=0::sh:d:st:di:sb:kt:pl:ch:G%
i:*FX21,0
h% 4,s% 4,hi% 15,k% 1,sc% 1,R% 7,d% 51,p% 51,g%(1),w$(1):box%=(2)1:w$(0)=" I ":w$(1)=" YOU":n$=" 1 2 3 4 5 6":N%=051:d%?N%=N%:
$st
.\box%=(box%1):0:131:28,33,9,38,7,4,12:4*box%,0)146;:go%=(box%1):4*go%,2)146;
8
Bsh
L8l(2,3,0,39,0,8):l(2,3,0,791,0,8):l(2,0,0,415,0,8)
Vm(" SHUFFLING"):L%=0(9):N%=051:M%=(51N%)+N%1:T%=d%?N%:d%?N%=d%?M%:d%?M%=T%:::N%=051:p%?N%=d%?N%::so(0,4):so(6,10):m("")
`
jso(n%,l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=k%?0+6:k%?1=k%?1+6:m(""):ro(14,10):l(2,1,4,39,0,8):l(0,3,0,39,6,8):n(0,130,0,n$,1,27)+7," "))
kt
l(0,0,0,415,16,8):p%?1613+1=11 @%=2:S%=2:go%=box%:131:0:28,27,21,38,21,4,12,7,23,1,0;0;0;0;:"JACK CUT=2";:K%=300::sc:go%=(box%1)
m(w$)
2131:1:28,25,19,38,17,4,23,1,0;0;0;0;::w$;
b
>N%=1k%?0=K% k%?N%=K%:N%=N%+1:n(2,128,K%*6+3,(K%+1))
e
*N%=N%1:n(0,130,k%?N%*6+3,(k%?N%+1))
*n(f%,b%,x%,n$)
4528,0,31,39,31,4,23,1,0;0;0;0;:f%:b%:x%,0)n$;
>
Hro(d%,e%)
RFN%=01:p%?(d%+N%)=p%?k%?N%::k%?0>k%?1 T%=k%?0:k%?0=k%?1:k%?1=T%
\8N%=01:L%=k%?N%e%:p%?L%=p%?(L%+1)::k%?1=k%?11:
f
ppl
zxG% P%=1:diff%=1:same%=1:T%=0:M%=3:Y%=4:I%=:U%=:N%=09:p%?(N%+20)=p%?N%::p%?24=p%?16:p%?30=p%?16::go%y o
G%(Y%=0M%=1)
y
U%go%=0: C%=c
/C%<>5U%=:I%S%=1:sc:x:go%=0: go%=0:
8u:p%?C%=&FF:Y%=Y%1:M%=1I%=:Y%=0O% S%=1:sc:x
G%go%=0
o
I%go%=1:
*M%>1U%S%=1:sc:x:go%=1: go%=1:
T%=0C%=M%:q:
I%=:N%=0M%:T%+v<32I%=
*:I%U%S%=1:sc:x:go%=1: go%=1:
M%=0C%=0:q:
N%=0M%:s :q:
$N%=0M%:r :q:
.N%=0M%:t :q:
8N%=0M%:f :q:
BN%=0M%:p :q:
L N%=M%::T%+v<32 C%=N%:N%=0
VN%=N%1:N%=1:q:
`ݤs
jDp%?N%13+1=R%?P%(same%=3same%=2)T%+v<32 C%=N%:N%=M%:= =
tݤr
~Adiff%>1((p%?N%13+1)R%?P%)=1T%+v<32 C%=N%:N%=M%:= =
ݤt
!T%+v=31 C%=N%:N%=M%:= =
ݤf
!T%+v=15 C%=N%:N%=M%:= =
ݤp
2p%?N%13+1=R%?P%T%+v<32 C%=N%:N%=M%:= =
ݤv
p%?N%=&FF =&FF
"L%=p%?N%13+1:L%>10 =10 =L%
ݤc
Y%=0=5m(" YOU TO PLAY")
L::h:K%>1n(2,128,K%*6+3,(K%+1))::N%=:N%=127N%=13 K%=1N%=13
#N%=127n(0,130,K%*6+3,(K%+1))
7N%=13:K%>1n(2,130,K%*6+3," "):l(2,0,K%,39,0,8)
m(""):=K%+6
ݤh
(LK%=49:K%=1 =tr K%<1K%>3 = N%=K%+6:p%?N%=&FFT%+v>31 = =
2ݤtr
<N%=69:T%+v<32 N%=9::=
F:=
Pq
ZEl(2,0,M%,791,0,8):u:z:M%=M%1:Y%=0 U%=:M%=1O% S%=1:sc:x
dG% go%=1
n
xu
SP%=P%+1:R%?P%=p%?C%13+1:l(0,0,1,415,C%1,8P%):S%=0:N%=C%:T%=T%+v:T%=15S%=2
P% S%=S%+al+rn
T%=31 S%=S%+2
"rt:K%=300:sc:T%=31 O%=:x
x
W130:28,7,19,22,12,4::28,28,21,36,21:131::I%=:U%=:T%=0:P%=1:same%=1:diff%=1
z
,C%=M% N%=C%M%1:p%?N%=p%?(N%+1):
ݤal
jN%=(R%?P%=R%?(P%1)):same%=4N% same%=1:=0same%=3N% same%=4:=12same%=2N% same%=3:=6same%=2:=2
ݤrn
pN%=((R%?P%R%?(P%1))=1):N%diff%=1:=0diff%=1diff%=2:=0R%?P%<>R%?(P%2)diff%=diff%+1:=diff%diff%=2:=0
sc
"h@%=3:O%=:S%=0 0:131:28,31,11,38,11,4:sc%?go%=sc%?go%+S%:go%*4,0)sc%?go%;:sc%?go%>=121 G%=
,
6rt
@E@%=2:131:0:28,28,21,37,21,4,12,7,23,1,0;0;0;0;:T%;" FOR ";S%;
J
T;k:0:131:28,25,19,38,19,4:"PRESS ANY KEY";:::
^ch
hG% l(0,3,0,791,20,8):l(0,3,0,39,26,8):go%=box%:J%=12:go%=(go%1):S%=s5(20+go%*6,):m(w$(go%)+" SCORE "+(S%)):k:sc:G% J%=2::
rl(2,3,0,791,0,8):l(2,3,0,39,0,8):l(0,3,0,39*box%+791*(box%1),12,8):S%=s5(12,):m(" BOX SCORE="+(S%)):k:go%=box%:sc

w
u@%=3:m(" "+w$(go%)+" WIN"+19," ")+"ANOTHER Y/N?"):g%(go%)=g%(go%)+1:0:131:28,31,13,38,13:go%*4,0)g%(go%);
ݤnm
Z:K%=&5F:K%=78K%=89:K%=89 28,31,11,38,11:" ":= m("OK,BYE FOR NOW"):=
0,1,2,3,4,5
0,1,2,4,3,5
0,1,2,5,3,4
0,1,3,4,2,5
0,1,3,5,2,4
0,1,4,5,2,3
0,2,3,4,1,5
0,2,3,5,1,4
0,2,4,5,1,3
0,3,4,5,1,2
1,2,3,4,0,5
&1,2,3,5,0,4
01,2,4,5,0,3
:1,3,4,5,0,2
D2,3,4,5,0,1
N,0,1,2,3,0,1,2,4,0,1,3,4,0,2,3,4,1,2,3,4
X@0,1,2,0,1,3,0,2,3,1,2,3,0,1,4,0,2,4,0,3,4,1,2,4,1,3,4,2,3,4
b,0,1,0,2,0,3,1,2,1,3,2,3,0,4,1,4,2,4,3,4
lh0,1,2,3,4,0,1,3,2,4,0,2,3,1,4,1,2,3,0,4,0,1,4,2,3,0,2,4,1,3,0,3,4,1,2,1,2,4,0,3,1,3,4,0,2,2,3,4,0,1