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

Жарков Валерий

Шрифт:

execAssem =

System.Reflection.Assembly.GetExecutingAssembly;

}

/// <summary>

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

/// </summary>

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

/// <summary>

/// Picture information for each card in a suit

/// </summary>

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

/// <summary>

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

/// in the number sequence

/// </summary>

static private string[] suitNames =

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

/// <summary>

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

/// in a suit

/// </summary>

static private string[] valueNames =

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

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

/// <summary>

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

/// according to BlackJack rules

/// </summary>

public int BlackJackScore

{

get

{

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

}

}

/// <summary>

/// Returns true if the card is a picture

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

/// </summary>

public bool IsPicture

{

get

{

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

}

}

/// <summary>

/// Returns text of the suit of this card

/// </summary>

public string Suit

{

get

{

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

}

}

/// <summary>

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

/// </summary>

public string ValueName

{

get

{

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

}

}

/// <summary>

/// Returns true if this is a red card

/// </summary>

public bool Red

{

get

{

int suit = (CardNo – 1) / 13;

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

}

}

/// <summary>

/// Returns true if this is a black card

/// </summary>

public bool Black

{

get

{

return !Red;

}

}

/// <summary>

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

/// </summary>

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];

}

}

/// <summary>

/// Constructs a card with a partiuclar number

/// </summary>

/// <param name="cardNo">number of the card

/// in the range 1 to 52</param>

/// <param name="faceUp">true if the card

/// is to be drawn face up</param>

public Card(byte cardNo, bool faceUp)

{

CardNo = cardNo;

FaceUp = faceUp;

}

/// <summary>

/// Constructs a face up card with that number

/// </summary>

/// <param name="cardNo"></param>

public Card(byte cardNo)

: this(cardNo, true)

{

}

/// <summary>

/// String description of the card

/// </summary>

/// <returns>the name and suit of the card</returns>

public override string ToString

{

return ValueName + " of " + Suit;

}

}

/// <summary>

  • Читать дальше
  • 1
  • ...
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • ...

Ебукер (ebooker) – онлайн-библиотека на русском языке. Книги доступны онлайн, без утомительной регистрации. Огромный выбор и удобный дизайн, позволяющий читать без проблем. Добавляйте сайт в закладки! Все произведения загружаются пользователями: если считаете, что ваши авторские права нарушены – используйте форму обратной связи.

Полезные ссылки

  • Моя полка

Контакты

  • chitat.ebooker@gmail.com

Подпишитесь на рассылку: