Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Turing Black Jack help
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DVL_IAC




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Armageddon




PostPosted: Sat Mar 26, 2005 9:47 pm   Post subject: (No 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.
ssr




PostPosted: Sat Mar 26, 2005 9:59 pm   Post subject: (No 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
DVL_IAC




PostPosted: Sat Mar 26, 2005 11:02 pm   Post subject: (No 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
DVL_IAC




PostPosted: Sat Mar 26, 2005 11:12 pm   Post subject: (No 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
RaPsCaLLioN




PostPosted: Sat Mar 26, 2005 11:34 pm   Post subject: (No 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'.
DVL_IAC




PostPosted: Sun Mar 27, 2005 12:04 am   Post subject: (No 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?
Cervantes




PostPosted: Sun Mar 27, 2005 7:39 am   Post subject: (No subject)

16.
Sponsor
Sponsor
Sponsor
sponsor
ssr




PostPosted: Sun Mar 27, 2005 8:55 am   Post subject: (No 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
person




PostPosted: Sun Mar 27, 2005 11:04 am   Post subject: (No 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)
DVL_IAC




PostPosted: Sun Mar 27, 2005 5:02 pm   Post subject: (No 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...
ssr




PostPosted: Sun Mar 27, 2005 6:42 pm   Post subject: (No 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
person




PostPosted: Sun Mar 27, 2005 7:14 pm   Post subject: (No subject)

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




PostPosted: Sun Mar 27, 2005 9:53 pm   Post subject: (No subject)

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




PostPosted: Sun Mar 27, 2005 11:07 pm   Post subject: (No 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 ^^
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 24 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: