WiP: Texas Hold’em (literally)

Howdy;
In lieu of being otherwise stuck on making any progress on my “main” project… I (almost regrettably) have decided to work on something less narrative-driven and more disgustingly annoying to write code for.

I suppose it could be copy-pasted into a more genuine story as a fun “little” mini-game (it’s not little at all… it’s So. Much. Code.). Which was kind of my original intention with it.

Without further hesitation; I give you the culmination of about 4 days of headache.

Demo Link!

The Game

At the start, you and your two opponents will be dealt two “pocket” or “hole” cards. By matching these to several “community” cards, you will build a “hand” of five cards. Whoever has the best possible hand, wins.

The five community cards will be dealt in 3 waves; three cards in “the flop”, one in “the turn”, and one more in “the river”.

Lastly comes “the showdown” where you will see how well your “pocket” cards match up to the community cards and whether or not your best hand beats your opponents’ best hands.

Currently, the game isn’t able to determine an official winner, so if you lack poker knowledge, you might have a hard time figuring out who won the game… so at the moment, those familiar with the card-game may be the only ones able to appreciate it.

Some Progress/Mechanics details

For now, the game is able to recognize (highly successfully) all types of hands:
High-Card,
One-Pair,
Two-Pair,
Three-of-a-Kind,
Straight,
Flush,
Full-House,
Four-of-a-Kind,
Straight-Flush,
and Royal-Flush.

The game will even tell you what your best hand is at the showdown, though it doesn’t know whether or not you actually won yet. (Working on that).

You will see options to “Check” “Raise” “Fold” and “Call” in between the dealer’s rounds. If you don’t know what any of them are supposed to do, don’t fret!
…they don’t do anything…
(yet)

Every play-through is different. Both you and your opponents will be dealt completely new hands every time, like a real game of Poker.

Plans for the future

That’s as far as it goes for now; I’m planning to add more bots, (up to 5, but maybe more if it’s not too much trouble) and soon after that I should be able to teach Choicescript to actually compare yours and your opponents’ hands so it can actually determine a winner.

After that will probably be adding in actual betting & folding, but I’m anticipating teaching Choicescript when to Raise, Fold, Call, or Check is going to be the really hard part… I have a loose plan where, different bots will have different “personalities” when it comes to how aggressive, shy, brave, or cowardly they are at gambling.

I don’t currently have plans to make it possible to “cheat”, but I’m leaving that open as a possibility.

I hope everyone finds this as cool as I do, though from your ends, you won’t likely see the full complexity of what’s already been built here… just know that this was not a fast and easy thing to make, even as limited as it is now.

As always, thanks for playing!

18 Likes

Apparently Straights aren’t working properly… again.

The issue seems to be that the game counts pairs twice towards a straight, when they should only count once.

I thought I fixed that problem, but it’s still happening. I’ll have to look into it deeper. Darn.

1 Like

I believe I have finally fixed it… keep an eye out for rogue hands that don’t make any sense.

You’ll notice I have a counter for the various cards at the bottom of the “showdown” page. That should help identify when a hand doesn’t add-up.

Please let me know if you encounter bugs!

I don’t know a thing about poker but I can and do appreciate the code work :slight_smile:

2 Likes

You are a mad man to attempt this, and a genius for getting it to work this well already, this is awesome

5 Likes

The thought has crossed my mind that I could use this as an opportunity to teach the curious how the game is played.

I could set up a little tutorial/learner. It’s honestly not as difficult to learn as it may seem. The hardest part to learn (imo) is recognizing what kind of hand you have and how it stacks up against others.

4 Likes

I’d actually love that. Someone tried to teach me once, but he was just using it as an opportunity to look at my hand, say “oh you lost this one” every single time and take all my oreos lol

2 Likes

Update: I have successfully added 6 more bots, making for a total of 9 players (which is typical of an official poker game).

I’ve also added the option to set how many bots are in-play.

Note that, with 8 bots, the Showdown page is very crowded… I’m going to look into reformatting how it displays everything to make it easier to read.

In the future, the Showdown will likely be broken up into a few separate pages so you can review your opponents’ hands one at a time before the game tells you who won.

I also want to add some more narrative touches to the game; comments from the other characters, more descriptive writing to create an immersive atmosphere… for the moment however, I need to focus on getting the game itself running correctly… so it’s going to be a pretty dry-read until then.

2 Likes

In retrospect… it appears 8 bots is too many. Trying to load the subroutines for all 8 at once slows Choicescript down to a crawl… I guess we’re going to reign that back.

Will do some trial & error to see how many I can get away with without frying dashingdon’s servers.

2 Likes

this is such a cool use of CS! You could definitely wrap a story around it (poker tournament drama? spy undercover in a casino?) and have a super unique full length game book, if you ever felt like doing all that extra work. major props

2 Likes

To give some perspective on how awful this is to code… the dedicated subroutines file for this game is currently 24,913 lines long.

That’s mostly just for drawing cards and recognizing hands.

It probably could be optimized more (less lines and words to do the same things) but still… this thing is chunky.

3 Likes

Stupid Hetrosexuals slacking off on the job!

In all seriousness though I do like this, I could definitely see it being used as a greater mini game in something like Raiders Of Ice Peak Mountain.

It’s an impressive programming feat, but if you’re planning on selling this at some point in the future when the game is fully working I’d recommend giving a little more personality to the bots, not just in AI, moreso a description and a small bit of dialogue or something so we can know who we’re playing against. Kinda like Poker Night At the Inventory.

Great WIP either way.

1 Like

Yeah, also I’m thinking that adding in more narrative will give me more opportunities to space-out the subroutines, which will help avoid forcing the game to parse literal thousands of lines all at once… which means faster loading between scenes.

As it is now… the loading is very clunky and it’s only going to get worse, so anything to ease it up is good.

2 Likes