changelog shortlog tags changeset files file revisions raw

Annotate bin/Data Structures: The Card Game

changeset 378: 751d42400a9e
parent:a1c4ba7f2fe0
author: Gregor (codu.org)
date: Mon Dec 07 02:40:30 2009 +0000 (2 years ago)
permissions: -rwxr-xr-x
description: medit/bin/Data Structures: The Card Game chebang=#!/usr/bin/env .wiki cont=This is a card game, created by Gregor Richards and Harrison Metzger. It is absurdly complicated.

== The data structures

=== Deck
The game is played with two standard 52-card decks.

=== Queue
In the center of the table is a queue. The queue has a maximum of five cards, and moves in a predetermined direction. The stack of cards is placed at the beginning of the queue to indicate its direction. The cards in the queue are face-up.

=== Stacks
Each player has a stack. The stack is face-up in front of the player.

=== Hands
Each player has a five-card hand.

=== Arrays
Each player has three arrays. The objective of the game is to get all three arrays to have every value (2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K) in order. The lists may start with any value, but must loop back 'round to one less than that value.

== Setup

At the beginning of the game, the deck is placed to one side. All five cards of the queue are set out, as are a single card for each stack, and each player's five-card hand.

== Gameplay

The game is a turn based game. Each players turn can be divided up into phases.

=== Phase 1 (Play)
During this phase, the player can use any card from their hand, either of the 2 stacks, or the head of the queue to place the next card in sequence on one of his arrays. An array can only be started from a card in the player's hand. Should an array become complete on a card move, the array is turned upside down (so all cards are now face down) and will be shuffled back into the deck in phase 3.

Any time the player uses all 5 cards in their hand, they are allowed to redraw all 5 cards. Likewise, should all 5 cards in the queue be used, it is refilled from the deck.

Alternatively, should the player be unable to play any card at the beginning of phase 1 (this is verified by showing all cards in the hand to the opponent), they may choose to discard 4 out of the 5 cards in their hand. This ends phase 1.

=== Phase 2 (Discards)
Phase 2 begins by discarding the head of the queue. The player removes the head of the queue and places it on the discard pile.

The player then must place one of their cards on their stack.

Should the player have any cards in their hand and the queue not be full, they can optionally put cards from their hand into the end of the queue.

=== Phase 3 (Replenish)

Should any arrays be closed, they, along with the discard pile, are shuffled back into the deck.

At this phase should the queue be less than 5 cards, it is replenished by drawing from the deck.

Also, the player's hand is replenished to 5 cards.

An invariant is that on the beginning of each player's turn, both players have 5 cards in their hand and the queue is filled with 5 cards.

Gregor@347 1
#!/usr/bin/env .wiki
Gregor@347 2
This is a card game, created by Gregor Richards and Harrison Metzger. It is absurdly complicated.
Gregor@347 3
Gregor@347 4
== The data structures
Gregor@347 5
Gregor@347 6
=== Deck
Gregor@347 7
The game is played with two standard 52-card decks.
Gregor@347 8
Gregor@347 9
=== Queue
Gregor@347 10
In the center of the table is a queue. The queue has a maximum of five cards, and moves in a predetermined direction. The stack of cards is placed at the beginning of the queue to indicate its direction. The cards in the queue are face-up.
Gregor@347 11
Gregor@347 12
=== Stacks
Gregor@347 13
Each player has a stack. The stack is face-up in front of the player.
Gregor@347 14
Gregor@347 15
=== Hands
Gregor@347 16
Each player has a five-card hand.
Gregor@347 17
harrisonmetz@363 18
=== Arrays
harrisonmetz@363 19
Each player has three arrays. The objective of the game is to get all three arrays to have every value (2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K) in order. The lists may start with any value, but must loop back 'round to one less than that value.
Gregor@347 20
Gregor@347 21
== Setup
Gregor@347 22
Gregor@347 23
At the beginning of the game, the deck is placed to one side. All five cards of the queue are set out, as are a single card for each stack, and each player's five-card hand.
Gregor@347 24
Gregor@347 25
== Gameplay
Gregor@347 26
harrisonmetz@363 27
The game is a turn based game. Each players turn can be divided up into phases.
harrisonmetz@363 28
Gregor@378 29
=== Phase 1 (Play)
Gregor@378 30
During this phase, the player can use any card from their hand, either of the 2 stacks, or the head of the queue to place the next card in sequence on one of his arrays. An array can only be started from a card in the player's hand. Should an array become complete on a card move, the array is turned upside down (so all cards are now face down) and will be shuffled back into the deck in phase 3.
harrisonmetz@363 31
Gregor@378 32
Any time the player uses all 5 cards in their hand, they are allowed to redraw all 5 cards. Likewise, should all 5 cards in the queue be used, it is refilled from the deck.
harrisonmetz@363 33
Gregor@378 34
Alternatively, should the player be unable to play any card at the beginning of phase 1 (this is verified by showing all cards in the hand to the opponent), they may choose to discard 4 out of the 5 cards in their hand. This ends phase 1.
harrisonmetz@368 35
harrisonmetz@363 36
=== Phase 2 (Discards)
Gregor@378 37
Phase 2 begins by discarding the head of the queue. The player removes the head of the queue and places it on the discard pile.
harrisonmetz@363 38
Gregor@378 39
The player then must place one of their cards on their stack.
harrisonmetz@363 40
Gregor@378 41
Should the player have any cards in their hand and the queue not be full, they can optionally put cards from their hand into the end of the queue.
harrisonmetz@363 42
harrisonmetz@363 43
=== Phase 3 (Replenish)
harrisonmetz@363 44
Gregor@378 45
Should any arrays be closed, they, along with the discard pile, are shuffled back into the deck.
harrisonmetz@367 46
harrisonmetz@363 47
At this phase should the queue be less than 5 cards, it is replenished by drawing from the deck.
harrisonmetz@363 48
Gregor@378 49
Also, the player's hand is replenished to 5 cards.
harrisonmetz@363 50
Gregor@378 51
An invariant is that on the beginning of each player's turn, both players have 5 cards in their hand and the queue is filled with 5 cards.