二十一点代码帮助!! [英] Blackjack Code Help!!

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

问题描述

您好。


我已经制作了二十一点代码并需要一些帮助。它似乎总体上有效,但有一些地方需要整理,我有点坚持它所以想知道我是否能得到一些帮助? (将非常感激)


我需要帮助的东西是:


- 停止程序回到代码(你会知道你玩的时候我的意思。

- 如何在里面添加重新运行的代码和

- 我如何将ace计为1和11(在我的代码中,它只计算为11)

- 如何添加不同的套件,如钻石,俱乐部,心形和黑桃,因为我的程序只显示数字而不是套房用它

- 我怎样才能展示每轮结束后玩的牌

- 我如何随意洗牌

- 我如何追踪已经处理过的牌每张卡只发一次


我的代码在这里附上。


预付谢谢



附加文件
< a href =https://bytes.com/attachments/attachment/1720d1231417666/tutti_blackjack_code-2-.zip> tutti_blackjack_code(2).zip (1.4 KB,90 views)

解决方案

我们最近有一个二十一点线程来解决你的一些顾虑。

(1.5 KB,84 views)


我会设置你的while循环,如下所示:

展开 | 选择 | Wrap | 行号

Hi.

I have made a blackjack code and need a some help on it. It seems to work overall but there are a few bits here and there that need sorting out, and I''m kinda stuck on it so was wondering if I could get some help? (Would be HUGELY appreciated )

The things I need help are on:

- Stopping the program going back to the code (you will know what I mean when you play it)
- How to add the re-run code in it and where
- How I can count the ace as 1 and 11 (as in my code it only counts as 11)
- How I can add the different suites like diamonds, clubs, hearts and spades, because my program only displays the numbers not the suites with it
- How I can show the cards played after each round
- How I can shuffle the cards
- How I can track what cards have been dealt so that each card is only dealt once

My code is here is attached.

Thanks in advance

Attached Files
tutti_blackjack_code (2).zip (1.4 KB, 90 views)

解决方案

We have a recent blackjack thread that addresses some of your concerns.

blackjack game

Three classes are defined: Card (defines suits and rank, including the Ace), Deck (creates a deck of cards, self.cards contains the Card objects), and BJ. BJ() is the game itself and has methods deal_hand(), hit_hand(), score_hand_BJ() (this is where the Ace is counted as 1 or 11 automatically), play() (the game loop), and play_over() (the game loop is summarized and results are displayed).

Your code has other problems. For example, selecting "H" for hit does not actually give the player a hit because you are using "H" instead of "h" in the if statement. The computer''s hand should be automatically hit if below the threshold, but is only hit if the user elects to receive one. There is no check to see if the player busts. You can determine the current score using sum() instead of a for loop since your list only contains integers.

Maybe you can get other ideas to improve your code from the thread mentioned above.


@bvdet
Hi.

Firslty I would like to thank you for spending your time to check out my code, appreciate it buddy :). Secondly, the error with the H/Hit there was, I have slightly fixed and changed and you will see the difference in the new updated code I will upload.

On another note, I have looked at the thread, and even used to the code and played it, and it is very good. But I just do not know how to adapt some of the code from there to mine. One of the main errors with my code is that it keeps going back to the code itself when playing a game (did you come across that?). Do you know how I can fix that? And would you know how I could fix any of the other issues/problems I posted in my first post? I am not that experienced in Python, I know more in VB, so yeah I do not know alot in Python. My friend helped me create this code as I struggled, and he has gone on a vacation so he cannot help me out, which sucks. If you could help me out, I would be very grateful and would appreciate it alot.

Thanks once again.

- ThaRealneSS

Attached Files
realness_updated_blackjack.zip (1.5 KB, 84 views)


I would setup your while loop something like this:

Expand|Select|Wrap|Line Numbers


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

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