OOP-related question

DalTXColtsFan

New member
Joined
Jan 25, 2018
Messages
1
Programming Experience
10+
This question is more OOP-related than C#-related.

Suppose I'm going to code a poker simulator in C#. The AI players could fit certain profiles like passive fish, aggressive maniac, balanced player, tight player, or even random player.

Obviously as part of my code I'm going to create a class called player with properties like open raising range, open limping range, continuation bet percentage, flop raise percentage yada yada yada (apologies to the non-poker-savvy on the forum).

I'm trying to decide how I want to handle the fact that while most of the AI players will fit one of the above categories almost perfectly, I want to have the flexibility to adjust any property for any player.

I think inheritance and/or polymorphism (though I will admit I don't understand polymorphism 100% by any means) would be unnecessary. There's no need to create classes called maniac, fish, tight player, random player etc. and be able to polymorphize into a class called player, and be able to create an array of class player and be able to have them be maniacs et al. Regardless of player type, the calculation for "action" is going to be the same, and depend on their cards, their ranges, and their frequencies - at any given point, we run the calculation and the results are check, call, raise or fold.

I think what I want to do is create the player class with an overloaded constructor that accepts a string. the string must be something like fish, maniac, tight player or random (or whatever else I come up with) and I just set all of the properties based on the defaults for that player type. Once all of the properties have their default values based on the string passed to the constructor, I would then be free to tweak any of them.

Does this sound like an acceptable approach - create a class called Player with and overloaded constructor, properties, and one method called CalculateAction that would calculate bet, raise or fold based on his range, frequencies, the board and the action up to that point in the hand?

I'm sure I'll have other questions later about creating a class for the deck of cards, a class for the flop etc., but for now I'll be happy to just get feedback on my thinking for the player class.

Hope this made sense,
DTXCF
 
The constructor should definitely not take a String as an argument. In that case, there's nothing to stop the code that creates an instance to pass "Hello World". If you wanted to go that way then you'd at least use an enumeration to limit the possible values that could be passed to only valid ones.
 

Latest posts

Back
Top Bottom