PyMonteCarlo
PyMonteCarlo is a module that has helper function for monte carlo simulations
Getting Started
Installing PyMonteCarlo
pip install (coming soon)
Basics
from PyMonteCarlo.mcs import MonteCarloSimulaterController as mcs
#Flip A Coin. Output between 0 - 1
mcs.flip_a_coin()
#Roll Dice. Output between 1 - 6
mcs.roll_a_dice()
QuickStart Guide
We Will Create A Monte Carlo Simulator On A Rock, Papper, Scissor Game. You Can Find This Game In Examples Folder In PyMonteCarlo Folder
Defining
from PyMonteCarlo import MonteCarloSimulaterController as mcs
controller = mcs.MonteCarloSimulaterController(actions = ["ROCK", "PAPER", "SCISSOR"], #All The Actions
results = ["PLAYER_1_WON", "PLAYER_2_WON", "TIE"]) #All The Results
Create Game Login
def play(player1_move, player2_move):
"""Takes Two Player Input And Decide The Winner"""
players = [player1_move, player2_move]
if player1_move == player2_move:
#They Both Tied
return "TIE"
moves = {"ROCK" : "SCISSOR", #Rock beats scissor
"SCISSOR" : "PAPER",
"PAPER" : "ROCK"}
for player_index in range(len(players)):
player_id = "PLAYER_1_WON" if player_index == 0 else "PLAYER_2_WON"
for move in moves:
if move == players[player_index] and moves[move] == players[1 if player_index == 0 else 0]:
return player_id
Creating Simulation
#The Main Simulations
for _ in range(1000):
player1_action = controller.take_action() #Randomly takes action between rock, paper, scissor
player2_action = controller.take_action()
"""Also You Can Do This
player2_action = controller.take_action(available_actions=["ROCK","PAPER"])
If You Want To Change The Available Outputs
"""
winner = play(player1_action, player2_action)
controller.add_result(winner) #Adds The Result To The Controller
Viewing The Results
print(controller.results_count()) #Returns How Many Times Each Result Occurs
print(controller.max_result(strength=True)) #Returns The Maximum Times Occuring Result With Its Strenght Between 0 - 1. 0 means bad and 1 means amazing.
print(controller.avg_result(strength=True)) #Returns Average Result And Its Strength
print(controller.median_result(strength=True)) #Returns Median Result With Its Strength
"""Output
{'PLAYER_1_WON': 348, 'PLAYER_2_WON': 316, 'TIE': 336}
('PLAYER_1_WON', 0.348)
('TIE', 0.336)
('TIE', 0.336)
"""
Contributing
If you have any suggestion either contact sonicroshan122@gmail or send a pull request
Authors
Roshan Jignesh Mehta - sonicroshan122@gmail
Future
This Features Will Be Added In The Future
- Monte Carlo Tree Search
- Ploting The Monte Carlo Simulation Results And Action
Metadata
Release files for MonteCarloPy 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| MonteCarloPy-0.1.tar.gz | 3.5 kB | Without provenance | Details for MonteCarloPy-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| MonteCarloPy-0.1-py3-none-any.whl | Python 3 | none | any | Details for MonteCarloPy-0.1-py3-none-any.whl |
Total release size: 7.3 kB
Release files / MonteCarloPy-0.1.tar.gz
| Download URL | MonteCarloPy-0.1.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
60933dc27b77c728e5677e099bafa3cbf69b788093ff6b9efb695815452ecb71
|
|
BLAKE2b-256 checksum How to use checksums |
d3841f61fcb7048085df320f6141ea6f161799c018a9cc47cb020ed7e3f5841d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / MonteCarloPy-0.1-py3-none-any.whl
| Download URL | MonteCarloPy-0.1-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a8579b10c282a144b54da97f8bee89d2d2c1bedc7484c0f741011fe050bd7cc
|
|
BLAKE2b-256 checksum How to use checksums |
8428e9d5be23787ad59510605e308e5260981c7e981a2ceff2c471380ae53f9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for MonteCarloPy 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.