Computer Science Canada

Turing Black Jack help

Author:  DVL_IAC [ Sat Mar 26, 2005 8:45 pm ]
Post subject:  Turing Black Jack help

I'm making a small black jack program in turing and i have it all done except i dont know how i would go about making it say the winner is whos ever closer to 21 without going over 21... like i wanna do
code:
if comp closer to 21 but not over 21 then
put "The computer wins"
elsif user closer to 21 but not over 21 then
put "You win"


idk what the code would be for "if comp closer to 21 but not over 21" and "if user closer to 21 but not over 21" Razz

Author:  Armageddon [ Sat Mar 26, 2005 9:47 pm ]
Post subject: 

I'm no expert but maybe you should try something like this

If User < Comp <= 21
Comp wins
Else if User <= 21
User Wins
Else
They both Bust

Obviously this is just pseudo-code.

Author:  ssr [ Sat Mar 26, 2005 9:59 pm ]
Post subject: 

yep thats the right idea
but be careful
u have to do something like
if comp > 21 then
put "comp lost"
return
end if
if user > 21 then
put "user lost"
else
if user > comp then
put "user win"
elsif user < comp then
put "user lost"
else put "tied"
end if
end if
lala wish u do a good job, I think u can simplify the code btw Very Happy

Author:  DVL_IAC [ Sat Mar 26, 2005 11:02 pm ]
Post subject: 

ssr wrote:
yep thats the right idea
but be careful
u have to do something like
if comp > 21 then
put "comp lost"
return
end if
if user > 21 then
put "user lost"
else
if user > comp then
put "user win"
elsif user < comp then
put "user lost"
else put "tied"
end if
end if
lala wish u do a good job, I think u can simplify the code btw Very Happy


hmm if the user gets 25 then the comp gets 22 using that code then it says "user looses" because it was higher then 21 then it says "user wins" because the user had a higher number then the comp... Confused

Author:  DVL_IAC [ Sat Mar 26, 2005 11:12 pm ]
Post subject: 

Armageddon wrote:
I'm no expert but maybe you should try something like this

If User < Comp <= 21
Comp wins
Else if User <= 21
User Wins
Else
They both Bust

Obviously this is just pseudo-code.


hmm tried this too
code:

if usertotal < comptotal <= 21 then
        put "The Computer Wins"
    elsif usertotal <= 21 then
        put "You Win!"
    else
        put "Tie!"


but i get an error on this line
code:
if usertotal < comptotal <= 21 then

that says "Operands of comparison operators must be of same type" Razz

Author:  RaPsCaLLioN [ Sat Mar 26, 2005 11:34 pm ]
Post subject: 

I believe like so...

code:
if usertotal < comptotal and comptotal <= 21 then


You can't do it all as 1 string comparison. Use 2 separate w/ an "and".

Either that or make sure both variables are stored as 'int'.

Author:  DVL_IAC [ Sun Mar 27, 2005 12:04 am ]
Post subject: 

RaPsCaLLioN wrote:
I believe like so...

code:
if usertotal < comptotal and comptotal <= 21 then


You can't do it all as 1 string comparison. Use 2 separate w/ an "and".

Either that or make sure both variables are stored as 'int'.


yay i did
code:
if usertotal < comptotal and
comptotal <= 21 then
and it worked Very Happy

thanks i think i got it working right now Very Happy


hmm what number should i make the computer stop asking to be hit at? at first i thought 18 that way it'd keep drawing until it got 18 or higher total but then i thought thats a bit high because if the comp had 17 it'd draw again when most ppl wouldnt then i thought of 16 but thought that might be too low because lots of ppl if they had 16 might take a chance and draw again so then i thought 17 but im not shure... what would be a good number for the comp to stop at?

Author:  Cervantes [ Sun Mar 27, 2005 7:39 am ]
Post subject: 

16.

Author:  ssr [ Sun Mar 27, 2005 8:55 am ]
Post subject: 

DVL_IAC wrote:
ssr wrote:
yep thats the right idea
but be careful
u have to do something like
if comp > 21 then
put "comp lost"
end if
if user > 21 then
put "user lost"
else
if user > comp then
put "user win"
elsif user < comp then
put "user lost"
else put "tied"
end if
end if
lala wish u do a good job, I think u can simplify the code btw Very Happy


hmm if the user gets 25 then the comp gets 22 using that code then it says "user looses" because it was higher then 21 then it says "user wins" because the user had a higher number then the comp... Confused

no it wont because of it first check the comp if it got a higher number, and there is a else statement int eh user's code only when both the user and the computer are smaller or equal to 21 will the program compare each other/

EDIT: to make the program work perfectly delete the return

Author:  person [ Sun Mar 27, 2005 11:04 am ]
Post subject: 

ssr: the dealer and the player cant both loose

DVL_IAC: it is the rules to make the dealer stop at 16 (just thought to explain to u wat Cervantes meant)

Author:  DVL_IAC [ Sun Mar 27, 2005 5:02 pm ]
Post subject: 

yay I'm pretty shure i got the program working perfactly Very Happy it plays different sounds when different things happen now im just wondering if i should have a midi playing in the background or just keep it as it is with just sounds and no mus...

Author:  ssr [ Sun Mar 27, 2005 6:42 pm ]
Post subject: 

person wrote:
ssr: the dealer and the player cant both loose

DVL_IAC: it is the rules to make the dealer stop at 16 (just thought to explain to u wat Cervantes meant)


GJ DVL_IAC
anyway
why cant they both lose because the dealer has to stop at 16?
then they cant get 22 and a 25 right, 'caue both of them would be over 21 adn they both loses
anyway then put return in teh code.
but since u r finished
gj

Author:  person [ Sun Mar 27, 2005 7:14 pm ]
Post subject: 

ssr: in the event that the dealer and the player both busts...the player wins

Author:  DVL_IAC [ Sun Mar 27, 2005 9:53 pm ]
Post subject: 

http://www.compsci.ca/v2/viewtopic.php?p=79117#79117 Very Happy

Author:  ssr [ Sun Mar 27, 2005 11:07 pm ]
Post subject: 

person wrote:
ssr: in the event that the dealer and the player both busts...the player wins

u r a blackjack expert arnt u ^^

Author:  Mr. T [ Sun Mar 27, 2005 11:29 pm ]
Post subject: 

ssr wrote:
person wrote:
ssr: in the event that the dealer and the player both busts...the player wins

u r a blackjack expert arnt u ^^

actually, no. the player goes through his hand first. so if the player busts, then the game is over and the dealer doesnt even have to go.

Author:  Naveg [ Sun Mar 27, 2005 11:30 pm ]
Post subject: 

but if they tie the dealer wins right?

Author:  Mr. T [ Sun Mar 27, 2005 11:32 pm ]
Post subject: 

yes.

Author:  person [ Mon Mar 28, 2005 11:40 am ]
Post subject: 

There r 2 variations:

http://www.gameroom2000.com/free-casino-games/blackjack-rules.htm

http://www.casinoscompared.co.uk/blackjack_rules.asp

Author:  Naveg [ Mon Mar 28, 2005 5:45 pm ]
Post subject: 

interesting, thanks for the info

Author:  person [ Tue Mar 29, 2005 3:55 pm ]
Post subject: 

http://www.compsci.ca/v2/viewtopic.php?p=79335#79335

(i kno its messy and not complete but....)

Author:  Naveg [ Wed Mar 30, 2005 12:15 am ]
Post subject: 

it also doesnt work....

Author:  person [ Wed Mar 30, 2005 3:00 pm ]
Post subject: 

Quote:
it also doesnt work....


LOL!! i forgot the pics

Author:  DVL_IAC [ Fri Apr 08, 2005 6:18 pm ]
Post subject: 

I made an updated version of my Black Jack. You can get it >Here<!


: