<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Will&#39;s Stats Emporium</title>
<link>https://williammedwid.com/posts.html</link>
<atom:link href="https://williammedwid.com/posts.xml" rel="self" type="application/rss+xml"/>
<description>A blog built with Quarto</description>
<generator>quarto-1.9.37</generator>
<lastBuildDate>Tue, 30 Jun 2026 07:00:00 GMT</lastBuildDate>
<item>
  <title>Boad Game Design: A Better Blade</title>
  <dc:creator>William Medwid</dc:creator>
  <link>https://williammedwid.com/posts/2026-06-30-a-better-blade/</link>
  <description><![CDATA[ 





<p>Sharing some progress on the board game I’m designing! This game has been almost 7 years in the making, with my first recorded iterations starting in 2019. In the <a href="https://docs.google.com/document/d/1LOGjD71TAOg6eka8LJ0YQiMUDCNQFQuq7egxFahBkS0/edit?tab=t.0" title="Google Doc with rules to A Better Blade">rules doc</a>. Alongside the rules, I’ve recorded the evolution of every change to the rules, and explanations for the intended effect of each.</p>
<p>The result of all this iteration is, in my opinion, a clever tactical game in which 2 to 4 players will continually outmatch the others by deploying armies that exploit the others’ weaknesses. Each player is trying to conquer four out of the many castles on the board, and do everything it takes to stop the others from doing the same.</p>
<p>This game is played on a modular hexagonal board made by the players, with a unique geometry each game.</p>
<p>The core of the game is the weapon triangle: Spears beats Swords, Swords beats Axes, Axes beats Spears. In order to destroy an opponent’s units, you’ll need to assemble a group larger than theirs, of the type of weapon that beats theirs (with an attacking group of 4+ being counted as larger).</p>
<p>For example, in the scenario below, Purple has two swords next to Red’s one axe. 2 &gt; 1 and swords defeat axes, so purple can destroy red’s axe. And Blue has four axes next to Yellow’s 4 spears. Since axes defeat spears, and a group of 4 attackers is always considered larger, Blue can destroy Yellow’s spears one by one.</p>
<p><img src="https://williammedwid.com/posts/2026-06-30-a-better-blade/captureExamples.jpg" class="img-fluid"></p>
<p>This weapons triangle makes for a constantly shifting landscape where your soldiers have very decisive victories and losses.</p>
<p>If you’re interested, you can play this game virtually on <a href="https://steamcommunity.com/sharedfiles/filedetails/?id=2223886773">Tabletop Simulator</a>! This game is still in development, so any feedback is appreciated.</p>



 ]]></description>
  <category>boardgames</category>
  <category>projects</category>
  <guid>https://williammedwid.com/posts/2026-06-30-a-better-blade/</guid>
  <pubDate>Tue, 30 Jun 2026 07:00:00 GMT</pubDate>
  <media:content url="https://williammedwid.com/posts/2026-06-30-a-better-blade/featured.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Brave Rats: First Turn Analysis</title>
  <dc:creator>William Medwid</dc:creator>
  <link>https://williammedwid.com/posts/2026-06-29-brave-rats-first-turn/</link>
  <description><![CDATA[ 





<section id="my-blog-and-brave-rats" class="level1">
<h1>My Blog and Brave Rats</h1>
<p>To kick off my updated blog site, I’m re-visiting some data from my <a href="https://digitalcommons.calpoly.edu/theses/2810/">Master’s thesis</a> on the card game <a href="https://boardgamegeek.com/boardgame/112373/braverats">Brave Rats</a>. If you’re not familiar with the game (it’s not too widely known), the simplest explanation is that it’s a series of simultaneous-move card reveals, where the player with the highest card will win the round, but each card has a special ability that may change the outcome. First to four victories wins. For reference, the card abilities are as follows:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Strength</th>
<th>Name</th>
<th>Ability</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>0</td>
<td>Musician</td>
<td>Round is a tie.</td>
</tr>
<tr class="even">
<td>1</td>
<td>Princess</td>
<td>Wins the full game if played against Prince (7).</td>
</tr>
<tr class="odd">
<td>2</td>
<td>Spy</td>
<td>Next round, your opponent must show their card first.</td>
</tr>
<tr class="even">
<td>3</td>
<td>Assassin</td>
<td>The lower card wins this round.</td>
</tr>
<tr class="odd">
<td>4</td>
<td>Ambassador</td>
<td>If you win with this card, you gain an additional round win.</td>
</tr>
<tr class="even">
<td>5</td>
<td>Wizard</td>
<td>Nullifies your opponent’s ability.</td>
</tr>
<tr class="odd">
<td>6</td>
<td>General</td>
<td>Next round, your card’s strength is increased by 2.</td>
</tr>
<tr class="even">
<td>7</td>
<td>Prince</td>
<td>You win the round (meaning that this card beats Assassin (3)).</td>
</tr>
</tbody>
</table>
<p>For a complete explanation, I recommend reading the introduction of my <a href="https://digitalcommons.calpoly.edu/theses/2810/">thesis</a> or watching this 2-minute video tutorial:</p>
<div class="quarto-video ratio ratio-16x9"><iframe data-external="1" src="https://www.youtube.com/embed/BfU4ccvL3kI" title="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
<p>In this article, I’ll look at three main questions:</p>
<ol type="1">
<li><p>How does my set of players play the first turn of Brave Rats?</p></li>
<li><p>Have their strategies used with knowledge of the optimal MiniMax strategy?</p></li>
<li><p>Are there any weaknesses we can exploit with this knowledge?</p></li>
</ol>
<p>Using a dataset of 154 recorded games and the MiniMax solution to the game, we’ll see that human players have converged towards the MiniMax solution, but still show slight exploitable imperfections in their first-turn plays.</p>
<p>The MiniMax optimal solution I’m suggesting could be summarized as a perfectly unpredictable player - they perfectly mix up their choices so that no matter what you play, you’ll never get more than a 50% chance to beat it.</p>
<section id="human-strategies-over-time" class="level2">
<h2 class="anchored" data-anchor-id="human-strategies-over-time">Human Strategies Over Time</h2>
<p>Unlike in Chess, where one may find success repeating the same opening move every game, in Brave Rats, any such predictable choices will bring a quick defeat, as every card has a weakness. Thus, one must instead try to be unpredictable and select cards according to a distribution that will be hard to beat. As such, I’ll be lumping many first-turn plays from different players together to create an aggregate understanding of how humans play. This means that instead of treating Brave Rats as a mind game about predicting your opponent, we’ll study it in terms of distributions of cards played.</p>
<p>So, we’ll take a look at how often each card has been played. I’ll make one distinction though: the plays from before I calculated and shared the MiniMax optimal strategy, and those after. Have we learned the ways of the machine?</p>
<div class="cell">
<details class="code-fold">
<summary>See code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># PLOT 1: FIRST TURN PLAY RATES</span></span>
<span id="cb1-2">flatStartCards <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> fullSet <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb1-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(P1Card, optimalKnown) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span>(</span>
<span id="cb1-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb1-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">wins =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(P1Wins <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb1-7">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(optimalKnown) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">playRate =</span> n<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(n)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb1-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source =</span> optimalKnown) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">union</span>(optimalProbs) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cardLabels, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P1Card"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"card"</span>))</span>
<span id="cb1-14"></span>
<span id="cb1-15"></span>
<span id="cb1-16">custom_theme <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb1-18">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Standard Element Removal/Adjustment</span></span>
<span id="cb1-19">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Since this is not a facet plot, we generalize these removals</span></span>
<span id="cb1-20">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb1-21">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#strip.text = element_blank(),</span></span>
<span id="cb1-22">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># General clean-up</span></span>
<span id="cb1-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.grid.major =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb1-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.grid.minor =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb1-25">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Legend adjustments</span></span>
<span id="cb1-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"top"</span>,</span>
<span id="cb1-27">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"horizontal"</span>,</span>
<span id="cb1-28">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Adding a general box (if desired, use panel.border if this is the only panel)</span></span>
<span id="cb1-29">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.border =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(</span>
<span id="cb1-30">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>,</span>
<span id="cb1-31">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb1-32">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span></span>
<span id="cb1-33">    ),</span>
<span id="cb1-34">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Title formatting</span></span>
<span id="cb1-35">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>),</span>
<span id="cb1-36">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb1-37">  )</span>
<span id="cb1-38"></span>
<span id="cb1-39">flatStartCards <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-40">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(source, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pre-Optimal"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Post-Optimal"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Optimal"</span>)))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-41">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> cardLabel, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> playRate, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> source)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-42">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dodge"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Use "dodge" to place bars side-by-side</span></span>
<span id="cb1-43">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(</span>
<span id="cb1-44">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">percent</span>(playRate, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">accuracy =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)),</span>
<span id="cb1-45">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_dodge</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>),</span>
<span id="cb1-46">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>,</span>
<span id="cb1-47">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#hjust = -0.1,</span></span>
<span id="cb1-48">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span></span>
<span id="cb1-49">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-50">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mult =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-51">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Distributions of First-Turn Plays"</span>,</span>
<span id="cb1-52">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Starting Card"</span>,</span>
<span id="cb1-53">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Probability of Round 1 Play"</span>,</span>
<span id="cb1-54">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-55">  custom_theme <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-56">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb1-57">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.ticks.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>()) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb1-58">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(</span>
<span id="cb1-59">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb1-60">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pre-Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#6BAED6"</span>,</span>
<span id="cb1-61">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Post-Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#9467bd"</span>,</span>
<span id="cb1-62">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#D95F0E"</span></span>
<span id="cb1-63">    ),</span>
<span id="cb1-64">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pre-Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed Before MiniMax"</span>,</span>
<span id="cb1-65">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Post-Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed After MiniMax"</span>,</span>
<span id="cb1-66">               <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MiniMax Optimal Strategy"</span></span>
<span id="cb1-67">              ))</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://williammedwid.com/posts/2026-06-29-brave-rats-first-turn/index_files/figure-html/unnamed-chunk-1-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>For the most part, it looks like we’ve trended in the right direction. Spy (2) has gone from significantly over-played to just a few percentage points above the optimal rate. With Assassin (3) being played more often, the biggest remaining difference is that we’ve played Wizard (5) far less than the optimal rate - this has been intentional, due to the difficulty adjusting to playing the late game with the Wizard (5) already expended.</p>
<p>Even after MiniMax has been known, we still have a few instances of players (knowingly) choosing cards that would never be played under the optimal strategy. From one point of view, this may be simply blundering or messing around, but it’s always entirely possible that an unexpected play will do even better against flawed human opponents.</p>
<p>But we don’t just want to know which cards are played the most, we want to know which ones will actually perform the best in practice. In the chart below, you’ll see the observed win rates for each card.</p>
<div class="cell">
<details class="code-fold">
<summary>See code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">perCardWinRatesExpectations <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> optimalWinRates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-2">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Calculating expected chance of winning due to each card pairing by multiplying MiniMax of A vs B by the probability that opponent plays B</span></span>
<span id="cb2-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(flatStartCards,<span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># %&gt;% filter(source != 'Optimal'), </span></span>
<span id="cb2-4">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P2Card"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P1Card"</span>),</span>
<span id="cb2-5">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">suffix =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_flat"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb2-6">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Add up those up for each of P1's cards</span></span>
<span id="cb2-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(P1Card, cardLabelP1, source) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expectedWinRate =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(OptimalWinP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> playRate)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-9">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Joining to flatStartCards again by P1Card to get the actual winrates</span></span>
<span id="cb2-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(flatStartCards, </span>
<span id="cb2-11">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P1Card"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P1Card"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"source"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"source"</span>),</span>
<span id="cb2-12">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">suffix =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_flat"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">winRate =</span> wins <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> n,</span>
<span id="cb2-14">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjustedWinRate =</span> (wins<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (n<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pivot_longer</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cols =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(expectedWinRate, winRate), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">names_to =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"expectedOrActual"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_to =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"winRate"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expectedOrActual =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(expectedOrActual <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'expectedWinRate'</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Expected'</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Observed'</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rowwise</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb2-19">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf_low =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(n) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> expectedOrActual <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Expected'</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">binom.test</span>(wins <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf.level =</span> conf_level)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conf.int[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]), <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ADJUSTED WALD CI</span></span>
<span id="cb2-20">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf_high =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(n) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> expectedOrActual <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Expected'</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">binom.test</span>(wins <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf.level =</span> conf_level)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conf.int[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb2-21">  )</span>
<span id="cb2-22"></span>
<span id="cb2-23">perCardWinRatesExpectations <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(source <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Optimal"</span>, expectedOrActual <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(source, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pre-Optimal"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Post-Optimal"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Optimal"</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-26">  </span>
<span id="cb2-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(</span>
<span id="cb2-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> cardLabelP1,</span>
<span id="cb2-29">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> adjustedWinRate,</span>
<span id="cb2-30">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> source</span>
<span id="cb2-31">  )) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-32">  </span>
<span id="cb2-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(</span>
<span id="cb2-34">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb2-35">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>,</span>
<span id="cb2-36">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span></span>
<span id="cb2-37">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-38">  </span>
<span id="cb2-39">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(</span>
<span id="cb2-40">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dodge"</span>,</span>
<span id="cb2-41">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>,</span>
<span id="cb2-42">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>,</span>
<span id="cb2-43">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span></span>
<span id="cb2-44">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-45">  </span>
<span id="cb2-46">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(</span>
<span id="cb2-47">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> conf_low, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> conf_high),</span>
<span id="cb2-48">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_dodge</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>),</span>
<span id="cb2-49">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span></span>
<span id="cb2-50">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-51">  </span>
<span id="cb2-52">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_label</span>(</span>
<span id="cb2-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(</span>
<span id="cb2-54">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">percent</span>(adjustedWinRate, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">accuracy =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb2-55">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> source</span>
<span id="cb2-56">    ),</span>
<span id="cb2-57">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_dodge</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>),</span>
<span id="cb2-58">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>,</span>
<span id="cb2-59">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span>,</span>
<span id="cb2-60">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>,</span>
<span id="cb2-61">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>,</span>
<span id="cb2-62">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label.size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb2-63">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-64">  </span>
<span id="cb2-65">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(</span>
<span id="cb2-66">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb2-67">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>percent,</span>
<span id="cb2-68">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mult =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>))</span>
<span id="cb2-69">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-70">  </span>
<span id="cb2-71">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb2-72">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed Win Rates For Each Card"</span>,</span>
<span id="cb2-73">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(Adjusted Wald estimates w/ 90% confidence intervals)"</span>,</span>
<span id="cb2-74">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb2-75">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb2-76">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb2-77">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-78">  </span>
<span id="cb2-79">  custom_theme <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-80">  </span>
<span id="cb2-81">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb2-82">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb2-83">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.ticks.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb2-84">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>)</span>
<span id="cb2-85">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-86">  </span>
<span id="cb2-87">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(</span>
<span id="cb2-88">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb2-89">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pre-Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#6BAED6"</span>,</span>
<span id="cb2-90">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Post-Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#9467bd"</span></span>
<span id="cb2-91">    ),</span>
<span id="cb2-92">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb2-93">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pre-Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed Before MiniMax"</span>,</span>
<span id="cb2-94">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Post-Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed After MiniMax"</span></span>
<span id="cb2-95">    )</span>
<span id="cb2-96">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://williammedwid.com/posts/2026-06-29-brave-rats-first-turn/index_files/figure-html/unnamed-chunk-2-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>Before the MiniMax model, Wizard (5) appears to have been the most effective play, albeit a rare one, with Spy (2) being the most common one with a positive win rate. Note that Princess shows well, but with so little data that we see in its confidence interval we have a very unclear estimate of how much it would win in the long run. Unfortunately, due to the limited number of games recorded, you’ll notice that every confidence interval in this chart spans the 50% line, so we technically can’t even prove that any of these cards have a win rate different than 50%.</p>
<p>After the release of the MiniMax model, Assassin (3) and Ambassador (4) have been the most effective out of the commonly played starter cards. General (6) has done surprisingly well, raising the possibility that it could be viable against flawed human opponents despite not being recommended by the optimal model.</p>
<p>Spy (2) has surprisingly under-performed, with its confidence interval almost entirely below a 50% win rate, indicating we can almost confidently say that Spy (2) play has poor outcomes under current strategies. This suggests that our follow-up responses to Spy (2) have improved by observing the MiniMax model (such as the idea of throwing away Assassin (3)), but follow-ups from the Spy (2) player have failed to keep up.</p>
</section>
<section id="using-tactics-from-minimax-to-exploit-human-imperfections" class="level2">
<h2 class="anchored" data-anchor-id="using-tactics-from-minimax-to-exploit-human-imperfections">Using Tactics from MiniMax to Exploit Human Imperfections</h2>
<p>We can go deeper than these uncertain estimates, though, and find true theoretical exploits to get the best win rates.</p>
<p>To understand the overall space of decisions being made on turn 1, see these expected game from each turn-1 matchup. The best possible outcome is that you play Princess (1) and your opponent plays Prince (7), as the Princess’s (1) ability reads “If your opponent plays the prince, you automatically win the game”.</p>
<div class="cell">
<details class="code-fold">
<summary>See code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">optimalWinRates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb3-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> cardLabelP1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> cardLabelP2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> OptimalWinP)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_tile</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-4">  </span>
<span id="cb3-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f%%"</span>, OptimalWinP <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span>)),</span>
<span id="cb3-6">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_gradient2</span>(</span>
<span id="cb3-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">low =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#6A3D9A"</span>,</span>
<span id="cb3-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mid =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>,</span>
<span id="cb3-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">high =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#E68600"</span>,</span>
<span id="cb3-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">midpoint =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb3-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">limits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb3-13">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_abline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pink"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb3-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Theoretical (MiniMax) Win Probabilities by First Turn Outcome"</span>,</span>
<span id="cb3-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Your Card"</span>,</span>
<span id="cb3-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Opponent's Card"</span></span>
<span id="cb3-19">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_discrete</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_discrete</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-22">  custom_theme <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb3-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb3-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">angle =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb3-25">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.grid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb3-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>),</span>
<span id="cb3-27">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>,</span>
<span id="cb3-28">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#panel.border = element_blank(),</span></span>
<span id="cb3-29">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.line =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>()</span>
<span id="cb3-30">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://williammedwid.com/posts/2026-06-29-brave-rats-first-turn/index_files/figure-html/unnamed-chunk-3-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>This chart is the core of turn 1 gameplay, and is a lot of information, but can be simplified into these 3 bite sized pieces of info:</p>
<ol type="1">
<li><p>The “Main 3” starters form a rock-paper-scissors trio: Spy (2) beats Assassin (3), Assassin (3) beats Ambassador (4), and Ambassador (4) beats Spy (2).</p></li>
<li><p>Wizard (5) is a solid choice as it gives a slight advantage against each of the “Main 3”.</p></li>
<li><p>Prince (7) is the best option to defeat Wizard (5) - even if you just play it 5% of the time, it’ll stop your opponent from getting an advantage by playing Wizard (5) every game.</p></li>
</ol>
<p>With this, we have the two ingredients to select a “best” card under any distribution - we know how likely they are to play each card, and how theoretically good or bad each card would be. With this, we can pretend the rest of the game doesn’t happen, and just try to get the highest number on this payoff matrix. As an example, if I want to calculate how good it would be to play General (6) against someone who plays turn 1 according to the optimal distribution, I’d start by finding the odds I win against their Spy (2): 22% (odds they play Spy (2)) times 49.2% (Odds I win given that they play Spy (2)) = 10.8%. If I do that calculation for all 8 cards they might play and add them up, I get a total of 48% - so it’s not ideal, but only a couple percent worse than others.</p>
<p>If we calculate the expected win rates this way against the three distributions of turn-1 cards, we get this chart:</p>
<div class="cell">
<details class="code-fold">
<summary>See code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">perCardWinRatesExpectations <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb4-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(expectedOrActual <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Expected"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb4-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(source, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pre-Optimal"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Post-Optimal"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Optimal"</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb4-4">  </span>
<span id="cb4-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(</span>
<span id="cb4-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> cardLabelP1,</span>
<span id="cb4-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> winRate,</span>
<span id="cb4-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> source</span>
<span id="cb4-9">  )) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(</span>
<span id="cb4-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb4-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>,</span>
<span id="cb4-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span></span>
<span id="cb4-14">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(</span>
<span id="cb4-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dodge"</span>,</span>
<span id="cb4-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>,</span>
<span id="cb4-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>,</span>
<span id="cb4-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span></span>
<span id="cb4-20">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(</span>
<span id="cb4-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(</span>
<span id="cb4-23">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">percent</span>(winRate, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">accuracy =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb4-24">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> source</span>
<span id="cb4-25">    ),</span>
<span id="cb4-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_dodge</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>),</span>
<span id="cb4-27">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>,</span>
<span id="cb4-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span></span>
<span id="cb4-29">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(</span>
<span id="cb4-31">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb4-32">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>percent,</span>
<span id="cb4-33">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mult =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>))</span>
<span id="cb4-34">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-35">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb4-36">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Theoretical Win Rates For Each Card vs. Different Starting Distributions"</span>,</span>
<span id="cb4-37">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Assuming MiniMax optimal play after first turn"</span>,</span>
<span id="cb4-38">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Your First Card"</span>,</span>
<span id="cb4-39">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb4-40">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb4-41">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-42">  custom_theme <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-43">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb4-44">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb4-45">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.ticks.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb4-46">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>)</span>
<span id="cb4-47">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb4-48">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(</span>
<span id="cb4-49">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb4-50">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pre-Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#6BAED6"</span>,</span>
<span id="cb4-51">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Post-Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#9467bd"</span>,</span>
<span id="cb4-52">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#D95F0E"</span></span>
<span id="cb4-53">    ),</span>
<span id="cb4-54">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb4-55">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pre-Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed Turn 1 Distribution</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">From Before MiniMax"</span>,</span>
<span id="cb4-56">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Post-Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed Turn 1 Distribution</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">From After MiniMax"</span>,</span>
<span id="cb4-57">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MiniMax Optimal</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Turn 1 Distribution"</span></span>
<span id="cb4-58">    )</span>
<span id="cb4-59">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://williammedwid.com/posts/2026-06-29-brave-rats-first-turn/index_files/figure-html/unnamed-chunk-4-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>So, even though the observed human distributions deviated from what’s optimal, we can see here that even the best card to exploit them (Ambassador (4)) would only get you to a theoretical 54% win rate against the pre-MiniMax players and 52% against post-MiniMax players. This gives hope that, at least for the first turn of the game, our plays have only been exploitable by a few percentage points - even before any knowledge of what was theoretically optimal to play.</p>
<p>In order to demonstrate the usefulness of this great 2% advantage against current players, though, I must also demonstrate that the end-game outcomes from different turn-1 matchups actually do reflect the expected results. To do this, I’ve made a little plot comparing the actual win rates we’ve seen versus the win rates MiniMax expects to see:</p>
<div class="cell">
<details class="code-fold">
<summary>See code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">startAggregates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> fullSet <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-2">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#filter(P1Card %in% c(2,3,4,5,7) &amp; P2Card %in% c(2,3,4,5,7)) %&gt;% </span></span>
<span id="cb5-3">  </span>
<span id="cb5-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(P1Card, P2Card, Outcome) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pivot_wider</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">id_cols =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(P1Card, P2Card), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">names_from =</span> Outcome, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_from =</span> n, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_fill =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> Win <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Loss,</span>
<span id="cb5-8">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf_low =</span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">binom.test</span>(Win <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, Win <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Loss <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf.level =</span> conf_level)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conf.int[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ADJUSTED WALD CI</span></span>
<span id="cb5-9">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf_high =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">binom.test</span>(Win <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, Win <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Loss <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf.level =</span> conf_level)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conf.int[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],</span>
<span id="cb5-10">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">phat =</span> (Win <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (Win <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> Loss <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb5-11">         ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">full_join</span>(optimalWinRates, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P1Card"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"P2Card"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">P2Card=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(P2Card, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"7"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"6"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"5"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"4"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"3"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0"</span>)))</span>
<span id="cb5-15"></span>
<span id="cb5-16">plotData <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> startAggregates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(P1Card <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> P2Card <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-18">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#filter(n &gt;= 4) %&gt;%</span></span>
<span id="cb5-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pivot_longer</span>(</span>
<span id="cb5-20">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cols =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(phat, OptimalWinP),</span>
<span id="cb5-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">names_to =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Type"</span>,</span>
<span id="cb5-22">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_to =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"WinRate"</span></span>
<span id="cb5-23">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb5-25">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Type =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">recode</span>(</span>
<span id="cb5-26">      Type,</span>
<span id="cb5-27">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">phat =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed"</span>,</span>
<span id="cb5-28">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">OptimalWinP =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Optimal"</span></span>
<span id="cb5-29">    ),</span>
<span id="cb5-30">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(</span>
<span id="cb5-31">      cardLabelP1, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" vs. "</span>,</span>
<span id="cb5-32">      cardLabelP2</span>
<span id="cb5-33">    ),</span>
<span id="cb5-34">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n = "</span>, n, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>),</span>
<span id="cb5-35">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">P2Card =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(P2Card, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"7"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"6"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"5"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"4"</span>,<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"3"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0"</span>)) <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># reverse ordering of P2's cards</span></span>
<span id="cb5-36">  )</span>
<span id="cb5-37"></span>
<span id="cb5-38"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(plotData,</span>
<span id="cb5-39">       <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> Type, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> WinRate, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> Type)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-40">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Main Bars</span></span>
<span id="cb5-41">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.65</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-42">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># CI only for observed bars</span></span>
<span id="cb5-43">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(</span>
<span id="cb5-44">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> plotData <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed"</span>),</span>
<span id="cb5-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> conf_low, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> conf_high),</span>
<span id="cb5-46">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span></span>
<span id="cb5-47">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-48">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># CI upper label</span></span>
<span id="cb5-49">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(</span>
<span id="cb5-50">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> plotData <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed"</span>),</span>
<span id="cb5-51">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> conf_high,</span>
<span id="cb5-52">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">percent</span>(conf_high, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">accuracy =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb5-53">    ),</span>
<span id="cb5-54">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.55</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.7</span></span>
<span id="cb5-55">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-56">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># CI lower label</span></span>
<span id="cb5-57">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(</span>
<span id="cb5-58">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> plotData <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed"</span>),</span>
<span id="cb5-59">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> conf_low,</span>
<span id="cb5-60">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">percent</span>(conf_low, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">accuracy =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb5-61">    ),</span>
<span id="cb5-62">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.55</span>,</span>
<span id="cb5-63">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.25</span>,</span>
<span id="cb5-64">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.7</span></span>
<span id="cb5-65">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-66">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># labels on bars</span></span>
<span id="cb5-67">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(</span>
<span id="cb5-68">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> scales<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">percent</span>(WinRate, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">accuracy =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)),</span>
<span id="cb5-69">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.45</span>,</span>
<span id="cb5-70">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>,</span>
<span id="cb5-71">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span></span>
<span id="cb5-72">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-73">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_grid</span>(</span>
<span id="cb5-74">    P2Card <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> P1Card,</span>
<span id="cb5-75">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">switch =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"both"</span></span>
<span id="cb5-76">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-77">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Top of subplot text</span></span>
<span id="cb5-78">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(</span>
<span id="cb5-79">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(</span>
<span id="cb5-80">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.09</span>,</span>
<span id="cb5-81">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> label</span>
<span id="cb5-82">    ),</span>
<span id="cb5-83">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb5-84">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span>,</span>
<span id="cb5-85">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span></span>
<span id="cb5-86">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-87">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># n text</span></span>
<span id="cb5-88">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(</span>
<span id="cb5-89">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(</span>
<span id="cb5-90">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span>,</span>
<span id="cb5-91">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> label_n</span>
<span id="cb5-92">    ),</span>
<span id="cb5-93">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb5-94">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span></span>
<span id="cb5-95">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-96">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mult =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-97">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_cartesian</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ylim =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.18</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">clip =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"off"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-98">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Win Rates for Most Common First Turn Outcomes"</span>,</span>
<span id="cb5-99">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(Adjusted Wald estimates w/ 90% confidence intervals)"</span>,</span>
<span id="cb5-100">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-101">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-102">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb5-103">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove facet grid labels  </span></span>
<span id="cb5-104">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb5-105">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb5-106">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove axis titles</span></span>
<span id="cb5-107">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb5-108">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb5-109">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove axis text (optional for journal figures)</span></span>
<span id="cb5-110">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb5-111">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.ticks.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb5-112">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># remove axis text (optional for journal figures)</span></span>
<span id="cb5-113">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb5-114">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.ticks.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb5-115">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.grid.major =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb5-116">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.grid.minor =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb5-117">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"top"</span>,</span>
<span id="cb5-118">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"horizontal"</span>,</span>
<span id="cb5-119">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># add box around each facet</span></span>
<span id="cb5-120">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.border =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span>(</span>
<span id="cb5-121">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>,</span>
<span id="cb5-122">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb5-123">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span></span>
<span id="cb5-124">      ),</span>
<span id="cb5-125">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.spacing =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unit</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lines"</span>),</span>
<span id="cb5-126">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>),</span>
<span id="cb5-127">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>)</span>
<span id="cb5-128">        ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-129">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Color palette (clean + print safe)</span></span>
<span id="cb5-130">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(</span>
<span id="cb5-131">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb5-132">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#6BAED6"</span>,</span>
<span id="cb5-133">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#D95F0E"</span></span>
<span id="cb5-134">    ),</span>
<span id="cb5-135">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb5-136">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Observed Win Rate"</span>,</span>
<span id="cb5-137">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Optimal"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Theoretical MiniMax Win Rate"</span></span>
<span id="cb5-138">    ),</span>
<span id="cb5-139">  )</span></code></pre></div></div>
</details>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://williammedwid.com/posts/2026-06-29-brave-rats-first-turn/index_files/figure-html/unnamed-chunk-5-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>And it looks like each of these matches quite well! Between cards 2, 3 and 4, the human outcomes are within 2 percentage points of the optimal model’s. With Wizard (5), we have tiny sample sizes so such proximity wouldn’t be possible, but at least they’re directionally correct as to which side has the advantage.</p>
<p>With the clear similarity of human post-turn-1 results to what MiniMax, and knowledge of the optimal model, we can now say that Ambassador (4) seems to legitimately have a slight edge against current players’ strategies - a 52% win rate if by the theory, or 60% win rate in the real games.</p>
</section>
<section id="conclusion" class="level2">
<h2 class="anchored" data-anchor-id="conclusion">Conclusion</h2>
<p>What surprised me most from this analysis was not that humans fail to play optimally, but that even trial and error got us so close to an optimal distribution. With the analysis only being able to produce a 4% lead off of the first turn against players who had no systematic knowledge of the game, it shows both the power of our intuition and reasoning which may extend to other similar games.</p>
<p>As we’ve converged closer to MiniMax optimal play, we’ve narrowed the vulnerability to a 2% turn-1 advantage. This convergence demonstrates a fascinating ability to carry on the mind games of trying to predict your opponent’s first move, while weighting the options according to a more complex distribution. Definitely don’t take the 2% advantage of Ambassador (4) to mean you should play it all the time… or should you?</p>
<section id="disclaimers" class="level3">
<h3 class="anchored" data-anchor-id="disclaimers">Disclaimers</h3>
<p>A few notes on statistical assumptions that are broken</p>
<ol type="1">
<li><p>47.4% of these plays are my own, so some trends may be more based on my own quirks than any larger meaning about people or the game. I didn’t find enough interesting between-player trends to make it a topic worth exploring much in this article.</p></li>
<li><p>Apart from myself, this is certainly a convenience sample of my friends, so different groups would certainly get different results.</p></li>
<li><p>Binomial (win rate) estimates and confidence intervals in this article are calculated using an <a href="https://measuringu.com/calculators/wald/">Adjusted Wald</a> intervals. These help with some smaller sample sizes by mimicking a Beta(2,2) Bayesian estimation, biasing the estimates toward 50%.</p></li>
<li><p>None of this gameplay is independent, so Binomial assumptions are surely broken anyway.</p></li>
<li><p>Tied games have been excluded for simplicity. MiniMax “win rates” are technically “expected values” where a win is one point and a tie is half a point (Brave Rats ends in a tie if neither player achieves 4 victories by the end). By doing so, I’ve enabled good binomial math, but this leads our human results to be unlike the optimal model’s - for the MiniMax model, a strategy that allows you to tie a losing game is very beneficial, whereas for the human data such a capability is just being ignored. In any case, it’s only 5 games of data, so shouldn’t make too much difference.</p></li>
<li><p>In plot #1 with the first-turn distributions, error bars based on a F statistic would likely be appropriate, though this plot may also just be understood as displaying existing data and not making any such hypothesis tests. This would also imply I should subsequently add error bars to the Theoretical Win Rates For Each Card vs.&nbsp;Different Starting Distributions plot, but I’m not aware of any methodology to do such a thing when the error bars would dependent on one another and any theoretical win rate would need the probabilities to add to 100%.</p></li>
<li><p>This post is adapted from one I wrote in 2020, but pretty much a total re-write.</p></li>
<li><p>As the 2% advantage suggests, I hope this analysis doesn’t give too much of an impression that I’ll be winning overwhelmingly by exploiting outside analysis. Such methods may sometimes be frowned upon in the board game community for circumventing the fun of discovering tactics organically, so I avoid it in many cases. In my experience, though, Brave Rats has been even more cherished alongside deep analysis though, and it lends it to scrutiny well, while being quite difficult to implement the optimizations much beyond memorizing the first turn distribution. Perhaps my meager 54% win rate (despite many games against people new to the game) can dissuade any such fears.</p></li>
</ol>


<!-- -->

</section>
</section>
</section>

 ]]></description>
  <category>analysis</category>
  <category>r</category>
  <category>boardgames</category>
  <guid>https://williammedwid.com/posts/2026-06-29-brave-rats-first-turn/</guid>
  <pubDate>Mon, 29 Jun 2026 07:00:00 GMT</pubDate>
  <media:content url="https://williammedwid.com/posts/2026-06-29-brave-rats-first-turn/featured.png" medium="image" type="image/png" height="177" width="144"/>
</item>
<item>
  <title>Study 25-35 Hours a Week? The Life of a First-Year Statistics Major</title>
  <dc:creator>William Medwid</dc:creator>
  <link>https://williammedwid.com/posts/2020-08-26-25-35-study-hours-a-week-the-life-of-a-statistics-major/</link>
  <description><![CDATA[ 





<p>Not all college slogans are the real inspirational type. Cal Poly happens to have a funnily direct one: Study 25-35 hours per week. At first while touring the school, it seems to be everywhere from posters on the wall to pins and magnets given out at orientation. 2 hours per week per unit, outside lecture, sounds like it’d add up to a whole lot. So, I’ve got to ask, does it match up with what students actually do?</p>
<p>As a bit of a spreadsheet nerd, I’ve found myself in a great position to dive into this question and see if I’ve lived up to the slogan myself. Ever since my second year of high school, consistently recording my time spent on academics in a spreadsheet has been an integral part of my work flow. Each assignment is added as a new row once it’s assigned, and I’ll do my best to describe it and estimate how long it’ll take to complete. This makes a dynamic to-do list where I can punch in and out, recording the time in helper columns. Once the assignment is done and I’ve recorded every minute spent on it, it’s filtered out of sight, clearing the list.</p>
<p>Now, let’s take a look at the most important parts of raw data, as that’s often the best way to understand what we’re working with. This includes every assignment and class over my first year of college. Feel free to explore the data with the interactive table below.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Libraries </span></span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(stringr)</span>
<span id="cb1-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(DT)</span>
<span id="cb1-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(lubridate)</span>
<span id="cb1-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(modelr)</span>
<span id="cb1-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(widgetframe)</span>
<span id="cb1-8"></span>
<span id="cb1-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Data</span></span>
<span id="cb1-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Note: This data is slightly pre-cleaned so only relevant columns and classes are there, and to avoid excess personal information.</span></span>
<span id="cb1-11"></span>
<span id="cb1-12">all_quarters <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Summer 2019"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fall 2019"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Winter 2020"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Spring 2020"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Summer 2020"</span>)</span>
<span id="cb1-13">online_quarters <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Spring 2020"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Summer 2020"</span>)</span>
<span id="cb1-14">units <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)</span>
<span id="cb1-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Best to define these here, they'll matter later.</span></span>
<span id="cb1-16"></span>
<span id="cb1-17">study_time <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"collegeFirstYear.csv"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Completed =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mdy</span>(Completed))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Assignment =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(Title <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_trunc</span>(Title, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">45</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_c</span>(Type, Tasks_Predicted, Units, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">week_completed =</span> Completed <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">floor_date</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">unit=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"week"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Quarter =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(Quarter, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> all_quarters)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">quarter_units =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(Quarter,</span>
<span id="cb1-23">                             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels=</span>all_quarters,</span>
<span id="cb1-24">                             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels=</span>units)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Minutes =</span> Min_Real) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb1-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Class <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GameDevClub"</span>)</span>
<span id="cb1-27"></span>
<span id="cb1-28">widget <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> DT<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">datatable</span>(study_time <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(Completed,Class,Assignment,Minutes), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rownames =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb1-29">widgetframe<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">frameWidget</span>(widget, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'100%'</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'100%'</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div id="htmlwidget-db55b888cb47b98f8e06" style="width:100%;height:100%;" class="widgetframe html-widget"></div>
<script type="application/json" data-for="htmlwidget-db55b888cb47b98f8e06">{"x":{"url":"index_files/figure-html//widgets/widget_data.html","options":{"xdomain":"*","allowfullscreen":false,"lazyload":false}},"evals":[],"jsHooks":[]}</script>
</div>
</div>
<p>Next, we’ll aggregate these tasks and see how much work there was on a weekly basis.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1">workloads <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> study_time <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(week_completed, Quarter, quarter_units) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Class"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> Type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> Quarter <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> online_quarters) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Only counting weeks where there were classes or the quarter was online.</span></span>
<span id="cb2-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">week_workload =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(Minutes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm=</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(week_completed, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.keep_all =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb2-7"></span>
<span id="cb2-8">workloads <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb2-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x=</span>week_completed, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y=</span>week_workload, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color=</span>Quarter)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xlab</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Week"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ylab</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hours of Academics Completed"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb2-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggtitle</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Academic workload over time (including lectures)"</span>)</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://williammedwid.com/posts/2020-08-26-25-35-study-hours-a-week-the-life-of-a-statistics-major/index_files/figure-html/first_chart-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Mean is the statistic of choice because large projects can take a long time and end up with work from one week being counted in another.</span></span>
<span id="cb3-2">conf_interval <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">t.test</span>(workloads<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>week_workload, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mu=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alternative =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"less"</span>)</span>
<span id="cb3-3"></span>
<span id="cb3-4">class_time_total <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> study_time <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb3-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Type<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Class"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pull</span>(Minutes) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm=</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb3-6">study_time_total <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> study_time <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb3-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Type<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Class"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pull</span>(Minutes) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm=</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb3-8">percent_in_class <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (class_time_total <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (class_time_total <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> study_time_total))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span></code></pre></div></div>
</div>
<p>Alas, I’ve only spent a mean of 19.7 hours per week, a good ways from 25, let alone 35. And that’s with classes included, which are 29% of that time. Apart from the intensive 4-week 8-unit 2019 summer session, there’s very little case to be made that I ended up having a typical 25-35 hour week, other than to consider the time spent traveling between classes, which, though quite time consuming, which is not included in my data, but could hardly be called studying.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">conf_interval_per_unit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">t.test</span>(workloads<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>week_workload<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>units, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mu=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alternative =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"less"</span>)</span></code></pre></div></div>
</div>
<p>Another more charitable way to reconcile my schedule with the ideal would be to look at the per-unit time spent. It turns out that’s a more positive 1.7 hours, or the equivalent of 27.7 hours for a 16-unit schedule. This is still including classes but feels almost like victory nonetheless.</p>
<p>Next, let’s see which classes were the ones that never required super rigorous homework?</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">workloads_by_class <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> study_time <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Class <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"General"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Removing non class-specific academic imperatives</span></span>
<span id="cb5-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(week_completed) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Class"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> Type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> Quarter <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> online_quarters) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Only counting weeks where there were classes or the quarter was online.</span></span>
<span id="cb5-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Class"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(Class,week_completed, Quarter, quarter_units) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">week_workload =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(Minutes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm=</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(week_completed, Class, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.keep_all =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb5-11"></span>
<span id="cb5-12">workloads_by_class <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> </span>
<span id="cb5-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y=</span>Class,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x=</span>week_workload)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"orangered"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xlab</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Weekly Workload (Excluding Classes)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rows=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vars</span>(Quarter), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">scales =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"free_y"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_vline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"darkgreen"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>))</span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="https://williammedwid.com/posts/2020-08-26-25-35-study-hours-a-week-the-life-of-a-statistics-major/index_files/figure-html/unnamed-chunk-3-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>The chart shows only three classes below the two hour line, which match my memories of the less rigorous yet still valuable courses. Note that of the outlier groups may be exaggerated because a project done slowly over many days only counts on the week when it’s completed, unless I’ve broken the project into multiple component tasks.</p>
<p>So, does Cal Poly require a full 25-35 hours a week of homework? Not for me at least. But I suppose the slogan “study 10-20 hours a week, whatever you’re feeling” would be far less inspiring. Also, I’m fairly certain architecture majors exceed 35 hours by at least a factor of two anyway.</p>



 ]]></description>
  <category>analysis</category>
  <category>academics</category>
  <category>r</category>
  <guid>https://williammedwid.com/posts/2020-08-26-25-35-study-hours-a-week-the-life-of-a-statistics-major/</guid>
  <pubDate>Wed, 26 Aug 2020 07:00:00 GMT</pubDate>
  <media:content url="https://williammedwid.com/posts/2020-08-26-25-35-study-hours-a-week-the-life-of-a-statistics-major/image.png" medium="image" type="image/png" height="111" width="144"/>
</item>
</channel>
</rss>
