Справочник Жаркова по проектированию и программированию искусственного интеллекта. Том 8: Программирование на Visual C# искусственного интеллекта. Издание 2. Продолжение 1 - страница 33

Шрифт
Интервал


}

///

/// Scores for each of the cards in a suit

///

static private byte[] scores =

new byte[] {       11,      //ace

 2,3,4,5,6,7,8,9,10, //spot cards

 10,10,10}; //jack, queen, king

///

/// Picture information for each card in a suit

///

static private bool[] isPicture =

new bool[] {       false,      //ace

 false,false,false,false,false,false,

false,false,false, //spot cards

 true,true,true}; //jack, queen, king

///

/// Names of the suits, in the order that of the suits

/// in the number sequence

///

static private string[] suitNames =

new string[] { "club", "diamond", "heart", "spade" };

///

/// Names of individual cards, in the order of the cards

/// in a suit

///

static private string[] valueNames =

new string[] {"Ace", "Deuce","Three","Four","Five","Six",

"Seven","Eight","Nine","Ten", "Jack","Queen","King" };

///

/// Returns the value in points of a given card,

/// according to BlackJack rules

///

public int BlackJackScore

{

get

{

return scores[(CardNo – 1) % 13];

}

}

///

/// Returns true if the card is a picture

/// (i.e. jack, queen or king)

///

public bool IsPicture

{

get

{

return isPicture[(CardNo – 1) % 13];

}

}

///

/// Returns text of the suit of this card

///

public string Suit

{

get

{

return suitNames[(CardNo – 1) / 13];

}

}

///

/// Returns the text of the value of this card

///

public string ValueName

{

get

{

return valueNames[(CardNo – 1) % 13];

}

}

///

/// Returns true if this is a red card

///

public bool Red

{

get

{

int suit = (CardNo – 1) / 13;

return ((suit == 1) || (suit == 2));

}

}

///

/// Returns true if this is a black card

///

public bool Black

{

get

{

return !Red;

}

}

///

/// Returns an image which can be used to draw this card

///

public Image CardImage

{

get

{

int dispNo = CardNo;

if (!FaceUp)

{

dispNo = 0;

}

if (cardImages[dispNo] == null)

{

cardImages[dispNo] = new Bitmap(

execAssem.GetManifestResourceStream(

@"PocketJack.images." + dispNo + @".gif"));

}

return cardImages[dispNo];

}

}

///

/// Constructs a card with a partiuclar number

///

/// number of the card

/// in the range 1 to 52

/// true if the card