Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Playing-cards/XPL0/playing-cards.xpl0
Normal file
32
Task/Playing-cards/XPL0/playing-cards.xpl0
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
char Deck(52); \card structure (low 2 bits = suit)
|
||||
def Players = 4; \number of players to deal to
|
||||
char Hand(Players, 52); \each player's hand
|
||||
int Card, N, I, J, T;
|
||||
char Suit, Royal;
|
||||
[for Card:= 0 to 52-1 do \make a new deck
|
||||
Deck(Card):= Card;
|
||||
for N:= 0 to 10000 do \shuffle the deck
|
||||
[I:= Ran(52); J:= Ran(52);
|
||||
T:= Deck(I); Deck(I):= Deck(J); Deck(J):= T;
|
||||
];
|
||||
for N:= 0 to 52-1 do \deal from the deck
|
||||
[Card:= Deck(N);
|
||||
I:= N/Players;
|
||||
J:= rem(0);
|
||||
Hand(J, I):= Card;
|
||||
];
|
||||
Suit:= "HDCS "; \print each player's hand
|
||||
Royal:= "JQK "; \ (= contents of the deck)
|
||||
for J:= 0 to Players-1 do \e.g: 2D 3C 10C AS KD
|
||||
[for I:= 0 to 52/Players -1 do
|
||||
[Card:= Hand(J, I);
|
||||
N:= Card>>2 + 1; \pip value
|
||||
if N = 1 then ChOut(0, ^A)
|
||||
else if N >= 11 then ChOut(0, Royal(N-11))
|
||||
else IntOut(0, N);
|
||||
ChOut(0, Suit(Card&3));
|
||||
ChOut(0, ^ );
|
||||
];
|
||||
CrLf(0);
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue