DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T d

⟦b5d6b494d⟧ TextFile

    Length: 2305 (0x901)
    Types: TextFile
    Names: »deal.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Bidding/deal.c« 

TextFile

/* deal.c */
/*
			Bridge Bidder	Version 3.0
			by John Oswalt and Nathan Glasser
			..!sun!megatest!jao (usenet)
			nathan@brokaw.lcs.mit.edu (internet)
			nathan@mit-eddie.uucp (usenet)

			June, 1989
------------------------------------------------------------------------------
Copyright 1988, 1989 by Nathan Glasser and John Oswalt.
You may feel free to distribute this program in its current form.
Please do not remove this copyright information.
*/

#include "bidding.h"

card_compare(pcard1,pcard2)
card *pcard1,*pcard2;
{
    return((pcard1->suit != pcard2->suit) ? (pcard1->suit - pcard2->suit) :
	   (pcard2->rank - pcard1->rank));
}

deal_hands(pdeal)
deal *pdeal;
{
    card *thehand;
    int player,cardsinhand;
    int cardnum;
    int nextcard;
    static vulnerability = 0;
    
    pdeal->num_bids = 0;
    pdeal->bidding_done = 0;
    vulnerability = ((pdeal->vulnerability = vulnerability) + 1) % 4;
    pdeal->opening_lead.rank = pdeal->opening_lead.suit = -1;
    
    for (player = 0; player < 4; player++)
    {
	thehand = pdeal->hands[player];

	if (!hand_setup[player])
    	    for (cardsinhand = 0; cardsinhand < 13; cardsinhand++)
    	    {
    	    	nextcard = random() % (cardsleft--);
    	    	for (cardnum = 0 ; cardsused[cardnum] || --nextcard >=0;
    	    	  cardnum++);
    	    	cardsused[cardnum] = 1;
    	    	thehand[cardsinhand].suit = cardnum / 13;
    	    	thehand[cardsinhand].rank = 2 + (cardnum % 13);
    	    }
	qsort(thehand,13,sizeof(card),card_compare);
    }
}

print_hand(fp,thehand)
FILE *fp;
card *thehand;
{
    int i;
    char bufs[4][80];
    
    format_hand(bufs,thehand);
    for (i = 0; i < 4; i++)
    {
	fputs(bufs[i],fp);
	putc('\n',fp);
    }
}

/* Accepts an array of size four of strings, and formats into it */
format_hand(bufs,thehand)
char (*bufs)[80];
card *thehand;
{
    extern char *suit_strings[];
    static char card_chars[] = "xx23456789TJQKA";
    int suit_num = -1;
    int i;
    static char card_str[3] = " A";
    
    bufs--;
    for (i = 0; i < 13; i++)
    {
	while (thehand[i].suit != suit_num)
	    sprintf(*++bufs,"%8s:  ",suit_strings[++suit_num]);
	card_str[1] = card_chars[thehand[i].rank];
	strcat(*bufs,card_str);
    }
    
    while (suit_num < 3)
	sprintf(*++bufs,"%8s:  ",suit_strings[++suit_num]);
}