{ "info": { "author": "Dan Parker", "author_email": "dan.m.parker0@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# smm2sim\n\nThis package simulates the GSA Mario Maker 2 Endless Expert League regular season and playoffs using a simple, customizable Monte Carlo method.\n\n### Installation\n\nThe package is on [PyPI] and can be installed with pip:\n\n```\npip install smm2sim\n```\n\n### How it works\n\nDuring each simulation, smm2sim uses the methods described below to assign a winner to all remaining matches in the season. It then calculates seasonal point totals and breaks ties to determine playoff seeding, and the playoffs are simulated match-by-match. The playoff structure is assumed to be single-elimination best-of-3 matches with no reseeding.\n\nBefore beginning the simulations, each player is assigned a power rating (PWR), such that a player with a PWR of 8 would be expected to score an average of 8 points in a 15 minute match. By default, the base power rankings for each player are a simple average of their past results (excluding points scored during untimed tiebreakers). Custom ranking systems are also supported, which can be combined with the default ratings or replace them entirely. The individual rating systems and the combined rankings can be regressed to the mean (or to custom player-specific values) as desired.\n\nThe player PWR rankings are adjusted at the beginning of each season simulation by a random amount, determined using a normal distribution with mean 0 and a user-provided standard deviation (1 point by default):\n```\nadjusted_pwr = [PWR] - numpy.random.normal(0, [rank_adj])\n```\n \nThis adjustment represents the uncertainty in each player's base PWR projection, which includes both model error and potential player skill changes. Higher values equate to more variance in outcomes.\n\nEach match consists of 3 simulated games. When simulating a game, player A's PWR is compared to player B's PWR. The resulting point differential is used to generate a normal cumulative distribution function, which estimates player A's probability of winning the game. This win probability is compared to a random number to determine the simulated winner of the game:\n```\npwr_difference = [PWR A] - [PWR B]\nwin_probability = 1 - scipy.stats.norm(pwr_difference, [stdev]).cdf(0)\nis_winner = numpy.random.random() < win_probability\n```\n\nThe standard deviation used to generate the normal distribution ([2.5 points by default]) is configurable.\n\n### Usage\n\n##### Basics\n\nEach simulation is controlled by a Simulate object. You create an object by specifying the number of simulations:\n```python\nimport smm2sim as smm2\nsimulation = smm2.Simulate(n_sims=10000)\n```\n \nIf desired, you can customize the values of the PWR rank adjustment used at the beginning of each simulation and the standard deviation used when simulating individual games:\n```python\nsimulation = smm2.Simulate(n_sims=10000, rank_adj=1, st_dev=2.5)\n``` \n##### PWRsystems\n \nYou can customize how the power rankings are generated by creating a PWRsystems object. You create an object by indicating which systems to include; the built-in system is called \"srs\":\n```python\nsystems = smm2.PWRsystems(srs=True)\nsimulation = smm2.Simulate(n_sims=10000, pwr_systems=systems)\n```\n\nYou can also use your own rating system by creating a generic PWR object and passing it a pandas DataFrame containing the custom rankings. The DataFrame must include one column called 'Player' containing the name of each player (case sensitive) and another column containing the rankings. The name of the ranking column should be unique from those of the other systems being used (so don't use \"SRS\"):\n```python\nmy_sys_df = pd.DataFrame([{'Player':'A','Power':7},{'Player':'B','Power':5}])\nmy_sys = smm2.PWR(values=my_sys_df)\nsystems = smm2.PWRsystems(others=my_sys)\n```\n\nYou can also combine multiple systems. The weights for each system (default = 1) can be specified using the built-in objects for each system:\n```python\nmy_sys_df = pandas.DataFrame([{'Player':'A','Power':7},{'Player':'B','Power':5}])\nmy_sys = smm2.PWR(weight=1, values=my_sys_df)\nsystems = smm2.PWRsystems(srs=smm2.SRS(weight=2), others=my_sys)\n```\n\nTo use multiple custom systems, pass a list of PWR objects instead of a single PWR object:\n```python\ndf1 = pd.DataFrame([{'Player':'A','Power1':7},{'Player':'B','Power1':5}])\ndf2 = pd.DataFrame([{'Player':'A','Power2':2},{'Player':'B','Power2':6}])\nmy_sys_1 = smm2.PWR(weight=2, values=df1)\nmy_sys_2 = smm2.PWR(weight=1.5, values=df2)\nsystems = smm2.PWRsystems(srs=True, others=[my_sys_1, my_sys_2])\n```\n\n##### Regression\n\nOptionally, you can choose to regress the ratings generated by each system by creating a Regression object (if regress_to is omitted, no regression will be used). By default, PWR values will be regressed to the sample mean:\n```python\nmy_sys = smm2.SRS(weight=2, regress_to=smm2.Regression())\n```\n\nYou can use fixed weighting by specifying a decimal between 0 and 1, or variable weighting based on the percentage of a specified number of games played (the default option):\n```python\n#(PWR * 0.75) + (sample_mean * 0.25)\nregression_fixed = smm2.Regression(weight=0.25)\n#((PWR * games_played) + (sample_mean * max(0, 12 - games_played))) / max(12, games_played)\nregression_variable = smm2.Regression(n_games=12)\n```\n \nYou can regress PWR to a fixed value rather than using the sample mean:\n```python\nregression = smm2.Regression(to=0, weight=0.5)\n```\n \nYou can also specify a custom regression value for each player using a pandas DataFrame. The DataFrame must contain one column called 'Player' containing the player names (case sensitive) and another called 'Baseline' for the regression values:\n```python\ndf = pd.DataFrame([{'Player':'A','Baseline':5},{'Player':'B','Baseline':8}])\nregression = smm2.Regression(to=df, n_games=33)\n```\n \nIn addition to (or instead of) regressing the values for individual PWR systems, you can choose to regress the final results after combining the various systems:\n```python\nregression = smm2.Regression(n_games=12)\nsystems = smm2.PWRsystems(regress_to=regression, srs=True, others=my_sys)\n```\n\n##### Execution and Analysis\n\nOnce you've set up your Simulate object, use run() to execute the simulation.\n```python\nsimulation = smm2.Simulate(n_sims=10000)\nsimulation.run()\n```\n \nThe run() method will return a reference to the Simulate object, so this syntax is also acceptable:\n```python\nsimulation = smm2.Simulate(n_sims=10000).run()\n```\n\nBy default, run() will use the joblib package to run the simulations in parallel; this can be overridden by setting parallel=False:\n```python\nsimulation = smm2.Simulate(n_sims=100).run(parallel=False)\n```\n \nOnce the simulation has executed, the results are aggregated and stored in several related dataframes. These can either be directly accessed using the simulations property:\n```python\nstandings = sim.simulations.standings\nregularseason = sim.simulations.regularseason\nseeding = sim.simulations.seeding\nplayoffs = sim.simulations.playoffs\n```\n\nOr returned as copies using class methods:\n```python\nstandings = sim.standings()\nregularseason = sim.regularseason()\nseeding = sim.seeding()\nplayoffs = sim.playoffs()\n```\n\nBy default, all of the aggregated dataframes use MultiIndexes incorporating the simulation number and the within-simulation row number. The class methods include an option to extract the MultiIndex into separate columns in the dataframe:\n```python\nstandings_reindexed = sim.standings(reindex=True)\n```\n\nYou can also entirely disable the generation of aggregated statistics, in which case the results are stored as a list of Simulation objects:\n```python\nsim = smm2.Simulate(n_sims=100000).run(combine=False)\nfor simulation in sim.simulations.values:\n rankings = simulation.rankings\n standings = simulation.standings\n regularseason = simulation.regularseason\n seeding = simulation.seeding\n playoffs = simulation.playoffs\n```\n\n[//]: #\n [PyPI]: ", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/dmparker0/smm2sim/archive/v1.0.3.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dmparker0/smm2sim/", "keywords": "Mario,SMM,SMM2,GSA,speedrun,simulation,statistics", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "smm2sim", "package_url": "https://pypi.org/project/smm2sim/", "platform": "", "project_url": "https://pypi.org/project/smm2sim/", "project_urls": { "Download": "https://github.com/dmparker0/smm2sim/archive/v1.0.3.tar.gz", "Homepage": "https://github.com/dmparker0/smm2sim/" }, "release_url": "https://pypi.org/project/smm2sim/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "A tool for simulating the GSA Mario Maker 2 Endless Expert League", "version": "1.0.3" }, "last_serial": 5778064, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "526934b5dd5c9b6c800eb0e666e17ed1", "sha256": "3d1db236a4842d97c548a729248df25b9bd418014f3f99a0219b7a3eae81500d" }, "downloads": -1, "filename": "smm2sim-1.0.0.tar.gz", "has_sig": false, "md5_digest": "526934b5dd5c9b6c800eb0e666e17ed1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13307, "upload_time": "2019-08-29T22:13:04", "url": "https://files.pythonhosted.org/packages/df/e3/5b501b59622a0ae0e69245e2ad715e5bb7658269a4c57236b1bc90dea26c/smm2sim-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "92b1eb8a076c4999f22a9b245eb6c549", "sha256": "cb73a070f186062862dd116de9f5a0957213b7296a6550ce292ff4471cc76919" }, "downloads": -1, "filename": "smm2sim-1.0.1.tar.gz", "has_sig": false, "md5_digest": "92b1eb8a076c4999f22a9b245eb6c549", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13181, "upload_time": "2019-08-30T17:23:28", "url": "https://files.pythonhosted.org/packages/ad/36/e9d388af24de1a97dc4d7630c96d4ac092d595b8c724909762de44803539/smm2sim-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "f1cb04e8303cc4c9c2a2a2d9b84d6c4b", "sha256": "de628a29d079d19defe4041778a564dd68a52abe24a778d1ecba9bf0a25a31b0" }, "downloads": -1, "filename": "smm2sim-1.0.2.tar.gz", "has_sig": false, "md5_digest": "f1cb04e8303cc4c9c2a2a2d9b84d6c4b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13215, "upload_time": "2019-09-03T20:28:56", "url": "https://files.pythonhosted.org/packages/59/b4/18c7c94fdb36d4b9dbd2b619767ee087d47516ee6f224752c499ef74e8e9/smm2sim-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "11ab9d75449f6180e1841c50a7963d14", "sha256": "f72844dfeece45937d9510ab37dc605da0c5ad698505a64cf8acb84aac27e546" }, "downloads": -1, "filename": "smm2sim-1.0.3.tar.gz", "has_sig": false, "md5_digest": "11ab9d75449f6180e1841c50a7963d14", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13203, "upload_time": "2019-09-03T21:40:11", "url": "https://files.pythonhosted.org/packages/9f/55/177abc31551f76ab042bbadb40cae1c0045bc0f1cc740e453d6689f5d8fc/smm2sim-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "11ab9d75449f6180e1841c50a7963d14", "sha256": "f72844dfeece45937d9510ab37dc605da0c5ad698505a64cf8acb84aac27e546" }, "downloads": -1, "filename": "smm2sim-1.0.3.tar.gz", "has_sig": false, "md5_digest": "11ab9d75449f6180e1841c50a7963d14", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13203, "upload_time": "2019-09-03T21:40:11", "url": "https://files.pythonhosted.org/packages/9f/55/177abc31551f76ab042bbadb40cae1c0045bc0f1cc740e453d6689f5d8fc/smm2sim-1.0.3.tar.gz" } ] }