This was original done as a "homework" assignment for an interview screen. A best effort has been made to scrub the identity of the company from the code base but I make no promises it has been wholly excised. No other alterations have been made to the source or history despite my vain desires. As it has been two years, and the code quality here isn't exactly something you should be copying, I feel this is safe to publish. However, DO YOUR OWN HOMEWORK.
This project was originally written to work on .NET Core 1.1 and minimal effort has been made to get it running in the latest .NET Core version.
This is a C# .NET Core solution to judge 3 Card poker. It should be cross-platform but was developed and tested on Win10-x64 so your mileage may vary.
This project was designed to solve the problems of 3 Card poker while being extensible and flexible enough to be quickly adapted to solve other pokers. Below are the major namespaces and classes and what they mean to understand how this is achieved.
Program.cs
: Console program responsible for I/OPoker.cs
: Defines the game of poker (a set of players with "hands") which is scored in tiers and then re-scored in "tie-breaker" fashionRuleSets
(namespace): implementation of rule builder pattern, should allow the service to be quickly modified to support other pokers. Each "rule set" is a variation of poker rules to judge with.RuleProcessors
(namespace): allow multiple rules to share logic and cached resultsRules
(namespace): define individual methods for evaluating hands in a round of poker; include initial evaluation and tie-breaking logic.Models
(namespace): concepts fundamental to implementing poker.
Note, there is one significant kludge that may need to be refactored if the architecture were to be improved. Specifically, Hand
is responsible for determining and knowing if it contains n-of-a-kind cards and what rank those cards are. Ideally this would live in something like a NumberOfAKindProcessor
but getting that to work with Pair tiebreaking was too difficult to be worth it for initial round of dev.
Another potential refactor would be to create PlayerHands.cs
to carry PlayerId
+ Hand
instead of putting the Id onto Hand
itself.
- .NET Core SDK
- Python 2.7 - required to run tests
- VS 2017 IDE - required to open .sln and run+debug
- If you don't want to download VS2017 the code files themselves can be easily viewed in any text editor. I would recommend VS Code with C# plugin for text highlighting and integration with dotnet core.
- Set current directory to
.\src
from project root - Run
dotnet publish -o ..\publish -c release
Note, if you wish to produce an exe instead you can run dotnet publish -o ..\publish -c release -r win10-x64
- Set current directory to published code location
- if following above from project root that is
.\publish
- if following above from project root that is
- Run
dotnet PokerSolver.dll
- OR run
PokerSolver.exe
if you published the exe
- Set current directory to project root
python .\run_tests "dotnet .\publish\PokerSolver.dll"
- Note: the path the the published dll is relative to the project root. The above only works if publish directions above are followed.
python .\run_tests ".\publish\PokerSolver.exe"
if you published the exe
Note, Tests in the test folder should automatically be run on build.