skent259 / crapssim

Simulator for craps with various betting strategies
MIT License
28 stars 13 forks source link

Add methods for running simulations #14

Open skent259 opened 2 years ago

skent259 commented 2 years ago

I like the idea of having some convenience methods for running the simulations, and maybe even some convenience methods for simplifying the data through displaying with charts or giving helpful aggregation data (I'm a gambler not a statistician but for me average ROI, risk of ruin, coin-in, etc. could be valuable.)

Might make sense to have that as a separate package or something within crapssim, but I think that as long as it's well documented it could just be available in crapssim itself.

I think that this would be useful on the users end for simplicity, and allow us to add more features for running those simulations. For example, one thing that I would like to see on that front would be using the tqdm package to allow us to show a progress bar of the simulation completion status. I would think most end users would find this helpful, but it would be burdensome to document how to set that up in the readme for a user who just wants to run a simulation on their strategy. Similarly, I haven't tested it yet but I think that there could be some significant speed increases if when running multi simulations we utilized the multiprocessing module.

In theory, I think that one way to do it might be a Simulation object where you could add the table(s) and player(s) and a run method that would then run and store the results. Maybe with classmethods or optional arguments to initialize it for table, player, strategy, etc. For example to run 1000 passline simulations:

sim = Simulation.from_strategy(strategy=passline, bankroll=10000, runout=True)
sim.run(count=1000)

then it would show a tqdm progress bar with x number of simulations over 1000 being completed. And then there would be methods or properties with data ex:

print(sim.win_loss_amounts)
>>> [100.4, -55.6, 4000, ...]

Originally posted by @amortization in https://github.com/skent259/crapssim/issues/8#issuecomment-1114993452

skent259 commented 2 years ago

I have a good bit of code for the simulations, and so I'd like to take a first pass at adding some basic simulation methods and helper methods to get summary statistics and visualizations.

One initial question is whether it's worth adding dependencies to e.g. pandas and matplotlib (though I prefer plotnine) through these methods. I figure almost everyone has access to these packages, so it's probably not a huge deal

amortization commented 2 years ago

Yeah, I think we should definitely try to utilize what you already have for simulation generation. I know very little about the actual statistics modeling. My initial interest in the package was using it for calculating rewards tier credit.

I only have a little knowledge of Pandas, and almost none with matplotlib or plotnine, but I don't see any issue with making those dependencies since this is a module meant for analyzing simulation data, and those are seemingly the most commonly used packages for doing so. I don't know a whole lot about package distribution either, but I think that there is a way to make the dependencies optional (https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#optional-dependencies) so that it would only require those packages if they used the simulation suite, whereas they could run the vanilla package without it. I think that would reduce the modules footprint. I know that something like SQLAlchemy uses optional dependencies for each of the different database adaptors without having to install all of them.