Casino simulator (intending to make a simulator for 5-card draw poker).
Version 0.5 has been finalized. See a summary of its features under "History" below.
Since it has been difficult to make a reasonably competent AI for the players, further versions might not be available in the near future.
UPDATE: Version 0.6 is available. Note that players do not play reasonable in 0.6, so go back to 0.5 if decent play is desired.
The simulator is being programmed in Python
Run from terminal by navigating to the folder containing the py files and typing:
python casimo.py
From version 0.2, the output tends to be too large for a terminal. Try writing to a file by using the syntax
python casimo.py > filename.txt
Make sure that the path you choose for the output does not cause overwriting of important files.
Sample output can no longer be found in the file output.txt.
Version 0.6 contains code for testing a variety of hand types, and can be run by typing:
python test_hand.py
v0.4: The largest test was run with these parameters: 50k hands/3 different stakes/32 tables per limit/GROWRATE of 1
It seems like the tight players are superior (all 5 highrollers and all players at the highest limit were tight).
The loose players are getting pummeled. Only 4 loose players remained at the end.
It's somewhat surprising that the regular players are not performing better. A tweak of the ranges should be considered.
v0.6: Contains tests to verify that a dealer and a player sorts and reads hands correctly (test_hand.py)
v0.1:
-Number of rounds simulated is determined by a global constant.
-Made an algorithm for one five-man table:
-Every player bets the maximum amount each hand.
-No cards are drawn (or all players draw in the same way)
-Ties are not possible. (If several players have the same hand, rank by suit or by coinflipping)
-After each hand, the chip count for the players are output (tested in terminal/cmd)
v0.15:
-Added a cashier class to give players cash when they leave and keep a list of these players.
-The stake manager now removes busted players from a table and directs them to the cashier.
-Tables that are not full are kept in a separate list from full tables.
-The simulator runs until there are no full tables left, and makes reports when reaching that point.
v0.2:
-Added the possibility for new managers to be generated to handle higher stakes when appropriate.
-Added functionality for moving up and down between stakes based on the number of big bets in a player's chipstack.
-Added functionality to convert between cash and chips in such a fashion that 1 chip equals one small blind at every stake.
-The cashier keeps a list of players having too much cash to play at the highest stakes (labeled high-rollers).
-Fixed a logical error that caused players to lose more chips than what they contributed to the pot at higher stakes.
Minor issues:
-Fixed logical errors in conversion between chips and cash that was present in a temporary version in a side branch.
v0.25:
-Added a recruiter class. So far, it only contains a few methods. It should eventually be able to produce different kinds of players.
-Made some cleanup and tested at a bigger scale (3 stakes, higher number of tables, more hands played).
Minor issues:
-Fixed erroneous global constant that caused busted players to sometimes have a negative amount of cash (from side branch).
v0.29:
-Preparation for v0.3.
-Files dealer.py and one_hand.py. At the moment, they're separate from the rest of the files.
-Contains classes for a dealer and cards. The dealer can deal hands and print info about the cards dealt.
-Started to implement functionality for the dealer to rearrange cards in a hand and print what hand it is (straight/pair etc.)
Minor issues:
-Improved the algorithm that determines the winner from v0.1 by using a global constant.
v0.3:
-Finished implementing the functionality for sorting and categorising hands.
-All global constants for dealers/cards are now found in config.py (Planning to move stuff here from the other classes too).
-Functionality for testing/dealing specific hands are implemented. Not intended for use by unsophisticated users.
Minor issues:
-Should improve message passing between some of the functions.
-Does not identify drawing hands yet. Some hands could belong in several categories (pair with draw, straight draw and flush draw etc.).
v0.31:
-Added the ability to return sorted hands from readHand to its caller, and from dealHand to its caller (issue 1 in v0.3).
-Decided that the dealer should not be concerned with drawing (issue 2). Should probably handle this in the Player class eventually.
-Final version before trying to combine dealers with tables/managers/players.
v0.32:
-Imports the dealer class into entities.py
-Moved global constants to config.py
-Minor refactoring and some new comments
v0.35:
-Players can now play actual hands, instead of just winning randomly. The play does not yet contain a draw phase.
-Have implemented three different strats for players (loose, regular and tight). The recruiter assigns a random strat to any new player.
-The dealer has gotten a showdown function, that takes the remaining players and gives the pot to the one with the best hand.
-The pot is split if there's a tie. Leftover chips are distributed randomly between the winners (the same person can win more than one of these).
Issues/shortcomings:
-There were several bugs in the first attempts. An example was related to popping from a list while in the process of iterating over it.
-A lack of a well planned design before starting on this version has led to some messy code. Some refactoring should be looked into soon.
-Doing a larger scale test, and comparing each strat should be added soon.
v.0.4:
-The code has been partly refactored. An example is making actual getter- and setter-functions. More can be done here.
-Using heritage for some of the classes was considered. None of the classes has enough similarities yet to make this a high priority.
-Some larger tests have been run (see the paragraph about testing).
v0.5:
-Further refactoring, including more getters/setters and removal of some duplication.
-A decent amount of testing has been done, and the most apparent shortcomings have been fixed. Therefore, this is merged into the master branch.
Issues/potential improvements:
-The simulator does not handle drawing cards, so currently only has one betting round.
-The player types that are available could be tweaked somewhat. An example is that the regulars seems to play slightly too loose to be able to reach high limits.
-Some values that are now manipulated directly in functions, should probably rely on setter methods instead.
-Large scale tests suggest that the code needs to be more efficient to be able to simulate a large number of hands in an acceptable amount of time.
Summary:
-Supports multiple tables at different stakes. New players start with a reasonable stack at the lowest stakes.
-A recruiter class generates the new players by randomly picking a strategy for them (loose/regular or tight).
-A manager handles tables, using a waitlist and the recruiter to make sure that tables are running smoothly (most of the time).
-Players move up and down depending on their chip stack relative to global constants.
-The cashier takes care of players moving between stakes and leaving. Players that have left are kept in a list that can be used for statistical analysis.
-A dealer generates new hands and sorts them for the players. The dealer also distributes the pot between players at showdown.
v0.6:
-Refactored dealers and players so both inherit from a base PokerPerson class.
-Players also sort their hands (in addition to the dealer). This is done according to player preferences.
-A new basis for detailed player strategy has been made. The player actions have not been adjusted to this yet, resulting in extremely tight play until a fix is ready.
-New tests have been made to verify that dealers and players sort and categorize hands correctly.
-Did some additional cleanup/refactoring and removed some obsolete files/code.
-Some slight upgrades have been made to the output of the simulator, but further adjustments should be made because of changes due to some of the refactored code.
v0.7:
-Fixed typos and poor wording in this README.
-Planning to implement a new basis for players that is hopefully easier to implement.