33 lines
646 B
Text
33 lines
646 B
Text
make "suits {Diamonds Hearts Clubs Spades}
|
|
make "pips {Ace Two Three Four Five Six Seven Eight Nine Ten Jack Queen King}
|
|
|
|
to card :n
|
|
output (sentence item 1 + modulo :n 13 :pips "of item 1 + int quotient :n 13 :suits)
|
|
end
|
|
|
|
to new.deck
|
|
make "deck listtoarray iseq 0 51
|
|
make "top 1
|
|
end
|
|
|
|
to swap :i :j :a
|
|
localmake "t item :i :a
|
|
setitem :i :a item :j :a
|
|
setitem :j :a :t
|
|
end
|
|
to shuffle.deck
|
|
for [i [count :deck] 2] [swap 1 + random :i :i :deck]
|
|
end
|
|
|
|
to show.deck
|
|
for [i :top [count :deck]] [show card item :i :deck]
|
|
end
|
|
|
|
to deal.card
|
|
show card item :top :deck
|
|
make "top :top + 1
|
|
end
|
|
|
|
new.deck
|
|
shuffle.deck
|
|
repeat 5 [deal.card]
|