README ¶
Tarot card shuffle draw
This program generates and shuffles a tarot deck. It then prompts the user to select the number of cards to draw from the deck, and displays those cards to the user. The program uses structs to represent the cards in the deck, and maps and slices to hold the names and suits of the cards. It also uses the crypto/rand and github.com/manifoldco/promptui packages to generate random numbers and create prompts for the user, respectively.
This application was built with heavy input from an Artificial intelligence ('AI') - ChatGPT. The above paragraph was written by the AI as were most of the comments in the code.
The human input:
- Initial input of a half-written application, determining:
- Topic (obviously!)
- Choice of computing language
Decisions to:
- use PromptUI (drop down menus)
- use crypto/rand*
- include "of" for Minor Arcana readout only
- offer choice of deck (Major; Minor; Full)*
- advise number of cards available and present default number of cards to draw
- prevent calling more cards to draw than are available
- offer choice of using reversed cards*
- tweaking/debugging/testing
Some of these decisions have a major impact on the design:
Choice of deck
There are lots of card shuffling programs out there. Most are based around a regular 52-card deck of playing cards but a full Tarot deck has 78 cards:
Minor Arcana:
4 suits, each with ten number cards and 4 court cards
Major Arcana:
22 Cards
Sometimes readings are conducted with the full deck, sometimes with only the Major Arcana. I haven't come across readings with only the Minor Arcana myself, but here you may choose from either the Major or Minor Arcanas only or a full deck containing both.
Offer choice of using reversed cards
Unlike regular playing cards, tarot cards have a specific 'Up' and 'Down'. Some readers like to include use of 'reversed' meanings for cards, some use only the 'upright' interpretations. This application offers the choice of both- essentially an additional shuffle in a second dimension.
Use of crypto/rand
Most Golang cards applications optimise for speed/ efficiency and use math/rand
. This application only uses crypto/rand
. The AI describes the difference:
math/rand is a package in Go that provides a pseudo-random number generator (PRNG) for generating random numbers in a program. The numbers generated by math/rand are not truly random, but are generated using a deterministic algorithm that produces a sequence of random-like numbers. This means that the same sequence of numbers will be produced each time the program is run, unless the program seed is changed.
It is typical to use a 'seed' value of the current time to generate a non-repeating sequence when using math/rand
.
crypto/rand, on the other hand, is a package in Go that provides a cryptographically secure PRNG for generating random numbers. This means that the numbers generated by crypto/rand are truly random and are generated using a source of randomness that is difficult, if not impossible, to predict or reproduce. This makes crypto/rand suitable for use in cryptographic applications where the randomness of the generated numbers is important for security. Because the numbers generated by crypto/rand are truly random, the sequence of numbers generated by the PRNG will be different each time the program is run, even without changing the seed.
Tests
Subsequently I added some unit tests generated with ChatGPT. These cover a subset of the code for reasons I have written about more extensively at my website. Currently coverage is reported as:
go test -cover
PASS
coverage: 26.3% of statements
ok github.com/joshuamkite/tarot-card-shuffle-draw 0.003s
Subsequently
Added interactive license display feature to comply with GPL 3.0; made minor changes to output formatting; added build script
Notes on use
There is no installer or app store and the offered binaries aren't signed- see notes below
Notes for Windows users
The app is not signed (sorry, not interested in paying and going through the aggravation for a one-off hobby project). As a result you may see security notices about that. You can either accept this or build the app yourself locally.
If you try 'clicking on the exe' you will see that the application exits immediately on completion. As described here you can address this by either:
Start the command prompt and then just drag the .exe file into the cmd window. The full path to the file will be pasted into the prompt and you just have to press enter.
or
Create a shortcut with the
/K
argument, e.g.
cmd /K "C:\SomeFolder\MyApp.exe"
Notes for Mac Users
If you aren't sure what to download, arm64
is equivalent to 'Apple Silicon'.
This app isn't 'notarized' with Apple (sorry, not interested in paying and going through the aggravation for a one-off hobby project). You can either build it yourself locally or context click to confirm that you want to run the downloaded binary
Note for desktop Linux users
I doubt anyone will need this but, yes, you will have to call this from a shell - most terminal emulators allow drag and drop, similar to Windows as described above
Documentation ¶
There is no documentation for this package.