Python BlackJack [英] Python BlackJack

查看:344
本文介绍了Python BlackJack的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个计算BlackJack中手牌总和的函数,但是,我无法为Face卡分配值。我正在使用python 2.5的卡模块。此外,例如,随机选择的卡片以8C的格式返回,因此我被赋予等级和套装,这也使得难以评估手牌。我是蟒蛇新手,所以如果有人对我如何使这个功能有任何有用的提示,请告诉我!

I am trying to develop a function that calculates the sum of a hand in BlackJack, however, I am having trouble assigning values to the Face cards. I am using the cards module for python 2.5. Also, the randomly selected cards are returned in the format ''8C'' for example, so I am given the rank and the suit, which also makes it difficult to evaluate the hand. I''m a python newbie, so if anyone has any helpful hints on how I can make this function work, please let me know!

推荐答案


我正在尝试开发一个计算BlackJack中手牌总和的函数,但是,我无法为Face卡分配值。我正在使用python 2.5的卡模块。此外,例如,随机选择的卡片以8C的格式返回,因此我被赋予等级和套装,这也使得难以评估手牌。我是一个蟒蛇新手,所以如果有人对我如何使这个功能有任何有用的提示,请告诉我!
I am trying to develop a function that calculates the sum of a hand in BlackJack, however, I am having trouble assigning values to the Face cards. I am using the cards module for python 2.5. Also, the randomly selected cards are returned in the format ''8C'' for example, so I am given the rank and the suit, which also makes it difficult to evaluate the hand. I''m a python newbie, so if anyone has any helpful hints on how I can make this function work, please let me know!



对于第一部分,我们需要某种示例代码。在您编辑回复时阅读页面右侧的REPLY GUIDELINES以了解如何使用CODE标签。


对于第二部分,这里有一个建议:

For the first part, we''ll need some kind of example code. Read the REPLY GUIDELINES on the right hand side of the page while your are editing your reply to learn how to use CODE tags.

For the second part, here''s a suggestion:

展开 | 选择 | Wrap | 行号



对于第一部分,我们需要某种示例代码。在您编辑回复时阅读页面右侧的REPLY GUIDELINES以了解如何使用CODE标签。


对于第二部分,这里有一个建议:
For the first part, we''ll need some kind of example code. Read the REPLY GUIDELINES on the right hand side of the page while your are editing your reply to learn how to use CODE tags.

For the second part, here''s a suggestion:
展开 | 选择 | Wrap | 行号



感谢您的建议,我已经想出如何给Face卡值10,但现在我的问题在于我无法获得手中所有牌的整数值。例如,如果我的手由[''KC'',''9H'']组成,我只能获得手中第一张牌的整数值。这是我的代码,如果有任何进一步的建议,我将非常感谢他们!
Thank you for your suggestion, I have figured out how to give the Face cards a value of 10, however now my problem lies in the fact that I can''t get an integer value for all of the cards in a hand. For example, if i have a hand consisting of [''KC'', ''9H''], I can only get the integer value of the first card in the hand. Here is my code, and if there are any further suggestions I would greatly appreciate them!



这应该有效(未经测试):

This should work (untested):

展开 | 选择 | 换行 | 行号


这篇关于Python BlackJack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆