MV Poker

I am creating a poker game.
1756205835722.png

Things I made so far:
Graphics:
- Title screen
- Character faces
- Play board

System:
- A deck with 52 cards, that gets reset and shuffled every hand.
- Dealing. (Put a card in each player's hand, the flop, river and turn)
- Checking which hand is the winner (I made a plugin for this.)

I have everything I need, but I am stuck on creating a betting algorithm. I might need an algorithm that checks what the win chances are based on which cards the AI has, and how many cards are still in the deck and how many players are in this hand. Based on that percentage, I could make the AI raise, call, check or fold. Another thing I also need to create is a dealer button, small blind bets and big blind bets. But I see this as part of the betting system I still am struggling with.

Finally I need an interface: Showing stacks, cards and bets near the players portraits, showing the flop, turn and river, and the pot, in the center of the table. Now, it all runs just in the background without visuals.

The game technically so far just:
- Creates a new deck and shuffles it
- Deals cards
- Declares a winner

1756205808206.png


Next steps:

First I will create a betting system, where AI will basically pick check, raise, fold or call randomly. That part is to set up turns, having the betting round stop once every player has checked or called. (So far I have skipped this to break my brains over the next step)

Next I need to make the AI take smart decisions. This is so freaking hard, I am so freaking stuck on this part.

IMAGES!!
Images are made by creating many templates with AI, combine the best features of each template and then redraw the whole thing myself. So, yes... AI helped me greatly with the design, specially the design of the mohawk character, since that is based on myself.

I thought it was smart to create graphics that way. It works with code: I have AI show me how it is done, and then I do it myself. But I hated it! I love the result, though. I wonder if all pixel artists work like I do, like zoom in at 800% or 1600%. Even with the minimap, things don't make sense at 1600% to me... Normally when I do, I zoom in for details, sure, but every pixel in the wrong place looks fine at 1600%, and weird at 100%, or the other way around. I don't think I'll do this again. 😛 Learned a lot about pixel art and shading, though...

PLUGIN!!
The plugin I wrote is a complicated algorithm that works as followed:
- Each card in the game is stored in a variable.
- The plugins knows which variables means what (Is it a card in a players hand, or part of the flop, turn or river?)
- The plugin checks the best 5 cards out of the 7 available per player
- The plugin checks which player has the best hand

This is only the second most challenging thing I had to face when making this game, but I nailed it! (With some help debugging, by AI...)

Now I have to add another algorithm to see which action the current AI player should take. That is so hard, that is where I am completely stuck.
Very much interested as I love playing poker! Will keep an eye on this project!
I will keep you updated.
I am making huge progress with my game. I am just hours away from making it playable... Unfortunately it is past midnight and my alarm goes off early in the morning for the rest of the week. Hopefully I can find some time to finish a first draft before the week is over!

The good news is: Is the problems I had are tackled!! The AI is semi-smart, but once it starts bidding, it won't stop. Meaning: If there are 2 AI's bidding, they keep raising till they are all-in. They don't switch to calling once the pot is big enough. Same thing for the callers, if they call 10, they call 1000.

Once that is done, the only thing left is dealing with a split pot. I have no idea how I am going to handle that... 😛 I'll figure it out though. The hard part is over.
I give up! 🙁 Maybe I'll restart this whole thing over some day, but right now, I give up. I can't seem to get it right!!! Specially with 4 AI opponents (as in, I program the opponents, they are not AI controlled characters) it is so freaking hard to make them call, raise or fold at the right moment. The only thing I seem to get them to do right, is check a bad hand (as in, not folding when you can check instead).

I thought I had it all right, In test plays I had opponents betting, others were folding, and it all seemed to be amazing. I thought the main bugs were things like: Folding players still getting a turn, or how to deal with a split pot or a side pot. I had no idea the players were folding good cards, because I would never see folding cards. I did notice some calling obiously bad hands. I mean, they would pretty much always call if they had a 10 or higher in there hand and nothing else. Even if the bets go way high and the river is already been played.

But then I decided to show all the opponents cards during playing, and it was as if they were just doing random stuff. Folding pocket 9's preflop when all they have to call is the blind, or 7-8 suited.

I honestly think the game would have more logic if I indeed made the choices opponents make random. At least then I can relax and not endlessly trying to find out where I went wrong.

So yeah, this one is a bust. On the pile of abandoned projects, probably never to be seen again.

However... ... ... I never actually do this, but... Maybe
don't give up, put it aside, check the code later.

if it checks on bad hand, than your code probably need it reversed.
don't know what you did though, but if is random, you might have something
wrong coded somewhere.

clear your mind and check later, it may work for you =)
Well, I did something stupid... Here is what happened. I had a pretty well-thought algorithm. It would check the hand of each player preflop, and give it a score. A pair would be a nice score, a high card would be a nice score, suited cards would push your score even more (unless you have a pair, then something is wrong...). And then for the flop, river and turn, I would use another, more complex algorithm that checks for a straight-flush, then a flush, then a straight, and so on, and so on. (I thought that would honestly be the hard part, but it wasn't.)

So, then I started eventing the whole game, got distracted by making accurate chip stacks half-way trough, and then I finished all the actual eventing.

Important to know, the output the plugin was supposed to give with my code was:
0: Fold/Check
1: Call/Check
2: Raise little
3: Raise Big
4: All in

Raise big would result is raising half their stack or half the pot (whichever is smaller and with a minimum of the big blind, unless the blind is larger than their stack), raise little will raise the minimum bet (big blind).

The thing I overlooked was: When they call, they call anything. They keep calling mediocre hands, even when they have large bets to call. When 2 bots raise, they raise until they are broke. One player bets half the pot? The other joins, because he would call a blind with 4-6 suited.

See, I underestimated how complex poker really is. And I have played a lot of poker, really.

This is really, really hard... I was scared I couldn't do it.

Where is really went wrong:
See, I was faaaaaaar more away from the finish line that I thought I was weeks ago and I was waaaaay pessimistic about it. And then I remembered seeing those AI assist chat windows pop up in VS code. I never used it, even disabled it (because you don't learn when you let AI do the job...), but I wanted to fix the issue, so I wanted to ask Gemini.

I often ask Gemini to check my code and help me find a solution to my problem, which then I myself would put into the code. However, my code got too long for gemini to read (without paying for pro) so I asked: Is there a gemini plugin for VS code, and it turned out there was.

I asked my new gemini plugin to check my code to see what I did wrong (Edit: More specific, I asked for ideas how to make the opponents smarter)... And they changed everything!!! I did read the explanation and I kind of understood what it wanted to tell me, but it was a lot of information to process all at once. However, I did NOT know that this plugin would actually adapt my code and take shortcuts I don't understand.

I didn't realize those "ideas" were actually made live in my code, so... I saved it and went to sleep, thinking I had some fresh ideas how to clean up my code in the morning. Next day, it was like my code was gone, and replace with a different code. I didn't recognize my own plugin anymore, it was too late to try CTRL+Z, which would have reversed the whole damn thing.

I was so far, and just because I wanted to talk about my code with AI, AI took over and messed everything up. Not only do I not understand my code anymore, AI also messed everything up.

I was already struggling with the betting system, and then I thought I found a tool that could explain to me what how I could improve my betting system, but instead it rewrote the whole thing.

Sorry for writing a whole book on the subject, but... Well, that is what happened. I thought I downloaded a tool that could teach me, like regular gemini does, but instead it took over. I don't like this tool. I want to tell the AI what I want to do, and then I want the AI to look at my code, and tell me how to do it. Then I can ask questions, if I don't understand the code straight away.

See, I don't even copy-paste the solution from AI, unless I exactly understand what it does, how it does what it does, and why it does what it does. If I knew Gemini would take over, I would at least have made a back-up... But... I'm stupid, okay. 😛 Yeah, not funny. I'm real pissed at myself.

But, to be fair (last thing, then I'll hit send, I swear) it isn't all gemini's fold, I was already at a dead end for a while before the dead end was blown up by gemini. I already gave up, that is why I downloaded the tool. I was desperate.
At least you made a backup with the original code, right? Right?
Nooo... i though it would just be an AI chat window. I didnt know it would achtially change my code. :'(

Edit: OMG!!! I did have a backup made before I downloaded the AI tool! I completely forgot I did, but I did! 😀

Still, I'm at a dead end with the whole betting system, but I didn't lose all my work. I will uninstall the AI tool before I do ANYTHING. 😛
if AI don't take all code, maybe do it in 2 parts.

but still, if something went wrong, telling them on 1-2 function
why it won't work.

I only use AI to understand mapping, or filter it some ways.
and explanation.

slice, splice, reduce, and other stuff gets complicated fast,
especially if there are different methods in each one to produce the same effect.

you can ask from there, what methods there are and which one would be better.
but in the end, its ultimately your choice.

always backup if you use AI code or rule out your choice, paste it below.
this way, you keep your own, and you can alter it your way if needed.

AI always make mistake, and human creation is far better as well =)
but I hope you can continue, don't rush, take your time.

I know poker and base can be easy for 2-4 or even 8 players.
adding AI opponent is a different story, check chips, hand, take chance,
fold, call, etc.

but you may need to place them on "null" at the end or "undefined"
in order to "re-check" their hands to make call or check or fold there.
Cutting my code in 2 parts is useless. The AI can't understand the second half without the first.

I know AI can make mistakes and will even lie to tell me what I want to hear... I didn't think this particular AI would actually change the code.

I thought it was just a chat window that would give advice.
I thought it was just a chat window that would give advice.
maybe explicit ask AI for advice only.

I don't know gemini but chatGPT is quite helpful for asking advice.
if they are equal, than it doesn't matter, but I got quite some handy
methods how some can be used, even combo's.

so I do hope your poker plugin come alive in the way you want too.
and its already quite difficult to make it work smoothly.

so keep your courage, or a step back and check later again =)
don't force yourself and it can end up in frustration ^^
Yeah, by now I understand a lot better how it works, but this is not what I want to use AI for. I don't want AI to do the coding for me. I want AI to teach me and I want to do the work myself. That is the only way I'd learn. And I only want to ask for help when I'm stuck.

With the tool installed, it will constantly try to finish my lines. It is not letting me think for myself and it is often not even completing the lines the way I want them to be completed. 😛
Progress?
I got quite far and then had a problem getting AI opponents right. This is currently shelved.
@Banana_Duck I saw your sad face about this being shelved, but there is an upside: By shelving this, I have time to work om another game you paid interest in: The football manager. 😛

The football manager is something I know I can create. I know exactly what to do. Unlike the poker game, where I am completely stuck.

So one game you wanted me to finish is shelved and will probably be lost forever, but at the same time another shelved game you wanted me to finish is back in development. 🙂

But which one would you have preferred, if it was your call?
I don't know much about poker, only the hand ranking part i understand,not much the rest, but seems like it smaller scale compared to football sim and quickly able to be finished, i wonder maybe with the help of chatgpt giving ideas on how to code can help?
I once made a poker mini-game using variables for card values and suits, with common events handling the draw and hand checks. It takes time but works well with eventing.

Original thread: https://forums.rpgmakerweb.com/threads/poker.179792/