Author |
Message |
DVL_IAC
|
Posted: 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 Razz](http://compsci.ca/v3/images/smiles/icon_razz.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Armageddon
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
ssr
![](http://siruisite.port5.com/ssr.jpg)
|
Posted: 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 Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
DVL_IAC
|
Posted: 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 Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif)
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 Confused](images/smiles/icon_confused.gif) |
|
|
|
|
![](images/spacer.gif) |
DVL_IAC
|
Posted: 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 Razz](http://compsci.ca/v3/images/smiles/icon_razz.gif) |
|
|
|
|
![](images/spacer.gif) |
RaPsCaLLioN
![](http://www.woodus.com/den/gallery/graphics/dw2nes/animated/dw2-hero.gif)
|
Posted: 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'. |
|
|
|
|
![](images/spacer.gif) |
DVL_IAC
|
Posted: 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
thanks i think i got it working right now
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? |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sun Mar 27, 2005 7:39 am Post subject: (No subject) |
|
|
16. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
ssr
![](http://siruisite.port5.com/ssr.jpg)
|
Posted: 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 Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif)
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 Confused](images/smiles/icon_confused.gif)
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 |
|
|
|
|
![](images/spacer.gif) |
person
|
Posted: 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) |
|
|
|
|
![](images/spacer.gif) |
DVL_IAC
|
Posted: Sun Mar 27, 2005 5:02 pm Post subject: (No subject) |
|
|
yay I'm pretty shure i got the program working perfactly 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... |
|
|
|
|
![](images/spacer.gif) |
ssr
![](http://siruisite.port5.com/ssr.jpg)
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
person
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
DVL_IAC
|
|
|
|
![](images/spacer.gif) |
ssr
![](http://siruisite.port5.com/ssr.jpg)
|
Posted: 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 ^^ |
|
|
|
|
![](images/spacer.gif) |
|