Shuffle
Paradigm(s) | Imperative |
---|---|
Designed by | User:Enoua5 |
Appeared in | 2016 |
Memory system | Cell based |
Dimensions | Two dimensional |
Computational class | Unknown |
Major implementations | Python 3 |
File extension(s) | .deck |
Contents
Introduction
Shuffle was created by User:Enoua5 in November of 2016. It reads instructions from a "deck of cards" by playing the card game War.
Note that .deck files must be encoded as UTF-8
Documentation
Syntax
Valid characters
The Unicode playing cards (U+1F0A1 to U+1F0DF), with the exception of the knight cards encode Shuffle's commands. Cards in this range that are "reserved" are interpreted as jokers. All other characters are comments.
Deck definition
The two decks are separated by two consecutive line-breaks. Everything before the double line-break is Player One's deck. Everything after is Player Two's. If a character is not a command, it is not put into the deck.
The cards are put into the decks in the order they appear in script, with the first cards going on the top.
Cards can be used more than once, and there does not need to be a full deck.
Syntax errors
There are three types of syntax errors in Shuffle.
- not enough decks defined; occurs when there is no double line-break.
- invalid deck split; occurs when there is more than one double line-break
- deck contains no cards; occurs when there is no valid cards in at least one deck
Running
Card meaning
Shuffle takes the suits of the two cards which are played as a command. The commands are as defined in the table bellow. The suit on the left is Player One's card, the suit on top is Player Two's.
X | Spade | Heart | Diamond | Club |
---|---|---|---|---|
Spade | Move pointer to the right. | Move pointer down. | Move pointer up. | Move pointer to the left. |
Heart | If the current cell has a value of zero, interpret the next command as NOP. | Interpret the next n commands as NOP. Where n is the value of Player One's card | Interpret the next command as NOP. | If the current cell has a value of zero, interpret the next n commands as NOP. Where n is the value of Player One's card |
Diamond | Subtract the value of Player One's card from the current cell | Add one onto the current cell | Subtract one from the current cell | Add the value of Player One's card to the current cell |
Club | Get user input in the form of an 8-bit character and save the value to the current cell. | Output the value of the current cell as an int. | Output the value of the current cell as an 8-bit character. | Get user input in the form of an 8-bit unsigned int and save the value to the current cell. |
If a joker is played (and is not interpreted as NOP), the program terminates.
Card values
Card | Value |
---|---|
Joker | 0 |
Ace | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 5 |
6 | 6 |
7 | 7 |
8 | 8 |
9 | 9 |
10 | 10 |
Jack | 11 |
Queen | 12 |
King | 13 |
"Game play"
At the beginning of each round, both players will play the card on the top of their deck. These two cards are then run as instruction. Whichever player has the higher value card gets both of the played cards added to the bottom of their deck with the higher valued card on the bottom. The next round is then played.
Tie breaking
In the event that both players play cards of the same value, each player forms a "stakes" pile. The two players then will add cards from the top of their deck to the bottom of their stakes pile until they have placed three cards each. A player will not add a card to their stakes if it is their last card. The six (three from each player) cards added to the stakes do not have their commands run.
Each then adds one more card to the bottom of their stakes. These last two cards are run. The values of the two most recently placed cards are then compared. Whoever has the higher value card gets the stakes piles added onto the bottom of their own; with the winning stake pile under the losing pile. The next round is then played.
If the cards once again have the same value, then the players repeat the tie-breaking process without clearing the stakes piles. This continues until a winner is decided, or until a player runs out of cards.
End of program
When one of the two players run out of cards, the program terminates.
Example programs
Hello
Prints "Hello" with a trailing new-line
๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐ฎ๐๐ ๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๏ปฟ๐ก๐๐
1 byte cat
Gets a char input, then outputs it
๐๐ ๐ก๐
Quit
Exits the program on startup
๐ ๐
Loop
Loops forever.
Found by reading this paper: http://math.pugetsound.edu/~mspivey/War.pdf
๐พ ๐ฑ๐พ
Truth-machine
I have no life.
๐๐๐ฒ๐พ๐๐ท ๐๐ฑ๐ฎ๐๐พ๐ฑ๐พ