Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1012391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:56:22+00:00 2026-05-16T09:56:22+00:00

I’m writing a poker framework in C# and I don’t like the design I

  • 0

I’m writing a poker framework in C# and I don’t like the design I currently have. My goal is to have a game engine that can play multiple AI agents against each other in batch mode very quickly, and play multiple AI agents vs. multiple humans (probably via a Silverlight client). I’d like to keep efficiency high but maintain flexibility– e.g., it should be able to play games like Limit Hold’em, No-Limit Hold’em, Limit 7-card Stud, etc.

My current design is rather clunky and inflexible:

  • HandHistory: Contains all the information about the current hand (players in, bets made, etc.)
  • IPlayer: Every player defines a GetAction(HandHistory history) method.
  • GameEngine: Defines a Play(HandInfo info) method that returns a HandHistory object.
  • PotManager: Manages the pot and determines how much each player has to call and how much they can win (e.g., if they have unequal stacks and are all-in).
  • BetManager: Manages the bets and determines when a betting round is finished.

The HandInfo class contains all the information about how to setup the hand. The Play method then looks something like this:

HandHistory Play(HandInfo info)
{
    PotManager pots = new PotManager(info);
    BetManager bets = new BetManager(info);
    HandHistory history = CreateHistory(info);

    bets.CollectBlinds();
    if(!bets.GameOver)
    {
        DealHoleCards();
        if(bets.PlayersThatCanStillBet > 1)
            bets.CollectBets();
        if(!bets.GameOver)
        {
            DealFlop();
            ... and on and on
        }
    }

    return history;
}

The problems arise because there are so many little things to consider like collecting the blinds, etc. The Pot and Bet manager classes become a nightmare and are invariably riddled with bugs. Also, my engine design only supports one game type (Hold’em) as opposed to others.

My main ranking is first for efficiency, as the engine is used primarily as an AI simulator over billions of hands. However, I’d like to think there is a more elegant way that this could be done.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T09:56:22+00:00Added an answer on May 16, 2026 at 9:56 am

    My first thought is, code for readability and lack of redundancy first, and optimize for performance (which I assume is what you mean by efficiency) last. It is usually hard to foresee where the performance bottle necks will be, and a slightly slower app is better than a buggy or unmaintainable system. It’s easy to use a product like dotTrace when you’re ready to optimize, if you find it isn’t fast enough.

    Regarding your desire to add functionality, I recommend becoming better at refactoring. That’s one of the core priciples of TDD: write the least amount of code to complete a piece of functionality, then refactor out any code smells. And by using TDD, you can make sure that when you implement, say, Stud, your Hold’em still works.

    A good place to start with your refactoring, since it sounds like you are already running into maintainability issues, is to try to ensure each class has a single responsibility (the first of the SOLID priciples). Your example method has many responsibilities: betting, dealing, game history, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.