 |
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
Chambahs Guest
Offline
|
Posted: Fri Jan 28, 2005 12:36 am Post subject: <py> Blackjack |
 |
|
|
|
#BlackJack by Chambahs
#1-25-05
from asss import *
chat = get_interface(I_CHAT)
stats = get_interface(I_STATS)
def c_deal(cmd, params, p, targ):
points = stats.GetStat(p, STAT_KILL_POINTS, INTERVAL_RESET)+ stats.GetStat(p, STAT_FLAG_POINTS, INTERVAL_RESET)
chat.SendMessage(p, "1000 Points have been betted. - Points Left: %d" % points -1000)
stats.GetStat(p, % points - 1000)
A = 11
K = 10
Q = 10
J = 10
A+J = 21
random_card1 = random(["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"])
random_card2 = random(["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"])
random_card3 = random(["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"])
random_card4 = random(["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"])
card_total = random_card1 + random_card2
card_total2 = random_card3 + random_card4
chat.SendMessage(p, "Your cards are:" random_card1, random.card2 " (Total = " card_total1 ")"
chat.SendMessage(p, "Dealers cards are:" random.card3, random.card4 " (Total = " card_total2 ")"
if card_total < 21:
chat.SendMessage(p, "Hit or stand? (Type ?hit or ?stand)")
else:
chat.SendMessage(p, "You got 21!")
stats.GetStat(p. % points +2500)
if random_card1 + random_card2 == A+J:
chat.SendMessage(p, "BLACKJACK!")
stats.GetStat(p, % points + 3000)
def c_hit(cmd, params, p, targ):
hit_card1 = random(["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"])
hit_card2 = random(["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"])
hit_card3 = random(["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"])
hit_card4 = random(["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"])
hit_card5 = random(["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"])
hit_card6 = random(["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"])
card_total3 = card_total + hit_card1
card_total4 = card_total + hit_card1 + hit_card2
card_total5 = card_total + hit_card1 + hit_card2 + hit_card3
deal_total1 = card_total2 + hit_card4
deal_total2 = card_total2 + hit_card4 + hit_card5
deal_total3 = card_total2 + hit_card4 + hit_card5 + hit_card6
chat.SendMessage(p, "Hit!")
chat.SendMessage(p, "Current Cards = " random_card1, random_card2, hit_card1 " (Total = " random_card1+random_card2+hit_card1 ")"
if card_total3 >= 22:
chat.SendMessage(p, "Bust! You lose, Please play again")
else:
chat.SendMessage(p, "Hit again or stand? (Type ?hit2 or ?stand)")
def c_hit2(cmd, params, p, targ):
chat.SendMessage(p, "Hit!")
chat.SendMessage(p, "Current Cards = " random_card1, random_card2, hit_card1, hit_card2 " (Total = " random_card1+random_card2+hit_card1+hit_card2 ")"
if card_total4 >= 22:
chat.SendMessage(p, "Bust! You lose, Please play again")
else:
chat.SendMessage(p, "Hit again or stand? (Type ?hit3 or ?stand)")
def C_hit3(cmd, params, p, targ):
chat.SendMessage(p, "Hit!")
chat.SendMessage(p, "Current Cards = " random_card1, random_card2, hit_card1, hit_card2, hit_card3 " (Total = " random_card1+random_card2+hit_card1+hit_card2+hit_card3 ")"
if card_total5 >= 22:
chat.SendMessage(p, "Bust! You lose, Please play Again")
else:
chat.SendMessage(p, "5 Card Stand! You Win!!")
stats.GetStat(p, %points + 2000)
def c_stand(cmd, params, p, targ):
chat.SendMessage(p, "Stay it is.")
if card_total2 <= 17:
chat.SendMessage(p, "The Dealer Hits! - Current Cards = " random_card2, random_card3, hit_card4 " (Total = " deal_total1 ")"
if deal_total1 <= 17:
chat.SendMessage(p, "The Dealer Hits Again! - Current Cards = " random_card2, random_card3, hit_card4, hit_card5 " (Total = " deal_total2 ")"
if deal_total2 <= 17:
chat.SendMessage(p, "The Dealer Hits Again! - Current Cards = " random_card2, random_card3, hit_card4, hit_card5, hit_card6 " (Total = " deal_total3 ")"
if deal_total3 <= 21:
chat.SendMessage(p, "Dealer has 5 Card Stand! You lose, Please Play Again")
else:
chat.SendMessage(p, "Dealer is Bust! You Win!")
elif deal_total2 <= 18 and >= 21:
chat.SendMessage(p, "The dealer stands with" deal_total2)
elif deal_total2 == 21:
chat.SendMessage(p, "Dealer has 21!")
elif deal_total1 == A+J:
chat.SendMessage(p, "Dealer has Blackjack!")
else:
chat.SendMessage(p, "Dealer is Bust! You Win!")
elif deal_total1 <= 18 and >= 21:
chat.SendMessage(p, "The dealer stands with" deal_total1)
elif deal_total1 == 21:
chat.SendMessage(p, "Dealer has 21!")
elif deal_total1 == A+J:
chat.SendMessage(p, "Dealer has Blackjack!")
else:
chat.SendMessage(p, "Dealer is Bust! You Win!")
elif card_total2 <= 18 and >= 21:
chat.SendMessage(p, "The dealer stands with" card_total2)
elif card_total2 == 21:
chat.SendMessage(p, "Dealer has 21!")
elif card_total2 == A+J:
chat.SendMessage(p, "Dealer has Blackjack!")
else:
chat.SendMessage(p, "Dealer is Bust! You Win!")
|
Hey, my FIRST try at making a REAL module, written in Python, not sure if im "allowed" to post it, so moderators, feel free to delete, also hence the word try, this module doesnt work, i got very frustrated, and gave up, so anyone who would like to fix it up, go for it i quit lol, btw, its a game of blackjack if you didnt notice
blackjack.py - 4.94 KB
File downloaded or viewed 83 time(s)
|
|
Back to top |
|
 |
Chambahs Guest
Offline
|
Posted: Fri Jan 28, 2005 12:37 am Post subject: |
 |
|
|
|
sry for the double post, but...
"Hey, my FIRST try at making a REAL module, written in C, not sure if im "allowed" to post it, "
i meant written in python
|
|
Back to top |
|
 |
Assassin2684 Server Help Squatter

Age:34 Gender: Joined: Jul 27 2004 Posts: 990 Location: Florida Offline
|
Posted: Fri Jan 28, 2005 8:19 am Post subject: |
 |
|
|
|
Not bad chambahs notbad.
|
|
Back to top |
|
 |
Solo Ace Yeah, I'm in touch with reality...we correspond from time to time.

Age:37 Gender: Joined: Feb 06 2004 Posts: 2583 Location: The Netherlands Offline
|
Posted: Fri Jan 28, 2005 9:40 am Post subject: |
 |
|
|
|
Haha, how can you judge this Assassin, without knowing what it is?
Indeed, it looks more like Python than C to me.
|
|
Back to top |
|
 |
i88gerbils Oldbie Server Help

Gender: Joined: Dec 13 2002 Posts: 423 Location: OH Offline
|
Posted: Fri Jan 28, 2005 10:33 am Post subject: |
 |
|
|
|
Yeah, I was about to say, "that doesn't look like C..." _________________ Oldbie Server Help
|
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
 |
i88gerbils Oldbie Server Help

Gender: Joined: Dec 13 2002 Posts: 423 Location: OH Offline
|
Posted: Fri Jan 28, 2005 1:13 pm Post subject: |
 |
|
|
|
Actually, reason losing out is that i actually did say it outloud as I was reading the post, and then wrote "about to say it" using "say" as a meaning for "write". Stupid vernacular.
|
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Fri Jan 28, 2005 3:18 pm Post subject: |
 |
|
|
|
One thing I noticed... 1000 credits have been betted? _________________
|
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Jan 28, 2005 3:48 pm Post subject: |
 |
|
|
|
If you want to play blackjack, don't play subspace. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
|
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Fri Jan 28, 2005 3:58 pm Post subject: |
 |
|
|
|
random(["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]) |
I didn't know there was a 1 card?
|
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Fri Jan 28, 2005 5:07 pm Post subject: |
 |
|
|
|
Shows what you know, Bak.
Oh, wait, never mind. I'll go hide now.  _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me
|
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:41 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Fri Jan 28, 2005 6:36 pm Post subject: |
 |
|
|
|
Bak wrote: | random(["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]) |
I didn't know there was a 1 card? |
I fixed that part at least in his code. One thing I do have to mention, is that you have no handling for the fact that an Ace counts as either 11 or 1. Would suck if you hit on an eleven, and busted.
A way I dealt with this problem when I made blackjack for my Casio calculator, was to keep a HadAce variable. Once you draw an ace, count it as only 1, and set your HadAce variable to be true. Then when calculating your current score, if <= 11 and HadAce, add ten.
|
|
Back to top |
|
 |
SamHughes Server Help Squatter

Joined: Jun 30 2004 Posts: 251 Location: Greenwich Offline
|
Posted: Fri Jan 28, 2005 6:48 pm Post subject: |
 |
|
|
|
This program doesn't take into account the lower probability of drawing a second card that's the same as the first (and higher probabilities for other values)
|
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Fri Jan 28, 2005 6:53 pm Post subject: |
 |
|
|
|
The code isn't designed well... but it is your first try so I woun't be overly critical of that.
Last edited by Bak on Sat Jan 29, 2005 11:03 am, edited 1 time in total |
|
Back to top |
|
 |
Solo Ace Yeah, I'm in touch with reality...we correspond from time to time.

Age:37 Gender: Joined: Feb 06 2004 Posts: 2583 Location: The Netherlands Offline
|
Posted: Fri Jan 28, 2005 7:10 pm Post subject: |
 |
|
|
|
Bak wrote: | The code isn't designed well... but it is your first try so I woun't be overly critical of that. |
Me thought the same.
|
|
Back to top |
|
 |
Chambahs Guest
Offline
|
Posted: Fri Jan 28, 2005 7:46 pm Post subject: |
 |
|
|
|
(runs, hides, and cries)
|
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Sat Jan 29, 2005 2:24 am Post subject: |
 |
|
|
|
it doesn't work because you never keep track of the player's cards... you need per player data indicating the current player's hand and the total number of aces
|
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:41 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Sat Jan 29, 2005 6:41 am Post subject: |
 |
|
|
|
Bak wrote: | You need to account for multiple aces. |
Why?
Think about this before you answer.
|
|
Back to top |
|
 |
Chambahs Guest
Offline
|
Posted: Sat Jan 29, 2005 9:22 am Post subject: |
 |
|
|
|
well, the 1 would be the ace...just rename it to A1 or something and name the A to A11 and boom you got 2 aces, so i did the right thing, w00t
|
|
Back to top |
|
 |
i88gerbils Oldbie Server Help

Gender: Joined: Dec 13 2002 Posts: 423 Location: OH Offline
|
Posted: Sat Jan 29, 2005 4:29 pm Post subject: |
 |
|
|
|
Not quite. Remember, an ace can be either AND at the player's choice (well, you can guess and if the total 11+x > 21, then the ace becomes a 1).
Keep at it though!
|
|
Back to top |
|
 |
Chambahs Guest
Offline
|
Posted: Sat Jan 29, 2005 5:15 pm Post subject: |
 |
|
|
|
lol im not adding to this code, i gave up a long time ago, i leave it to the experts
|
|
Back to top |
|
 |
Chambahs Guest
Offline
|
Posted: Sat Jan 29, 2005 5:21 pm Post subject: |
 |
|
|
|
sorry for the double post, but i just thought of some code that would sort that out
def pick_a(cmd, params, p, targ):
if random_card == A:
chat.SendMessage(p, "Use ?ace to decide if you want to use the ace as a 1 or 11")
if params == 1:
random_card = 1
elif params == 11:
random_card = 11
cmd1 = add_command("ace". pick_a)
shouldnt that work? also i just wrote that out freehand and off the top of my head, it should work tho..i think, but what do i know, im just a newbie programmer lol
|
|
Back to top |
|
 |
SamHughes Server Help Squatter

Joined: Jun 30 2004 Posts: 251 Location: Greenwich Offline
|
Posted: Sat Jan 29, 2005 9:20 pm Post subject: |
 |
|
|
|
There's no need to make the player actively decide whether to use the ace as a one or an eleven. If having the ace be eleven makes the player go bust, you count the ace as a one. Simple.
|
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 188 page(s) served in previous 5 minutes.
|