Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,21 +1,24 @@
ranks: 1..13
suits: [`♣`, `♦`, `♥`, `♠`]
suits: ['♣', '♦', '♥', '♠']
define :card [rank, suit][
init: [
init: method [rank, suit][
ensure ->
and? -> contains? ranks this\rank
-> contains? suits this\suit
and? -> contains? ranks rank
-> contains? suits suit
this\rank: rank
this\suit: suit
]
print: [
R: ø
case [this\rank=]
when? [1] -> R: `A`
when? [11]-> R: `J`
when? [12]-> R: `Q`
when? [13]-> R: `K`
else -> R: this\rank
string: method [][
R: case this\rank [
1 -> 'A'
11 -> 'J'
12 -> 'Q'
13 -> 'K'
any -> this\rank
]
~{|R||this\suit|}
]
]

View file

@ -1,51 +0,0 @@
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
; ## GLOBALS ##
Global $SUIT = ["D", "H", "S", "C"]
Global $FACE = [2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K", "A"]
Global $DECK[52]
; ## CREATES A NEW DECK
Func NewDeck()
For $i = 0 To 3
For $x = 0 To 12
_ArrayPush($DECK, $FACE[$x] & $SUIT[$i])
Next
Next
EndFunc ;==>NewDeck
; ## SHUFFLE DECK
Func Shuffle()
_ArrayShuffle($DECK)
EndFunc ;==>Shuffle
; ## DEAL A CARD
Func Deal()
Return _ArrayPop($DECK)
EndFunc ;==>Deal
; ## PRINT DECK
Func Print()
ConsoleWrite(_ArrayToString($DECK) & @CRLF)
EndFunc ;==>Print
#Region ;#### USAGE ####
NewDeck()
Print()
Shuffle()
Print()
ConsoleWrite("DEALT: " & Deal() & @CRLF)
Print()
#EndRegion ;#### USAGE ####

View file

@ -1,177 +0,0 @@
identification division.
program-id. playing-cards.
environment division.
configuration section.
repository.
function all intrinsic.
data division.
working-storage section.
77 card usage index.
01 deck.
05 cards occurs 52 times ascending key slot indexed by card.
10 slot pic 99.
10 hand pic 99.
10 suit pic 9.
10 symbol pic x(4).
10 rank pic 99.
01 filler.
05 suit-name pic x(8) occurs 4 times.
*> Unicode U+1F0Ax, Bx, Cx, Dx "f09f82a0" "82b0" "8380" "8390"
01 base-s constant as 4036985504.
01 base-h constant as 4036985520.
01 base-d constant as 4036985728.
01 base-c constant as 4036985744.
01 sym pic x(4) comp-x.
01 symx redefines sym pic x(4).
77 s pic 9.
77 r pic 99.
77 c pic 99.
77 hit pic 9.
77 limiter pic 9(6).
01 spades constant as 1.
01 hearts constant as 2.
01 diamonds constant as 3.
01 clubs constant as 4.
01 players constant as 3.
01 cards-per constant as 5.
01 deal pic 99.
01 player pic 99.
01 show-tally pic zz.
01 show-rank pic z(5).
01 arg pic 9(10).
procedure division.
cards-main.
perform seed
perform initialize-deck
perform shuffle-deck
perform deal-deck
perform display-hands
goback.
*> ********
seed.
accept arg from command-line
if arg not equal 0 then
move random(arg) to c
end-if
.
initialize-deck.
move "spades" to suit-name(spades)
move "hearts" to suit-name(hearts)
move "diamonds" to suit-name(diamonds)
move "clubs" to suit-name(clubs)
perform varying s from 1 by 1 until s > 4
after r from 1 by 1 until r > 13
compute c = (s - 1) * 13 + r
evaluate s
when spades compute sym = base-s + r
when hearts compute sym = base-h + r
when diamonds compute sym = base-d + r
when clubs compute sym = base-c + r
end-evaluate
if r > 11 then compute sym = sym + 1 end-if
move s to suit(c)
move r to rank(c)
move symx to symbol(c)
move zero to slot(c)
move zero to hand(c)
end-perform
.
shuffle-deck.
move zero to limiter
perform until exit
compute c = random() * 52.0 + 1.0
move zero to hit
perform varying tally from 1 by 1 until tally > 52
if slot(tally) equal c then
move 1 to hit
exit perform
end-if
if slot(tally) equal 0 then
if tally < 52 then move 1 to hit end-if
move c to slot(tally)
exit perform
end-if
end-perform
if hit equal zero then exit perform end-if
if limiter > 999999 then
display "too many shuffles, deck invalid" upon syserr
exit perform
end-if
add 1 to limiter
end-perform
sort cards ascending key slot
.
display-card.
>>IF ENGLISH IS DEFINED
move rank(tally) to show-rank
evaluate rank(tally)
when 1 display " ace" with no advancing
when 2 thru 10 display show-rank with no advancing
when 11 display " jack" with no advancing
when 12 display "queen" with no advancing
when 13 display " king" with no advancing
end-evaluate
display " of " suit-name(suit(tally)) with no advancing
>>ELSE
display symbol(tally) with no advancing
>>END-IF
.
display-deck.
perform varying tally from 1 by 1 until tally > 52
move tally to show-tally
display "Card: " show-tally
" currently in hand " hand(tally)
" is " with no advancing
perform display-card
display space
end-perform
.
display-hands.
perform varying player from 1 by 1 until player > players
move player to tally
display "Player " player ": " with no advancing
perform varying deal from 1 by 1 until deal > cards-per
perform display-card
add players to tally
end-perform
display space
end-perform
display "Stock: " with no advancing
subtract players from tally
add 1 to tally
perform varying tally from tally by 1 until tally > 52
perform display-card
>>IF ENGLISH IS DEFINED
display space
>>END-IF
end-perform
display space
.
deal-deck.
display "Dealing " cards-per " cards to " players " players"
move 1 to tally
perform varying deal from 1 by 1 until deal > cards-per
after player from 1 by 1 until player > players
move player to hand(tally)
add 1 to tally
end-perform
.
end program playing-cards.

View file

@ -1,480 +0,0 @@
<#
.Synopsis
Creates a new "Deck" which is a hashtable converted to a dictionary
This is only used for creating the deck, to view/list the deck contents use Get-Deck.
.DESCRIPTION
Casts the string value that the user inputs to the name of the variable that holds the "deck"
Creates a global variable, allowing you to use the name you choose in other functions and allows you to create
multiple decks under different names.
.EXAMPLE
PS C:\WINDOWS\system32> New-Deck
cmdlet New-Deck at command pipeline position 1
Supply values for the following parameters:
YourDeckName: Deck1
PS C:\WINDOWS\system32>
.EXAMPLE
PS C:\WINDOWS\system32> New-Deck -YourDeckName Deck2
PS C:\WINDOWS\system32>
.EXAMPLE
PS C:\WINDOWS\system32> New-Deck -YourDeckName Deck2
PS C:\WINDOWS\system32> New-Deck -YourDeckName Deck3
PS C:\WINDOWS\system32>
#>
function New-Deck
{
[CmdletBinding()]
[OutputType([int])]
Param
(
# Name your Deck, this will be the name of the variable that holds your deck
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$False,
Position=0)]$YourDeckName
)
Begin
{
$Suit = @(' of Hearts', ' of Spades', ' of Diamonds', ' of Clubs')
$Pip = @('Ace', 'King', 'Queen', 'Jack', '10', '9', '8', '7', '6', '5', '4', '3', '2')
#Creates the hash table that will hold the suit and pip variables
$Deck = @{}
#creates counters for the loop below to make 52 total cards with 13 cards per suit
[int]$SuitCounter = 0
[int]$PipCounter = 0
[int]$CardValue = 0
}
Process
{
#Creates the initial deck
do
{
#card2add is the rows in the hashtable
$Card2Add = ($Pip[$PipCounter]+$Suit[$SuitCounter])
#Addes the row to the hashtable
$Deck.Add($CardValue, $Card2Add)
#Used to create the Keys
$CardValue++
#Counts the amount of cards per suit
$PipCounter ++
if ($PipCounter -eq 13)
{
#once reached the suit is changed
$SuitCounter++
#and the per-suit counter is reset
$PipCounter = 0
}
else
{
continue
}
}
#52 cards in a deck
until ($Deck.count -eq 52)
}
End
{
#sets the name of a variable that is unknown
#Then converts the hash table to a dictionary and pipes it to the Get-Random cmdlet with the arguments to randomize the contents
Set-Variable -Name "$YourDeckName" -Value ($Deck.GetEnumerator() | Get-Random -Count ([int]::MaxValue)) -Scope Global
}
}
<#
.Synopsis
Lists the cards in your selected deck
.DESCRIPTION
Contains a Try-Catch-Finally block in case the deck requested has not been created
.EXAMPLE
PS C:\WINDOWS\system32> Get-Deck -YourDeckName deck1
8 of Clubs
5 of Hearts
--Shortened--
King of Clubs
Jack of Diamonds
PS C:\WINDOWS\system32>
.EXAMPLE
PS C:\WINDOWS\system32> Get-Deck -YourDeckName deck2
deck2 does not exist...
Creating Deck deck2...
Ace of Spades
10 of Hearts
--Shortened--
5 of Clubs
4 of Clubs
PS C:\WINDOWS\system32>
.EXAMPLE
PS C:\WINDOWS\system32> deck deck2
Ace of Spades
10 of Hearts
--Shortened--
4 of Spades
6 of Spades
Queen of Spades
PS C:\WINDOWS\system32>
#>
function Get-Deck
{
[CmdletBinding()]
[Alias('Deck')]
[OutputType([int])]
Param
(
#Brings the Vairiable in from Get-Deck
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]$YourDeckName
)
Begin
{
}
Process
{
# Will return a terminal error if the deck has not been created
try
{
$temp = Get-Variable -name "$YourDeckName" -ValueOnly -ErrorAction stop
}
catch
{
Write-Host
Write-Host "$YourDeckName does not exist..."
Write-Host "Creating Deck $YourDeckName..."
New-Deck -YourDeckName $YourDeckName
$temp = Get-Variable -name "$YourDeckName" -ValueOnly
}
finally
{
$temp | select Value | ft -HideTableHeaders
}
}
End
{
Write-Verbose "End of show-deck function"
}
}
<#
.Synopsis
Shuffles a deck of your selection with Get-Random
.DESCRIPTION
This function can be used to Shuffle any deck that has been created.
This can be used on a deck that has less than 52 cards
Contains a Try-Catch-Finally block in case the deck requested has not been created
Does NOT output the value of the deck being shuffled (You wouldn't look at the cards you shuffled, would you?)
.EXAMPLE
PS C:\WINDOWS\system32> Shuffle-Deck -YourDeckName Deck1
Your Deck was shuffled
PS C:\WINDOWS\system32>
.EXAMPLE
PS C:\WINDOWS\system32> Shuffle NotMadeYet
NotMadeYet does not exist...
Creating and shuffling NotMadeYet...
Your Deck was shuffled
PS C:\WINDOWS\system32>
#>
function Shuffle-Deck
{
[CmdletBinding()]
[Alias('Shuffle')]
[OutputType([int])]
Param
(
#The Deck you want to shuffle
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]$YourDeckName)
Begin
{
Write-Verbose 'Shuffles your deck with Get-Random'
}
Process
{
# Will return a missing variable error if the deck has net been created
try
{
#These two commands could be on one line using the pipeline, but look cleaner on two
$temp1 = Get-Variable -name "$YourDeckName" -ValueOnly -ErrorAction stop
$temp1 = $temp1 | Get-Random -Count ([int]::MaxValue)
}
catch
{
Write-Host
Write-Host "$YourDeckName does not exist..."
Write-Host "Creating and shuffling $YourDeckName..."
New-Deck -YourDeckName $YourDeckName
$temp1 = Get-Variable -name "$YourDeckName" -ValueOnly
$temp1 = $temp1 | Get-Random -Count ([int]::MaxValue)
}
finally
{
#Gets the actual value of variable $YourDeckName from the New-Deck function and uses that string value
#to set the variables name
Set-Variable -Name "$YourDeckName" -value ($temp1) -Scope Global
}
}
End
{
Write-Host "Your Deck was shuffled"
}
}
<#
.Synopsis
Creates a new "Hand" which is a hashtable converted to a dictionary
This is only used for creating the hand, to view/list the deck contents use Get-Hand.
.DESCRIPTION
Casts the string value that the user inputs to the name of the variable that holds the "hand"
Creates a global variable, allowing you to use the name you choose in other functions and allows you to create
multiple hands under different names.
.EXAMPLE
PS C:\WINDOWS\system32> New-Hand -YourHandName JohnDoe
PS C:\WINDOWS\system32>
.EXAMPLE
PS C:\WINDOWS\system32> New-Hand JaneDoe
PS C:\WINDOWS\system32>
>
#>
function New-Hand
{
[CmdletBinding()]
[OutputType([int])]
Param
(
# Name your Deck, this will be the name of the variable that holds your deck
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$False,
Position=0)]$YourHandName
)
Begin
{
$Hand = @{}
}
Process
{
}
End
{
Set-Variable -Name "$YourHandName" -Value ($Hand.GetEnumerator()) -Scope Global
}
}
<#
.Synopsis
Lists the cards in the selected Hand
.DESCRIPTION
Contains a Try-Catch-Finally block in case the hand requested has not been created
.EXAMPLE
#create a new hand
PS C:\WINDOWS\system32> New-Hand -YourHandName Hand1
PS C:\WINDOWS\system32> Get-Hand -YourHandName Hand1
Hand1's hand contains cards, they are...
PS C:\WINDOWS\system32>
#This hand is empty
.EXAMPLE
PS C:\WINDOWS\system32> Get-Hand -YourHandName Hand2
Hand2 does not exist...
Creating Hand Hand2...
Hand2's hand contains cards, they are...
PS C:\WINDOWS\system32>
.EXAMPLE
PS C:\WINDOWS\system32> hand hand3
hand3's hand contains 4 cards, they are...
5 of Spades
4 of Spades
6 of Spades
Queen of Diamonds
#>
function Get-Hand
{
[CmdletBinding()]
[Alias('Hand')]
[OutputType([int])]
Param
(
#Brings the Vairiable in from Get-Deck
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]$YourHandName
)
Begin
{
}
Process
{
# Will return a missing variable error if the deck has net been created
try
{
$temp = Get-Variable -name "$YourHandName" -ValueOnly -ErrorAction stop
}
catch
{
Write-Host
Write-Host "$YourHandName does not exist..."
Write-Host "Creating Hand $YourHandName..."
New-Hand -YourHandName $YourHandName
$temp = Get-Variable -name "$YourHandName" -ValueOnly
}
finally
{
$count = $temp.count
Write-Host "$YourHandName's hand contains $count cards, they are..."
$temp | select Value | ft -HideTableHeaders
}
}
End
{
Write-Verbose "End of show-deck function"
}
}
<#
.Synopsis
Draws/returns cards
.DESCRIPTION
Draws/returns cards from your chosen deck , to your chosen hand
Can be used without creating a deck or hand first
.EXAMPLE
PS C:\WINDOWS\system32> DrawFrom-Deck -YourDeckName Deck1 -YourHandName test1 -HowManyCardsToDraw 10
PS C:\WINDOWS\system32>
.EXAMPLE
DrawFrom-Deck -YourDeckName Deck2 -YourHandName test2 -HowManyCardsToDraw 10
Deck2 does not exist...
Creating Deck Deck2...
test2 does not exist...
Creating Hand test2...
test2's hand contains cards, they are...
.EXAMPLE
PS C:\WINDOWS\system32> draw -YourDeckName deck1 -YourHandName test1 -HowManyCardsToDraw 5
#>
function Draw-Deck
{
[CmdletBinding()]
[Alias('Draw')]
[OutputType([int])]
Param
(
# The Deck in which you want to draw cards out of
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]$YourDeckName,
#The hand in which you want to draw cards to
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]$YourHandName,
#Quanity of cards being drawn
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]$HowManyCardsToDraw
)
Begin
{
Write-Verbose "Draws a chosen amount of cards from the chosen deck"
#try-catch-finally blocks so the user does not have to use New-Deck and New-Hand beforehand.
try
{
$temp = Get-Variable -name "$YourDeckName" -ValueOnly -ErrorAction Stop
}
catch
{
Get-Deck -YourDeckName $YourDeckName
$temp = Get-Variable -name "$YourDeckName" -ValueOnly -ErrorAction Stop
}
finally
{
Write-Host
}
try
{
$temp2 = Get-Variable -name "$YourHandName" -ValueOnly -ErrorAction Stop
}
catch
{
Get-Hand -YourHandName $YourHandName
$temp2 = Get-Variable -name "$YourHandName" -ValueOnly -ErrorAction Stop
}
finally
{
Write-Host
}
}
Process
{
Write-Host "you drew $HowManyCardsToDraw cards, they are..."
$handValues = Get-Variable -name "$YourDeckName" -ValueOnly
$handValues = $handValues[0..(($HowManyCardsToDraw -1))] | select value | ft -HideTableHeaders
$handValues
}
End
{
#sets the new values for the deck and the hand selected
Set-Variable -Name "$YourDeckName" -value ($temp[$HowManyCardsToDraw..($temp.count)]) -Scope Global
Set-Variable -Name "$YourHandName" -value ($temp2 + $handValues) -Scope Global
}
}

View file

@ -1,66 +0,0 @@
class playingcard
dim suit
dim pips
end class
class carddeck
private suitnames
private pipnames
private cardno
private deck(52)
private nTop
sub class_initialize
dim suit
dim pips
suitnames = split("H,D,C,S",",")
pipnames = split("A,2,3,4,5,6,7,8,9,10,J,Q,K",",")
cardno = 0
for suit = 1 to 4
for pips = 1 to 13
set deck(cardno) = new playingcard
deck(cardno).suit = suitnames(suit-1)
deck(cardno).pips = pipnames(pips-1)
cardno = cardno + 1
next
next
nTop = 0
end sub
public sub showdeck
dim a
redim a(51-nTop)
for i = nTop to 51
a(i) = deck(i).pips & deck(i).suit
next
wscript.echo join( a, ", ")
end sub
public sub shuffle
dim r
randomize timer
for i = nTop to 51
r = int( rnd * ( 52 - nTop ) )
if r <> i then
objswap deck(i),deck(r)
end if
next
end sub
public function deal()
set deal = deck( nTop )
nTop = nTop + 1
end function
public property get cardsRemaining
cardsRemaining = 52 - nTop
end property
private sub objswap( a, b )
dim tmp
set tmp = a
set a = b
set b = tmp
end sub
end class

View file

@ -1,17 +0,0 @@
dim pack
set pack = new carddeck
wscript.echo "--before shuffle"
pack.showdeck
pack.shuffle
wscript.echo "--after shuffle"
pack.showdeck
dim card
for i = 1 to 52
set card = pack.deal
next
wscript.echo "--dealt a card, it's the", card.pips, "of", card.suit
wscript.echo "--", pack.cardsRemaining, "cards remaining"
if pack.cardsRemaining <> 0 then
pack.showdeck
end if