Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
<py> Blackjack

 
Post new topic   Reply to topic Printable version
 View previous topic  afk Post :: Post Windows Restarter Script  View next topic  
Author Message
Chambahs
Guest


Offline

PostPosted: Fri Jan 28, 2005 12:36 am    Post subject: <py> Blackjack Reply to topic Reply with quote

Code: Show/Hide
#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 icon_smile.gif i quit lol, btw, its a game of blackjack if you didnt notice icon_smile.gif




blackjack.py - 4.94 KB
File downloaded or viewed 72 time(s)
Back to top
Chambahs
Guest


Offline

PostPosted: Fri Jan 28, 2005 12:37 am    Post subject: Reply to topic Reply with quote

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 tongue.gif
Back to top
Assassin2684
Server Help Squatter


Age:33
Gender:Not sure
Joined: Jul 27 2004
Posts: 990
Location: Florida
Offline

PostPosted: Fri Jan 28, 2005 8:19 am    Post subject: Reply to topic Reply with quote

Not bad chambahs notbad.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:36
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Fri Jan 28, 2005 9:40 am    Post subject: Reply to topic Reply with quote

Haha, how can you judge this Assassin, without knowing what it is? sa_tongue.gif

Indeed, it looks more like Python than C to me.
Back to top
View users profile Send private message Add User to Ignore List
i88gerbils
Oldbie Server Help


Gender:Gender:Male
Joined: Dec 13 2002
Posts: 423
Location: OH
Offline

PostPosted: Fri Jan 28, 2005 10:33 am    Post subject: Reply to topic Reply with quote

Yeah, I was about to say, "that doesn't look like C..."
_________________
Oldbie Server Help
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website Yahoo Messenger
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Jan 28, 2005 12:10 pm    Post subject: Reply to topic Reply with quote

i88gerbils wrote:
Yeah, I was about to say, "that doesn't look like C..."


and you ended up saying it anyway... that's the voice of reason losing out
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
i88gerbils
Oldbie Server Help


Gender:Gender:Male
Joined: Dec 13 2002
Posts: 423
Location: OH
Offline

PostPosted: Fri Jan 28, 2005 1:13 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email Visit posters website Yahoo Messenger
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Fri Jan 28, 2005 3:18 pm    Post subject: Reply to topic Reply with quote

One thing I noticed... 1000 credits have been betted?
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Fri Jan 28, 2005 3:48 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Jan 28, 2005 3:58 pm    Post subject: Reply to topic Reply with quote

Code: Show/Hide
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
View users profile Send private message Add User to Ignore List AIM Address
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Fri Jan 28, 2005 5:07 pm    Post subject: Reply to topic Reply with quote

Shows what you know, Bak.

Oh, wait, never mind. I'll go hide now. icon_wink.gif
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Fri Jan 28, 2005 6:36 pm    Post subject: Reply to topic Reply with quote

Bak wrote:
Code: Show/Hide
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
View users profile Send private message Add User to Ignore List Send email
SamHughes
Server Help Squatter


Joined: Jun 30 2004
Posts: 251
Location: Greenwich
Offline

PostPosted: Fri Jan 28, 2005 6:48 pm    Post subject: Reply to topic Reply with quote

This program doesn't take into account the lower probability of drawing a second card that's the same as the first tongue.gif (and higher probabilities for other values)
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Jan 28, 2005 6:53 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:36
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Fri Jan 28, 2005 7:10 pm    Post subject: Reply to topic Reply with quote

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. icon_smile.gif
Back to top
View users profile Send private message Add User to Ignore List
Chambahs
Guest


Offline

PostPosted: Fri Jan 28, 2005 7:46 pm    Post subject: Reply to topic Reply with quote

icon_sad.gif (runs, hides, and cries)
Back to top
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sat Jan 29, 2005 2:24 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Sat Jan 29, 2005 6:41 am    Post subject: Reply to topic Reply with quote

Bak wrote:
You need to account for multiple aces.

Why?

Think about this before you answer.
Back to top
View users profile Send private message Add User to Ignore List Send email
Chambahs
Guest


Offline

PostPosted: Sat Jan 29, 2005 9:22 am    Post subject: Reply to topic Reply with quote

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:Gender:Male
Joined: Dec 13 2002
Posts: 423
Location: OH
Offline

PostPosted: Sat Jan 29, 2005 4:29 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email Visit posters website Yahoo Messenger
Chambahs
Guest


Offline

PostPosted: Sat Jan 29, 2005 5:15 pm    Post subject: Reply to topic Reply with quote

lol im not adding to this code, i gave up a long time ago, i leave it to the experts tongue.gif
Back to top
Chambahs
Guest


Offline

PostPosted: Sat Jan 29, 2005 5:21 pm    Post subject: Reply to topic Reply with quote

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

PostPosted: Sat Jan 29, 2005 9:20 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Custom Projects All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 656 page(s) served in previous 5 minutes.

phpBB Created this page in 0.475047 seconds : 50 queries executed (91.7%): GZIP compression disabled