Page 1 of 1

BASIC 'Hearts' game

Posted: Mon May 18, 2020 2:03 am
by Victragic
Hi all,

well it's - 'Hearts', the card game that you play when you are pretending to work, now for unexpanded Vic-20. Written entirely in BASIC. (I'm wondering if someone has already done this, but I just spent the better part of an hour searching, apparently no..)

The game includes the following rules / variants :

- 2 Clubs always goes first
- You cannot lead a heart unless a point card has been played
- If you 'shoot the moon', everyone else's score increases by 26
- First round is not 'safe' - if you have no clubs, you can trump with a point card

The computer players don't play what I would consider to be an 'optimal' game, nevertheless they still provides what I think is a reasonable level of competition.

This is the first thing I've done in BASIC on the VIC since I was a kid. I was using the Programmer's Aid cartridge for the first time (really this was just an excuse to see what that cartridge does, after all these years), and I have to say - it made the task much much easier than I remember coding on the VIC to be.

EDIT : Fixed a 'randomising' issue, now plays different games each time you start it.
EDIT 25/5/20 : - Better randomising
- fixed scoring bug when player shoots moon on last round
- Various bits of screwy code fixed
- Slightly more efficient play by computer players

Re: BASIC 'Hearts' game

Posted: Mon May 18, 2020 2:15 am
by beamrider
Thanks. Very nice and clean... does what it says on the tin!

I knew I'd seen the title screen style before so I had to find it - it's similar to the Blue Meanies opening screen.

Re: BASIC 'Hearts' game

Posted: Mon May 18, 2020 2:29 am
by Victragic
beamrider wrote: Mon May 18, 2020 2:15 am I knew I'd seen the title screen style before so I had to find it - it's similar to the Blue Meanies opening screen.
Yes a bit of a nod to Commodore's Vic-21 too..

Re: BASIC 'Hearts' game

Posted: Mon May 18, 2020 9:23 am
by orion70
Well done! You really should post this HERE :)

Re: BASIC 'Hearts' game

Posted: Mon May 18, 2020 3:14 pm
by chysn
It's really very nice. KIM shot the moon in the first hand. I was able to come back and win, but it was quite a performance.

Re: BASIC 'Hearts' game

Posted: Tue May 19, 2020 4:57 pm
by Victragic
Thanks - I'm still tinkering a little with it before I post on the announcement board. I can make the computer play a wee bit more efficiently.

Re: BASIC 'Hearts' game

Posted: Sat May 23, 2020 2:37 pm
by Mayhem
I’m an incredibly mean Hearts player, so interested to see how this looks heh.

Re: BASIC 'Hearts' game

Posted: Mon May 25, 2020 1:25 am
by Victragic
Mayhem wrote: Sat May 23, 2020 2:37 pm I’m an incredibly mean Hearts player, so interested to see how this looks heh.
You'll probably beat the computer players quite regularly, I'd think :)

The latest version is *just* good enough for a casual player like me though, I just played it twice and didn't win either time. (A computer player shot the moon in each game). My goal was to end up with something I wouldn't win *every* time when I played it.

Re: BASIC 'Hearts' game

Posted: Wed May 27, 2020 2:30 pm
by Mayhem
Not bad, enjoyed playing that, although it's missing the "pass three cards to the next player" feature which really is an essential part of the game imo.

Re: BASIC 'Hearts' game

Posted: Thu May 28, 2020 2:55 am
by Victragic
You are right, I had forgotten that competely!

If I can do it well and within 3.5k, I'll include. But I'm not sure at this stage if I can.

Re: BASIC 'Hearts' game

Posted: Thu May 28, 2020 4:09 am
by Mayhem
If bumping to +8k means you can fit that in and expand the computer AI in the process (maybe variable difficulty levels) then I'm all for it 8)

Re: BASIC 'Hearts' game

Posted: Mon Sep 14, 2020 2:09 am
by wimoos
Hi Victragic,

I suggest to make the sorting routine a bit faster / obsolete:

Replace

Code: Select all

73 t=0:n=1
74 ifd%(n,p)<d%(n-1,p)thent=d%(n-1,p):d%(n-1,p)=d%(n,p):d%(n,p)=t:ifn>1thenn=n-1:goto74
75 n=n+1:ifn<13then74
76 return
with

Code: Select all

73 n=i
74 ifn<12-rthend%(n,p)=d%(n+1,p):n=n+1:goto74
75 d%(n,p)=99
76 return
and remove D%(I,P)=99 from line 66.

Regards,

Wim.

Re: BASIC 'Hearts' game

Posted: Wed Sep 16, 2020 2:34 am
by wimoos
Here is the WimBasic version. Brought it down to 1912 bytes, 37 lines.
It autostarts in VICE.

Regards,

Wim.
hearts.zip
(9.42 KiB) Downloaded 51 times

Re: BASIC 'Hearts' game

Posted: Sun Sep 20, 2020 11:31 pm
by Victragic
That's considerably more efficient!

I'll have a look at this a bit later.

BTW the original code was made on a real Vic with just the Programmer's Aid cartridge, I've no intention of expanding it beyond those specs but happy for anyone to take it further as they see fit!