hiddenGem

Tarot Cards

May 26th, 2021 (edited)
941
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.70 KB | None | 0 0
  1. %% Tarot Card Draws
  2.  
  3. %{
  4. Using the card trick as a template for this script
  5. comments for the good of the order are at the end as always :)
  6. %}
  7.  
  8.  
  9. %% Tarot Card Draws
  10. clc, clear
  11. format long
  12.  
  13. % Minor Arcana
  14. Names = {'Ace of ','Two of ','Three of ', 'Four of ', 'Five of ', ...
  15.         'Six of ','Seven of ', 'Eight of ', 'Nine of ', 'Ten of ', ...
  16.         'Page of ','Knight of ', 'Queen of ', 'King of '};
  17. Suits = {'Cups', 'Pentacles', 'Wands', 'Swords'};
  18.  
  19. q = 1;  % Random Number
  20. while q < 57    % Creates set values of cards
  21.     for column = 1:4
  22.         for row = 1:14    
  23.             Set_minor(q) = strcat(Names(row), Suits(column));      
  24.             q = q + 1;
  25.             row = row + 1;
  26.         end
  27.     end
  28. end
  29.  
  30. Set_minor = reshape(Set_minor, 1,56);   % reshaping the minor array
  31.  
  32. % Major Arcana
  33. Set_major = {'The Fool','The Magician','The High Priestess','The Empress',...
  34.             'The Emperor', 'The Hierophant','The Lovers','The Chariot',...
  35.             'The Strength','The Hermit','Wheel of Fortune','The Justice'...
  36.             'The Hanged Man', 'Death','Temperance','The Devil','The Tower'...
  37.             'The Star','The Moon','The Sun','Judgement','The World'};
  38. Set_major = reshape(Set_major, 1, 22);  % reshaping the major array
  39.  
  40. z = input('Reading with the Minor Arcana? (y/n)\n', 's');
  41. switch z    % Choosing deck with or without minor arcana
  42.     case char('y')      % with minor
  43.        Set = [Set_major, Set_minor];
  44.     case char('n')      % without minor
  45.        Set = Set_major;
  46. end
  47.  
  48. zz = input('Allow reverse cards? (y/n)\n','s');
  49.  
  50. % Draws Cards
  51. ran_cards = randperm(length(Set),6);
  52. for i = 1:length(ran_cards)     % Giving random number card values
  53.     game_cards(i) = Set(ran_cards(i));
  54.     if strcmp(zz, 'y')  % Allowing cards to be reversed
  55.         a = round(rand);    % Gives 0 or 1 randomly
  56.         switch a  
  57.             case 0  % Normal card
  58.             case 1  % Reversed card
  59.                 game_cards(i) = strcat(game_cards(i), ' Reversed');
  60.         end
  61.     end
  62. end
  63.  
  64. reshape(game_cards, 2, 3)   % Reshapes the cards
  65.  
  66. %{
  67. RUNNING INFORMATION
  68.     requires a 'y' or 'n' input twice
  69.         1. for playing with or without the minor
  70.         arcana line 40
  71.  
  72.         2. for using reversed cards or not
  73.         line 48    
  74.  
  75. SIDE NOTES
  76.     Draws six cards for the reading
  77.         Just edited this to be on one line
  78.         ran_cards = randperm(length(Set),6);
  79.         line 43 just change the number
  80.  
  81.     I would like to do reading formats in a
  82.     future update
  83.         The current format is
  84.                 cards 1 2 3
  85.                 cards 4 5 6
  86. EDIT HISTORY
  87.     6 24 2021
  88.         added reversed format
  89.        
  90.         changed the draw format so that
  91.         the number of cards picked in all
  92.         scenarios can be adjusted by one line
  93.             see side notes above
  94. %}
Add Comment
Please, Sign In to add comment