Video Poker Takes Your Money In 10 Lines Of BASIC

It wasn’t easy, but [D. Scott Williamson] succeeded in implementing Jacks or Better Video Poker in 10 lines of BASIC, complete with flashing light and sound! Each round, one places a bet then plays a hand of 5-card draw, hoping to end up with Jacks or better.

This program is [Scott]’s entry into the 2024 BASIC 10 Liner Contest, which at this writing has concluded submissions and expects to announce results on April 6th 2024. Contestants may choose any 8-bit computer system BASIC, and must implement their program within ten lines of code (classically limited to 80 characters per line, but there are different categories with different constraints on line width.)

10 lines of BASIC is truly an exercise in information density.

We’ve seen impressive 10-line BASIC programs before, like this re-implementation of the E.T. video game. (Fun fact: while considered one of the worst video games of all time, there’s a compelling case to be made that while it was a flop, it was ahead of its time and mostly just misunderstood.)

These programs don’t look much like the typical BASIC programs many of us remember. They are exercises in information density, where every character counts. So we’re delighted to see [Scott] also provides a version of his code formatted and commented for better readability, and a logical overview that steps through each line.

He spends a little time talking about the various challenges, as well. For example, hand ranking required a clever solution. IF…THEN conditionals would rapidly consume the limited lines of code, so hands are ranked programmatically. The 52-card deck is also simulated, rather than simply generating random cards on the fly.

The result looks great, and you can watch it in action in the video, just under the page break. If this sort of challenge tweaks your interest, there’s plenty of time to get started on next year’s BASIC 10 Liner Contest. Fire up those emulators!

14 thoughts on “Video Poker Takes Your Money In 10 Lines Of BASIC

  1. Good luck to everyone in this year’s BASIC 10 liner contest. Don’t forget to checkout all the entries including the two I’ve submitted this year – Hardware Hustle (inspired by a Hackaday article on the dice and pencil game of the same name) and ZXFM (a football management game).

      1. 10-lines is something different then 10 statements. How many can you do with only 10 statements? Anyone who ever used an old computer with basic knows that this is completely normal. An art of programming well known from various magazines at the time. Cramming in as much useful statements on a single line is the real challenge here.

        1. Exactly! I remember Leo Christopherson’s Android Nim on the TRS-80 had as its first line a comment that read “Don’t be alarmed at the way this pgm lists!” since he had gone back and poked in ASCII characters into the string literals of the program. The tokenizer didn’t care one whit when storing the literal. As long as you worked around 0x00 values you could also embed short ASM functions into BASIC strings, which I did often.

          I think the premise of this contest is genius.

    1. You’ll have to put me out of my misery and explain how you enter multiple statements per line in ZX81 BASIC because it really limited my ZX81 entry in the contest last year (ZXWORD)

    1. Any version of Atari BASIC can run Jacks or Better VIDEO POKER.
      The 120 character limitation is due to only being able to enter 3 lines on the display, and that only if you move the left margin to 0 (POKE 82,0). The input buffer is ~253 bytes (I think, I forget exactly, but it’s just under 256), and you can ENTER longer lines so long as you don’t overflow during tokenization (
      I develop in Notepad++, change the line endings, then read the file into the emulator with hard drive emulation in Atari800WinPLus like this ENTER”D1:VIDPOKER.LST”. I use DOS to copy files from the emulated hard drive to emulated floppy .atr files.
      It’s true I no longer use the flat Atari 400 keyboard on a CRT, but the program does load, list, and run on stock hardware using the stock BASIC.
      Quick Basic is another awesome story, it’s fast and supports all sorts of Atari computer hardware features like characters, display lists, player missile graphics, and best of all it’s still under active development getting better all the time. I’m not using it but I can’t compete with it, those games are really awesome. I digress.

  2. I’ve been playing a lot of Win16 and Win32 Video Poker games that are on I’m about to write a version myself, and then I had the eye opening realization. Sure you can use a simple sequence of IF statements to determine what hand the player has, but are there more optimal ways of doing this? And now I’m hung up on what kind of PRNG I want to use to design my deck shuffling algorithm. 10 lines of code, holy moly!

  3. I was looking at the E.T. ATARI article, when my wife looked over and said “I remember playing E.T.”. She said that she enjoyed it, but remembered falling in holes a lot. She thought that she was just really bad at the game. 🤣

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.