BASIC 'Hearts' game

Discussion, Reviews & High-scores

Moderator: Moderators

Post Reply
User avatar
Victragic
Frogger '07
Posts: 605
Joined: Tue Nov 14, 2006 5:56 pm
Location: South Australia

BASIC 'Hearts' game

Post 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
Last edited by Victragic on Mon May 25, 2020 1:15 am, edited 2 times in total.
3^4 is 81.0000001
User avatar
beamrider
Vic 20 Scientist
Posts: 1452
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: BASIC 'Hearts' game

Post 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.
User avatar
Victragic
Frogger '07
Posts: 605
Joined: Tue Nov 14, 2006 5:56 pm
Location: South Australia

Re: BASIC 'Hearts' game

Post 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..
3^4 is 81.0000001
User avatar
orion70
VICtalian
Posts: 4341
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Re: BASIC 'Hearts' game

Post by orion70 »

Well done! You really should post this HERE :)
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: BASIC 'Hearts' game

Post 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.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5

WIP: MIDIcast BASIC extension

he/him/his
User avatar
Victragic
Frogger '07
Posts: 605
Joined: Tue Nov 14, 2006 5:56 pm
Location: South Australia

Re: BASIC 'Hearts' game

Post 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.
3^4 is 81.0000001
User avatar
Mayhem
High Bidder
Posts: 3027
Joined: Mon May 24, 2004 7:03 am
Website: http://www.mayhem64.co.uk
Location: London

Re: BASIC 'Hearts' game

Post by Mayhem »

I’m an incredibly mean Hearts player, so interested to see how this looks heh.
Lie with passion and be forever damned...
User avatar
Victragic
Frogger '07
Posts: 605
Joined: Tue Nov 14, 2006 5:56 pm
Location: South Australia

Re: BASIC 'Hearts' game

Post 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.
3^4 is 81.0000001
User avatar
Mayhem
High Bidder
Posts: 3027
Joined: Mon May 24, 2004 7:03 am
Website: http://www.mayhem64.co.uk
Location: London

Re: BASIC 'Hearts' game

Post 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.
Lie with passion and be forever damned...
User avatar
Victragic
Frogger '07
Posts: 605
Joined: Tue Nov 14, 2006 5:56 pm
Location: South Australia

Re: BASIC 'Hearts' game

Post 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.
3^4 is 81.0000001
User avatar
Mayhem
High Bidder
Posts: 3027
Joined: Mon May 24, 2004 7:03 am
Website: http://www.mayhem64.co.uk
Location: London

Re: BASIC 'Hearts' game

Post 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)
Lie with passion and be forever damned...
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: BASIC 'Hearts' game

Post 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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: BASIC 'Hearts' game

Post 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 50 times
Last edited by wimoos on Fri Jan 15, 2021 3:24 am, edited 32 times in total.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
User avatar
Victragic
Frogger '07
Posts: 605
Joined: Tue Nov 14, 2006 5:56 pm
Location: South Australia

Re: BASIC 'Hearts' game

Post 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!
3^4 is 81.0000001
Post Reply