News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Z|G

Programming in basic. 1st program in years. Blackjack.

Started by Z|G, 17:18, 14 May 21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Z|G

Hi All.

Thought I might document my journey in learning to program in "basic" again, after * cough* years!

First off, I'd like to say that I am not a programmer (software engineer), as the next few screen shots can attest too.

I decided to write something that would use different area's of the "basic" language, such as arrays, data structures and simple logic based scenarios that would be useful to re-learn. So Blackjack was chosen to fit this brief.

It's not really graphically pleasing and would not pose any sort of challenge to more advanced programmers.
Using WinApe Emulator

Title Screen - Please excuse the crudeness of it. (lack of design finesse!)


Few screens of gameplay.... (nothing special)


Moving on...


moving on...

It splits cards - Just not shown.

I always had a cheat mode in mind, this provided more than just a way to cheat, but was a great way to actually see what was happening.
Cheat enabled. Showing Dealer Cards, and next 4 cards in shoe.



What did I learn from the experience.
It's strange to not be able to scroll above or below what you have written.
Silly mistakes, can take ages to find
If in doubt, just add more variables!!! *j/k*
Was not used to the If..Then..else limitations by that I mean, if <cond> then{do this block}else {do this other block of things}
Now understand, why others write multiple instructions on the same line
Basic can be manipulated to work.
I should get a job as a Park Ranger!
I am so used to hitting shift-8 on my laptop to produce a "(" key, shift-9 for ")" ditto for many other keys.
When writing a game about blackjack, perhaps go to a website that tell's you the rules of blackjack, I always thought 5 cards meant you won automatically *home blackjack version*
Keep track of your index's!!

Other than that, I thoroughly enjoyed the experience. even when I could not find those silly little errors, that made me re-write things only to find out it was not a limitation in "basic", but an error in my logic.

I used rnd to generate the cards, which I feel is not correct, I'd like to have a deck of cards [a-k {SUIT*4}] *5 (5 decks). put into an array, as to avoid multiple chances of having it stuff the shoe with say more than 20 Aces. 1deck=4 aces. 5 decks=20 aces, seemed like it stuffed more in than would be possible with a physical 5 deck  to me....??? of any card?? did not seem random enough.

Also be a bit gentle, I'm NOT trying out for programmer of the year!

Program #1 - completed. Moving on...lots to learn.



1xCPC6128, 1xTandy Model 4, 1xC64 (IN BOX)

eto

It doesn't look bad! Congratulations to coming back to the CPC :-) I also startet BASIC again last year. I love to deal with the limitations. It's part of the fun.

Is there a DSK so we can give your game a try?

Animalgril987

Hi @Z|G.
That actually isn't half bad. :D
I agree with @eto; please post a dsk so we can have a go. Also I have a couple of ideas for the card array...


Alan.

IndyUK

Hi

Wanted to join the others to also say "nice job".

Quote from: Z|G on 17:18, 14 May 21It's strange to not be able to scroll above or below what you have written.

Discovered something that maybe of interest to you. If you ever need to examine your BASIC program. Open the Assembler screen (F3) and under the File menu there is a "Read BASIC" option. That will dump your listing into the assembler window. I don't think you can edit and run it from there but, at least you can examine the code and then make the changes in the emulator screen. It's not perfect but I did find it kind of useful while bug/error fixing.

Good luck with future projects.

eto

Quote from: IndyUK on 21:20, 15 May 21
menu there is a "Read BASIC" option. That will dump your listing into the assembler window. I don't think you can edit and run it from there but, at least you can examine the code and then make the changes in the emulator screen. It's not perfect but I did find it kind of useful while bug/error fixing.

I also remember that not being able to scroll was kind of a problem when I started to program in Basic again last year. A way to make this less of a burden was for me, to "structure" the program in a way that I always started sections at 1000,2000,3000 and so on. That way, I knew I can just use e.g. "list 2000-" and then hit ESC at the right moment.



Another option, which I used a lot for my last project:

Save aBasic file in ASCII format, extract it and then open it with your favorite text editor in Windows/Mac Os/Linux. Copy/Paste and using Regex helped a lot to modify larger chunks of code. If I needed new line numbers, I have pasted the code into Excel column B, created the line numbers in column A, pasted back into the texteditor and removed the tabs.

This file again can be saved as ASCII (UTF-8 with Windows line endings) and then can be reimported into the DSK, then can loaded or merged with Basic.

Not the smoothest workflow but every now and then very helpful.

Z|G

Thanks for the positive feedback.

And Tips. I'll try loading it into the assembly window. That would help.
As for a .dsk image, Ummm geeez , it's bit of an ugly duckling, and still has many things to fix. I was not actually trying to do a full blackjack game, but use this as a jumping off point to getting it working, then understanding what I did wrong, and then moving on...

no real betting system, each round is $5, unless you double down..dozens of other little things need fixing.

As an example. In part of the main routine (if you can even call it this), I lose track of the the dealers index, and had to use goto's to get it back on track.. ie.. dealerscards$(0),dealerscards$(1) to even test if the dealer has Blackjack so it's not pretty.

It's a bit like your first child. you want it perfect! before others see it.

I may spend some time on it, and give it a polish up, it will still be ugly, just not hideous. ;) just busy at the 'mo with work


Editx1:Just tried loading basic into the asm window. *fantastic*, I must read more about what winape can do!!
1xCPC6128, 1xTandy Model 4, 1xC64 (IN BOX)

Powered by SMFPacks Menu Editor Mod