themax90 Posted July 30, 2005 Posted July 30, 2005 (edited) I just finished a blackjack game! YAY! using my card functions. Below is the attached zip files, one is sectioned for study and editing, another is just the whole script for those who are more single filed. Anyways here is my card systems:expandcollapse popupFunc DeckCreate($ref) IniWrite($deck, "Deck" & $ref, "CS", "52") $i = 52 While $i <> 0 IniWrite($deck, "Deck" & $ref, $i, "0") $i = $i - 1 WEnd While IniRead($deck, "Deck" & $ref, "CS", -1) <> 0 $a = Random(1, 13, 1) $b = Random(1, 4, 1) $card = $a & ":" & $b $cardcheck = CardCheck($card, $ref) If $cardcheck = 1 Then $spot = IniRead($deck, "Deck" & $ref, "CS", -1) If $spot = -1 Then Error(0) Else IniWrite($deck, "Deck" & $ref, "CS", ($spot - 1)) IniWrite($deck, "Deck" & $ref, $spot, $card) EndIf ElseIf $cardcheck = 0 Then Sleep(1) EndIf WEnd IniWrite($deck, "Deck" & $ref, "CS", "52") EndFunc;==>DeckCreate Func DeckDelete() FileDelete($deck) EndFunc;==>DeckDelete Func CardCheck($card, $ref) $i = 52 While 1 $check = IniRead($deck, "Deck" & $ref, $i, -1) If $check = -1 Then Error(0) ElseIf $check = $card Then Return 0 ExitLoop ElseIf $check = 0 Then Return 1 ExitLoop ElseIf $check <> $card And $check <> 0 And $check <> - 1 Then $i = $i - 1 EndIf WEnd EndFunc;==>CardCheck Func CardDraw($ref) $cardspot = IniRead($deck, "Deck" & $ref, "CS", -1) If $cardspot = -1 Then Error(1) ElseIf $cardspot = 0 Then Return 0 Else[attachmentid=3499] IniWrite($deck, "Deck" & $ref, "CS", ($cardspot - 1)) $drawcard = IniRead($deck, "Deck" & $ref, $cardspot, -1) IniWrite($deck, "Deck" & $ref, $cardspot, "0") If $drawcard = -1 Then Error(1) Else Return $drawcard IniWrite("Deck.ini", "Deck" & $ref, $cardspot, "0") EndIf EndIf EndFunc;==>CardDraw Func CardInterpret($card) $card = StringSplit($card, ":") $card[1] = StringReplace($card[1], "4", "Four") $card[1] = StringReplace($card[1], "5", "Five") $card[1] = StringReplace($card[1], "6", "Six") $card[1] = StringReplace($card[1], "7", "Seven") $card[1] = StringReplace($card[1], "8", "Eight") $card[1] = StringReplace($card[1], "9", "Nine") $card[1] = StringReplace($card[1], "10", "Ten") $card[1] = StringReplace($card[1], "11", "Jack") $card[1] = StringReplace($card[1], "12", "Queen") $card[1] = StringReplace($card[1], "13", "King") $card[1] = StringReplace($card[1], "3", "Three") $card[1] = StringReplace($card[1], "2", "Duce") $card[1] = StringReplace($card[1], "1", "Ace") $card[2] = StringReplace($card[2], "1", " of Hearts") $card[2] = StringReplace($card[2], "2", " of Diamonds") $card[2] = StringReplace($card[2], "3", " of Spades") $card[2] = StringReplace($card[2], "4", " of Clubs") $card = $card[1] & $card[2] Return $card EndFunc;==>CardInterpret Func CardNum($card) $card = StringSplit($card, ":") If $card[1] = "13" Or $card[1] = "12" Or $card[1] = "11" Or $card[1] = "10" Then $newcard = 10 ElseIf $card[1] = "1" Then $newcard = 1 ElseIf $card[1] = "2" Then $newcard = 2 ElseIf $card[1] = "3" Then $newcard = 3 ElseIf $card[1] = "4" Then $newcard = 4 ElseIf $card[1] = "5" Then $newcard = 5 ElseIf $card[1] = "6" Then $newcard = 6 ElseIf $card[1] = "7" Then $newcard = 7 ElseIf $card[1] = "8" Then $newcard = 8 ElseIf $card[1] = "9" Then $newcard = 9 EndIf Return $newcard EndFunc;==>CardNum Func CardAce($card, $gui, $bot) If $bot = 1 Then If $card = 1 Then $total = Random(1, 2, 1) If $total = 1 Then $total = 11 ElseIf $total = 2 Then $total = 1 EndIf Else $total = $card EndIf Return $total ElseIf $bot = 0 Then If $card = 1 Then $acewin = GUICreate("Ace", 137, 102, (@DesktopWidth - 137) / 2, (@DesktopHeight - 102) / 2) $label = GUICtrlCreateLabel("A ace has been drawn, would you like it to be worth 11 or 1?", 10, 10, 120, 30, 0x1000 + 1) $1 = GUICtrlCreateCheckbox("One", 10, 50, 50, 20) $11 = GUICtrlCreateCheckbox("Eleven", 10, 80, 50, 20) $ok = GUICtrlCreateButton("Ok", 80, 60, 50, 30) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $ok Then If GUICtrlRead($1) = 1 And GUICtrlRead($11) <>1 Then $total = 1 GUIDelete($acewin) GUISetState($gui, @SW_SHOW) Return $total ExitLoop ElseIf GUICtrlRead($11) = 1 And GUICtrlRead($1) <> 1 Then $total = 11 GUIDelete($acewin) GUISetState($gui, @SW_SHOW) Return $total ExitLoop Else MsgBox(0, "Error", "Either both are selected or none, please choose one.") EndIf EndIf WEnd Else $total = $card Return $total EndIf EndIf EndFunc;==>CardAce Func TwentyOneTest($total) If $total = 21 Then Return 1 Else Return $total EndIf EndFunc;==>TwentyOneTest Now for a demonstration use this script ; Deck INI Location $deck = @tempdir & "\Deck.ini" ; Reference Password $ref = 1 SplashTextOn("", "Creating Deck........", "150", "20", "-1", "-1", 1, "", "", "") DeckCreate($ref) SplashOff() While 1 $card = CardDraw($ref) If $card = 0 Then MsgBox(0, "Deck Empty", "Deck Depleted.") Exit Else MsgBox(0, "Card Draw", "Your card is : " & CardInterpret($card)) EndIf WEnd ; Include card functions and errors in reference to card functions #include "Include\cards.au3" #include "Include\errors.au3" You can get cards.au3 and errors.au3 from the sectioned blackjack zip . I hope u all like, took me a week or so. Just for fun! Edited December 3, 2005 by AutoIt Smith
LxP Posted July 31, 2005 Posted July 31, 2005 This is great, AutoIt Smith! Just one small thing I noticed -- I'm pretty sure that the dealer is obliged to hit until he has a higher score than the player. (I won 17 to 16 just then.)
Moderators SmOke_N Posted July 31, 2005 Moderators Posted July 31, 2005 (edited) @Valik - Most Casino's make the dealer hit on 16 but not all. Found this out the hard way once. @AutoIt Smith - Nice Job: I'm currently working on a Heads Up Texas Hold'em game. P.S. Misspelled word "Duce" = "Deuce". Edit: Had to fix my own misspelled word! Edited July 31, 2005 by ronsrules Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
HardCopy Posted July 31, 2005 Posted July 31, 2005 @Valik - Most Casino's make the dealer hit on 16 but not all. Found this out the hard way once.@AutoIt Smith - Nice Job: I'm currently working on a Heads Up Texas Hold'em game.P.S. Misspelled word "Duce" = "Deuce".Edit: Had to fix my own misspelled word! <{POST_SNAPBACK}>headsup holdem eh!will you be including a random shuffle generatoras seen in online cardrooms?If so would you please remove the code which guarantees your opponent a 2 outer on the river.TYVMHardcopy Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad
Baku Posted July 31, 2005 Posted July 31, 2005 dang you thats what i was working at =( very good job, maybe u'd also use that idea sum1 got with the card bmps.
layer Posted July 31, 2005 Posted July 31, 2005 Please make texas holdem... I love that game.... Well any kind of poker is good for me. But I love blackjack too FootbaG
erifash Posted July 31, 2005 Posted July 31, 2005 I noticed that you write to an INI. You could use my _INITable() functions to improve your script speed by writing to a string and not a file. If you wanted to save the information to a file all you would have to use is _INITableSave() and _INITableLoad().I really like your game! Great work! My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver
kabalarian Posted August 6, 2005 Posted August 6, 2005 i just played this and when u deplete ur bank roll u get like 5 errors and Bank Depleted popup 3 or 4 times
themax90 Posted August 11, 2005 Author Posted August 11, 2005 @kabalarian I have no idea whats wrong with your processor but it works on everywhere i've tried. I've been gone for a week or so and havn't been able to read feedback. Also I rewrote the payout becauseti tripled incom, just change the all $win's to $betamount's and you'll be safe, o and Kaba, could u be betting like 1000 or NOT EVENC REATING a bank roll. I just hope my card functions and and server emulations(to come) will help you all @erifash Dang you I was working on that also!!! but you beat me to it, hehe Yah thisprogram was just a quick boredom fix, afew misspellings and a output error, and AI was sloopy to get the job done. Thanks all! AutoIt Smith Be on the lookout for moreprograms
themax90 Posted August 12, 2005 Author Posted August 12, 2005 (edited) Blackjack 1.2 is here, Fixed! Duce is renamed to Deuce and all payout, subductive glitches are fixed. Blackjack normal(playing w/ source) Blackjack sectioned to be fixed soon.... If anyone wants to give feed back it's cool. AutoIt Smith Edited August 12, 2005 by AutoIt Smith
Zach Posted September 24, 2005 Posted September 24, 2005 Can I play you in blackjack, you be the dealer, for a thousand a hand In blackjack advantage the house has over the player is very minimal, like 49 to 51 if the player plays correctly. If a player knows both of the dealer cards, the odds flip around enough that you could never lose playing black jack - just a gues, but I would say the odds would now be 75-80 percent in the players advantage. (You need to hide one of the dealers cards)
Valuater Posted October 10, 2005 Posted October 10, 2005 i downloaded your BlackJack game from your signature. The bank gave me 1000 credits... i bet 2000 and i won ( i only had 1000 ) then i had 3000 crdits and bet 5000.. it allowed me to play.. but i lost... then i got this 8)
DiskAI Posted November 8, 2005 Posted November 8, 2005 here some gif i got from the net (can't remember from where) hope it would make your game better btw if i start off with 1000000 bet and win ... guess what .... i got 1000000 plus 800 : card_img.rar i think
themax90 Posted November 8, 2005 Author Posted November 8, 2005 (edited) Yes i know, I never wanted to rework on it. It's open to who ever as long as you put my name on it somewhere. The projects been closed for, ummm.... 3 months, so yah But thanks New Link... Edited August 24, 2006 by AutoIt Smith
Kickassjoe Posted August 11, 2006 Posted August 11, 2006 i might work on it a little tomorrow... dont have autoit3 on this computer... and i would need to get beta... What goes around comes around... Payback's a bitch.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now