Author Topic: Blackjack  (Read 56749 times)

0 Members and 1 Guest are viewing this topic.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Blackjack
« Reply #15 on: June 10, 2019, 08:32:29 pm »
Don't forget about the option to "double-down."

Pecos Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline xra7en

  • Seasoned Forum Regular
  • Posts: 284
    • View Profile
Re: Blackjack
« Reply #16 on: June 10, 2019, 09:29:51 pm »
oops mis-post!
I just like re-writing old DOS book games into modern QB64 code - weird hobby, I know!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #17 on: June 11, 2019, 11:40:36 pm »
Added the Double Down Option and Overhauled the whole game:
Quote
' Fixes since BJ 1on1 wImages.bas 2019-06-09:
' + Fix label: Dealer must hit if es Total is < 17, not 16.
' + I added Double Down (DD) option, not just for Pete's sake.
' So for DD, I read BJ rules according to Hoyle, more fixes to those rules:
' + The 2nd card to Dealer is face down not first.
' + Blackjack pays 3:2 or 1.5 times bet, IF Dealer does not match = "push".
' + If player busts e loses immediately, no push if Dealer also busts.
' + After everyone gets 2 cards, Dealer looks to see if e has BJ, if so, shows it.
' + Splash Screen and introduction.
* BJ wDD 2019-06-11.zip (Filesize: 17.27 KB, Downloads: 251)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #18 on: June 10, 2020, 10:07:51 pm »
I know, I know... This thread is OLD... But I had an impulse to play BJ.

In doing so, I cheated and started with 1,000 chips... Of course, it didn't take me long to amass a decent score... One thing I did notice was that, when my score got over 30k+, my score would show as a negative amount. Would this be a limitation of QB? If so, is there a way to redefine the variable, 'chips'?

Another thing was, whenever I "Bust", the dealer continues and if it busts we "tie", and my bet is restored... Not sure if that is supposed to happen, but there you go...

J
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #19 on: June 10, 2020, 11:36:30 pm »
Hi Johnno,

Dang, I was hoping you were going to tell me you applied some of your asset magic to the game.

Yeah, your score goes negative after 32,000+ because I was not very optimistic Typing the score using Integer instead of _INTEGER64 (look out Donald Trump). ;-))  Easy fix.

And I am generous with fake money er, ah, points, the house is not required to make a profit which is why you don't loose if the dealer busts also.

Think I will try the game again too. :)



« Last Edit: June 10, 2020, 11:37:40 pm by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #20 on: June 11, 2020, 12:06:01 am »
Actually, I was thinking about using more graphics.... but my knowledge of QB64's graphics commands is not very good and I am not 100% sure that I can do it... lol

I have been looking for a Basic blackjack program (not with line numbers and goto's...) that follow the basic rules of two handed BJ with play again option.... There seems to be plenty of examples in python, java, javascript etc. but I know only a little of python and nothing about the others, so conversion, for me at least, is out of reach...

I'm going to go through you example and see what I can do... but I can't promise anything...

I have copies of pseudo-code that may be able to help... I will compare them with your game and see what I can throw together... This will either be fun or a nightmare... I'll start with the 'fun' option... lol
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #21 on: June 11, 2020, 11:07:35 am »
@johnno56

Well it would be great to work on a project again with you. I really like what we came up with on Battleship.

I would be glad to change rules around, up the points/money/chips stake at beginning of game, I call them chips in program and change so you can win more points/fake money/chips. It would be nice distraction from Gin Rummy which I am still stuck on.

Do you still want to loose if you go bust or wait and see if dealer busts as well = push or tie? (of course you can make your own version)

I hope you bulleted "Output EXE to Source File" under the Run menu in your new QB64 version. That would make loading and running assets a breeze if in same folder as the source .bas file.
 
« Last Edit: June 11, 2020, 11:08:58 am by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #22 on: June 12, 2020, 09:28:02 am »
Hmm... Not overly concerned about which rules to include, change or delete... I prefer 'simple'... ('cos I find 'difficult' hard to do... lol).

Like: Player dealt two cards face up. Dealer One up. One down. If player busts, dealer wins, end of hand. Push is ok when there is a tie. The only 'problem' I see in waiting to see if the dealer busts as well, is that, if both bust then it's a 'tie' and this is an advantage to the player as there is no loss of chips. Game continues until Quit or broke. Oh. 'Chips' are fine by me...

I am working my way through your game because it's relatively easy to follow and I refuse to try and untangle "lined and goto-ed' prehistoric basic code... lol. Well, maybe not quite so easy to follow, but WAY easier than the old code....

I was thinking more along the lines of how Battleships was controlled. Basically by mouse. Click on various valued 'chip' images to place a bet. Click on 'hit' to deal an extra card; Click on 'Stay" to switch to dealer. As always, esc or 'exit', to end the game.

Possible extras: Intro screen; Menu to switch on/off stuff like ambient sound; Music; Highscores; Player name; Max bet... stuff like that...

The least I can do is to start sourcing assets... If I can't find public domain stuff I'll try to make it myself... lol  I think I made a card game table some time ago... It's either floating around on this site or an old drive somewhere... If I can find it, perhaps we can use it, or use as an example of how 'not' to make a table... lol

It's almost 2330 and I have to be up at 0500 to do our fortnightly produce market shopping... Time to hit the sack...
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #23 on: June 12, 2020, 10:04:25 am »
Hmm... Not overly concerned about which rules to include, change or delete... I prefer 'simple'... ('cos I find 'difficult' hard to do... lol).

Yep! you bet, simple is easy to understand, usually logical and easy to remember. So it makes sense to choose simple over complex. If I have a philosophy, that might be it's core. Rule #1


Like: Player dealt two cards face up. Dealer One up. One down. If player busts, dealer wins, end of hand. Push is ok when there is a tie. The only 'problem' I see in waiting to see if the dealer busts as well, is that, if both bust then it's a 'tie' and this is an advantage to the player as there is no loss of chips. Game continues until Quit or broke. Oh. 'Chips' are fine by me...

OK, by Rule#1 AND everyone already knows this game as played:
 If player busts, dealer wins, end of hand.


I am working my way through your game because it's relatively easy to follow and I refuse to try and untangle "lined and goto-ed' prehistoric basic code... lol. Well, maybe not quite so easy to follow, but WAY easier than the old code....

I was thinking more along the lines of how Battleships was controlled. Basically by mouse. Click on various valued 'chip' images to place a bet. Click on 'hit' to deal an extra card; Click on 'Stay" to switch to dealer. As always, esc or 'exit', to end the game.

I have just the thing for that, developed in Gin Rummy Variation Series (though so far only posted one game and found it faulty) it is an extremely simple way to do a "Menu" of buttons customized to the exact situation you're at in the game. I will start rewrite of that along with higher stake, round over with player bust and I have new idea about setting up an account, so after first time you are staked, you are really in hole 1000... well details can be worked out later, point is you have an account and can borrow up to 1000, so every time you start game and log in... you get drift I think. Getting into banking, I can think of a number of bells and whistles for that! ;-))


Possible extras: Intro screen; Menu to switch on/off stuff like ambient sound; Music; Highscores; Player name; Max bet... stuff like that...

The least I can do is to start sourcing assets... If I can't find public domain stuff I'll try to make it myself... lol  I think I made a card game table some time ago... It's either floating around on this site or an old drive somewhere... If I can find it, perhaps we can use it, or use as an example of how 'not' to make a table... lol

...

Yeah! That's the asset magic I am talking about :) 
Oh, I think we should maintain a better credit list for sources of images or sounds.

Oh yeah, and change chips UDT Type to _INTEGER64 so we can go sky high with the points/fake money/chips.
That's quite a Punch List already Johnno! :)
« Last Edit: June 12, 2020, 11:14:36 am by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #24 on: June 12, 2020, 07:18:02 pm »
hmm... I just hope that I am not punching above my weight class... lol

By the way... I found that "card table"... The smallbasic BJ program you converted to sdlbasic but I never got around to adding graphics...

This table... (I will redo it with proper chip values - 10,20,50,100,ALL)

mockup.png
* mockup.png (Filesize: 314.92 KB, Dimensions: 800x600, Views: 346)
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #25 on: June 12, 2020, 08:21:26 pm »
Hi @johnno56

Almost done with very rudimentary bank, B+ Banking and Loan, a little rusty with filing and trying to rush it out.
The rest is ready and BTW it was already conceding round to dealer if player busts.

I just removed an entire bush and chopped it up into leave bags so I am ready to play :)

I am allowing unlimited bets, start thinking about graphics for that. Maybe stacking chips or something?

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #26 on: June 12, 2020, 09:11:17 pm »
Did a search on opengameart.org and found a simple 'poker' set of graphics. The attached cards are about 130x200 (small set) large is about 530x830

The cards do not have to be used. The cards and chips came in seperate files. The cards (or something similar) to the ones you used could replace them.
I think yours would be better... They look more 'real' than the opengameart cards... lol

Small cards and chips...

spritesheet_poker_assets.png
* spritesheet_poker_assets.png (Filesize: 282.66 KB, Dimensions: 2048x2048, Views: 341)
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #27 on: June 13, 2020, 12:54:55 am »
@johnno56

Oh sorry, I finally got the stupid files to work correctly but ran out of gas and crashed. I wanted to do something kinda of fun (for me anyway) before posting. Famous last words, it shouldn't take long now :-))

Yeah those cards are weird but chips look great and same with table. It would be cool if had like King of Diamonds with the Ace of Spades, something that shouts Black Jack! My splash screen too pixelated.

Probably will need button images for "Quit" or something similar like "Cash In Chips", "Stand" or Stay?, "Hit Me".

A funny or smart mouthed Dealer?

Eh, got to finish my banking...
« Last Edit: June 13, 2020, 12:56:17 am by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #28 on: June 13, 2020, 02:21:36 am »
Ok. Re-created the original table using GIMP and have separated the image into layers. Added Blackjack cards to the centre  of the table and learning how to draw text to a circular path. Possible "Black" on the top path and "Jack" on the bottom path. Once done I'll post another image. This time, because of layers, will make future changes much easier...
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #29 on: June 13, 2020, 03:09:49 am »
@johnno56

OK I think I have all the kinks out of new banking system for chip tracking between games.
You are charged interest if you owe but make interest if you are in the Black. The "Founder" who makes the original loan makes money on every thing except starting the loan.

At present the user log-in is super plain, just type your name, possibly want password and encryption in future.

* BJ restart 2020-06-12.zip (Filesize: 19.26 KB, Downloads: 241)
« Last Edit: June 13, 2020, 10:43:38 am by bplus »