Skip to content

Commit

Permalink
fix cthulhutech.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
HighDiceRoller committed Sep 21, 2024
1 parent 5a0b5cb commit c7ad7dc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion notebooks/cthulhutech.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
{
"cell_type": "code",
"source": "%pip install icepool\n\nimport icepool\n\nclass CthulhuTechEval(icepool.MultisetEvaluator):\n def next_state(self, state, outcome, count):\n score, run = state or (0, 0)\n if count > 0:\n set_score = outcome * count\n run_score = 0\n run += 1\n if run >= 3:\n # This could be the triangular formula, but it's clearer this way.\n for i in range(run): run_score += (outcome - i)\n score = max(set_score, run_score, score)\n else:\n # No dice rolled this number, so the score remains the same.\n run = 0\n return score, run\n\n def final_outcome(self, final_state):\n # Return just the score.\n return final_state[0]\n \n # Outcomes should be seen in consecutive order.\n extra_outcomes = icepool.MultisetEvaluator.consecutive\n\nimport matplotlib.pyplot as plt\n\ndefault_colors = plt.rcParams['axes.prop_cycle'].by_key()['color']\nevaluator = CthulhuTechEval()\nfigsize = (16, 9)\nfig, ax = plt.subplots(figsize=figsize)\n\nfor num_dice in range(1, 11):\n pool = icepool.d10.pool(num_dice)\n result = evaluator.evaluate(pool)\n ax.plot([x for x in range(101)], [result.probability('>=', percent=True) for x in range(101)])\n marker_size = 64 if num_dice < 10 else 128\n ax.scatter(result.median(), 50.0,\n marker=('$%d$' % num_dice),\n facecolor=default_colors[num_dice-1],\n s=marker_size)\n\nax.set_xticks(range(0, 61, 5))\nax.set_yticks(range(0, 101, 10))\nax.set_xlim(0, 60)\nax.set_ylim(0, 100)\nax.set_xlabel('Result')\nax.set_ylabel('Chance of getting at least (%)')\nax.grid()\nplt.show()",
"source": "%pip install icepool\n\nimport icepool\n\nclass CthulhuTechEval(icepool.MultisetEvaluator):\n def next_state(self, state, outcome, count):\n score, run = state or (0, 0)\n if count > 0:\n set_score = outcome * count\n run_score = 0\n run += 1\n if run >= 3:\n # This could be the triangular formula, but it's clearer this way.\n for i in range(run): run_score += (outcome - i)\n score = max(set_score, run_score, score)\n else:\n # No dice rolled this number, so the score remains the same.\n run = 0\n return score, run\n\n def final_outcome(self, final_state):\n # Return just the score.\n return final_state[0]\n \n # Outcomes should be seen in consecutive order.\n extra_outcomes = icepool.MultisetEvaluator.consecutive\n\nimport matplotlib.pyplot as plt\n\ndefault_colors = plt.rcParams['axes.prop_cycle'].by_key()['color']\nevaluator = CthulhuTechEval()\nfigsize = (16, 9)\nfig, ax = plt.subplots(figsize=figsize)\n\nfor num_dice in range(1, 11):\n pool = icepool.d10.pool(num_dice)\n result = evaluator.evaluate(pool)\n ax.plot([x for x in range(101)], [result.probability('>=', x, percent=True) for x in range(101)])\n marker_size = 64 if num_dice < 10 else 128\n ax.scatter(result.median(), 50.0,\n marker=('$%d$' % num_dice),\n facecolor=default_colors[num_dice-1],\n s=marker_size)\n\nax.set_xticks(range(0, 61, 5))\nax.set_yticks(range(0, 101, 10))\nax.set_xlim(0, 60)\nax.set_ylim(0, 100)\nax.set_xlabel('Result')\nax.set_ylabel('Chance of getting at least (%)')\nax.grid()\nplt.show()",
"metadata": {
"trusted": true
},
Expand Down

0 comments on commit c7ad7dc

Please sign in to comment.