Previous: Shuffling the Deck, Up: Operations on Stacks [Contents][Index]
Now every player has the same shuffled deck s
and nobody knows in which
order the 52 cards are stacked. Therefore you can simply use any drawing
strategy to obtain a players hand. For example, look at the following code that
draws two cards from s
for each player.
TMCG_Stack<VTMF_Card> hand[5]; for (size_t i = 0; i < 5; i++) { VTMF_Card c1, c2; s.pop(c1), s.pop(c2); hand[i].push(c1), hand[i].push(c2); } |
Further, probably you want disclose the card types to the corresponding
player. Consider the code fragment for the player P_j: Every player
receives the necessary information from the other players and she computes the
card types of her hand hand[j]
. Finally, these types are stored
together with the masked cards in the open stack private_hand
.
TMCG_OpenStack<VTMF_Card> private_hand; for (size_t i = 0; i < 5; i++) { if (i == j) { for (size_t k = 0; k < hand[j].size(); k++) { tmcg->TMCG_SelfCardSecret(hand[j][k], vtmf); for (size_t i2 = 0; i2 < 5; i2++) { if (i2 == j) continue; if (!tmcg->TMCG_VerifyCardSecret(hand[j][k], vtmf, in_stream[i2], out_stream[i2])) std::cerr << "Verification failed!" << std::endl; } private_hand.push(tmcg->TMCG_TypeOfCard(hand[j][k], vtmf), hand[j][k]); } } else { for (size_t k = 0; k < hand[i].size(); k++) { tmcg->TMCG_ProveCardSecret(hand[i][k], vtmf, in_stream[i], out_stream[i]); } } } |
The example can be modified in a straightforward way to publicly disclose a
card from a players hand or from the remaining stack s
, i.e. to lay
down the card face-up on the table.