Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / text blackjack

Author
Message
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 3rd Jun 2009 21:11 Edited at: 3rd Jun 2009 21:13
When I run this code card1$(top,left number) is always j or a

whats wrong with it?Does it do the same thing when you run it?
(sorry for not REMing)


If at first you don't succeed-Pause-Go to last checkpoint
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 3rd Jun 2009 21:20
Try adding at the beginning RANDOMIZE TIMER() . That should make sure that every time it runs it will be much more random.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 3rd Jun 2009 21:36 Edited at: 3rd Jun 2009 21:39
O that was'nt the problem. I made it where it changes the value over and over.heres the fix it's more code tho.ty



If at first you don't succeed-Pause-Go to last checkpoint
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 3rd Jun 2009 22:35
Wow....that is a LOT of IF-THENS and a REALLY LOT of GOTOS!

There is probably a way you could restructure that to make it a lot easier.

For instance, with all of the:
If Card1$="1"...Card1$="2"....3,4,5,6 etc etc. Could probably be revised by a single if-then.

For all of the number to card conversions, it can be done rather simply.

You could load up a string array that contains all of the Card values. This is good because you can figure it out in one line for all cards, like this:

card1$=values$(val(card1$))

See? It would work for all cards. I would also suggest storing all of the cards in the hand into one array, for ease of reference. Rather than card1$ you could have card$(1), and once again, a clear benefit is you can reference the data with a numeric value, rather than an exact variable name.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Jun 2009 02:18
BN2 is right about storing the hands in an array, that way you could have as many players as you wanted and wouldnt have to write any more code!

Getting the value of the card can be made much simpler.
This is a great opportunity for a Function. Why do I say a function and not a subroutine? Well, both are used when you want to do the same thing multiple times (i.e. check the value of the cards), but function wins out because we want to check different cards multiple times.
You could do this with a sub but you'd have to make sure all your variables were named correctly, so if you wanted to use it in the future or give it to someone else it would be quite fiddly to get it working again; whereas a function can be slotted into any program.

This is also a good opportunity to use the select command. I'm going to slightly re-order your deck for this and put Ace at 1.
When you generate the card values they should remain as numbers so you can evaluate them more easily.

I've run out of space, function next...

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Jun 2009 02:25


There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 4th Jun 2009 02:48
Quote: "case default : card$=str$(n) : endcase"


Clever, didn't think about that one. You could alter it with Ace being 13 and just have it be str$(n+1) so that 1=2. That way it would preserve the order of "strength" for the cards, since Aces beat kings in most games, so a mathematical function could be used to determine the value of the hand accurately, rather than needing special cases for aces.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 4th Jun 2009 04:53 Edited at: 4th Jun 2009 08:52
Wow,you guys really like to complicate things.Thanks for the help

I did'nt think about useing arrays thats a good idea.But I've

already done some code.

EDIT

Well,I tryed useing arrays and this is the best I could do.



EDIT
heres the layout of my code I don't got some rules yet or the AI



If at first you don't succeed-Pause-Go to last checkpoint
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 4th Jun 2009 23:26 Edited at: 4th Jun 2009 23:57
I have finished everything except the rules and a thing where it ask

if you want to play.Comment if you have a comment.

Also,ways to win-
get 21
get 5 cards without going over 21
if dealer busts then you win
there is dealer advantage in this game(just like james bond blackjack on ps1)

EDIT

i had to add
if bet<0
goto deal
endif
so you can't bet a neg number lol


If at first you don't succeed-Pause-Go to last checkpoint
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 5th Jun 2009 00:03 Edited at: 5th Jun 2009 00:06
Hey nice, i played for like 20 minutes

but if you make gold equal some random HUMUNGOS number then bet huge somehow it goes to a huge negative number(i wanted to keep play so i hit escape>typed Gold = 1000000000>> hit enter>> vwala i have tons of money)

not important as i doubt anyone would get that high(without cheating )

And if you for instance have 25 gold and put in to bet 12.5 then it takes off 12 but if you win then it comes out as 37? odd.

New Site! Check it out \/
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 5th Jun 2009 00:30 Edited at: 5th Jun 2009 00:41
thanks,
Quote: "And if you for instance have 25 gold and put in to bet 12.5 then it takes off 12 but if you win then it comes out as 37? odd.
"

thats because it takes 12.5 from 25 which is 12.5,rounding it off to
12(I guess) and when you win it takes your bet*2 and adds that to your gold so 12+12.5*2=37.

Quote: "but if you make gold equal some random HUMUNGOS number then bet huge somehow it goes to a huge negative number "


ya, I noticed that,I don't know?

If at first you don't succeed-Pause-Go to last checkpoint
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 5th Jun 2009 01:20
Oh i geuss that makes sense lol


Hmmm Weird about the negative thing...

New Site! Check it out \/
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 5th Jun 2009 01:50
Quote: "Quote: "but if you make gold equal some random HUMUNGOS number then bet huge somehow it goes to a huge negative number ""


My guess is that the number breaks the number barrier, where it is so big that the byte that controls the sign gets changed.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 5th Jun 2009 01:55
ya bn2 is right try this
print 1234567891+1234567891
thanks bn2

If at first you don't succeed-Pause-Go to last checkpoint

Login to post a reply

Server time is: 2025-05-15 05:51:14
Your offset time is: 2025-05-15 05:51:14