\documentclass[11pt,a4paper]{article}

% Efron's Dice Project — jmaths house style (matches the Y10 statistics pack).
% Build: pdflatex efron_dice_project.tex (single pass).

\usepackage[top=1cm, bottom=1cm, left=1.2cm, right=1.2cm, includeheadfoot, headheight=14pt]{geometry}
\usepackage{amsmath, amssymb}
\usepackage{xcolor}
\usepackage{tcolorbox}
\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage{enumitem}
\usepackage{booktabs}
\usepackage[hidelinks]{hyperref}

\usetikzlibrary{arrows.meta, calc}

% --- Colours ---
\definecolor{mypdark}{RGB}{0,70,127}
\definecolor{myplight}{RGB}{220,235,248}
\definecolor{mypamber}{RGB}{210,110,30}
\definecolor{answerline}{RGB}{180,180,180}
\definecolor{gridcol}{RGB}{210,220,235}
\definecolor{boxshade}{RGB}{245,247,250}
% Canonical dice piece colours (match the live app)
\definecolor{diegreen}{HTML}{2E8B57}
\definecolor{dieyellow}{HTML}{E0A800}
\definecolor{diered}{HTML}{C0392B}
\definecolor{diepurple}{HTML}{6F42C1}

% --- Header / Footer ---
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\lhead{\textbf{Efron's Dice Project} \quad \textit{MYP Year 10 Mathematics}}
\rhead{}
\cfoot{\thepage}
\lfoot{\textit{jmaths.xyz}}
\rfoot{J.~Murphy}

\tcbuselibrary{skins, breakable}

\newtcolorbox{scenariobox}[1]{
  colback=white, colframe=mypamber,
  boxrule=1pt, arc=3pt,
  fonttitle=\bfseries\color{white},
  coltitle=white, colbacktitle=mypamber,
  title={#1},
  left=8pt, right=8pt, top=3pt, bottom=4pt
}

\newtcolorbox{questionbox}[1]{
  colback=white, colframe=mypdark,
  boxrule=0.8pt, arc=4pt,
  fonttitle=\bfseries,
  title={#1},
  left=6pt, right=6pt, top=3pt, bottom=4pt,
  breakable
}

\setlist[enumerate]{topsep=2pt, itemsep=4pt, parsep=0pt, leftmargin=1.4em}

% --- A die net: cross shape, four vertical faces + two flanks on row 2 ---
% \dienet{colour}{name}{top}{left}{centre}{right}{third}{bottom}
\newcommand{\dienet}[8]{%
  \begin{tikzpicture}[scale=0.56, every node/.style={transform shape}]
    \fill[#1, rounded corners=3pt] (-1.18,-2.38) rectangle (2.18,2.38);
    \foreach \x/\y/\v in {0.5/1.7/#3, -0.55/0.65/#4, 0.5/0.65/#5, 1.55/0.65/#6, 0.5/-0.4/#7, 0.5/-1.45/#8}{
      \fill[white, rounded corners=1.5pt] (\x-0.48,\y-0.48) rectangle (\x+0.48,\y+0.48);
      \node[font=\Large\bfseries] at (\x,\y) {\v};
    }
    \node[font=\bfseries\small, #1] at (0.5,-2.75) {#2};
  \end{tikzpicture}%
}

% --- Blank sample-space grid (7x7 incl. header row/col) ---
\newcommand{\samplegrid}{%
  \begin{tikzpicture}[scale=0.5]
    \draw[gridcol, thick] (0,0) grid (7,7);
    \fill[myplight, opacity=0.6] (0,6) rectangle (7,7);
    \fill[myplight, opacity=0.6] (0,0) rectangle (1,7);
    \draw[mypdark, very thick] (0,0) rectangle (7,7);
    \draw[mypdark, very thick] (0,6) -- (7,6);
    \draw[mypdark, very thick] (1,0) -- (1,7);
  \end{tikzpicture}%
}

\begin{document}

\begin{center}
  {\LARGE\bfseries\color{mypdark} Efron's Dice Project}\\[2pt]
  {\small\itshape Probability \;\textbullet\; sample spaces \;\textbullet\; experimental vs theoretical}
\end{center}

\begin{scenariobox}{The wager Gates refused}
Warren Buffett is a known fan of nontransitive dice. In \emph{Fortune's
Formula}\footnote{\emph{Fortune's Formula}, W.~Poundstone — ``trick dice that confound most people's ideas of probability.''}, a conversation between Buffett and Edward
Thorp about these ``trick dice'' is described.

\medskip
Buffett once challenged Bill Gates to a game of Efron's
dice\footnote{\url{https://www.businessinsider.nl/bill-gates-interview-warren-buffett-support-microsoft-antitrust-lawsuit-2019-6}}:
they would bet on the outcomes, winner takes the money. Buffett politely
offered Gates the chance to choose his die \emph{first}. His generosity
aroused Gates's suspicion --- after inspecting the dice, Gates decided that
\textbf{Buffett should pick first, or the bet was off.}
\end{scenariobox}

\vspace{-2pt}
\begin{center}
  \dienet{diegreen}{GREEN}{4}{0}{4}{0}{4}{4}\hspace{6pt}
  \dienet{dieyellow}{YELLOW}{3}{3}{3}{3}{3}{3}\hspace{6pt}
  \dienet{diered}{RED}{5}{1}{1}{1}{5}{5}\hspace{6pt}
  \dienet{diepurple}{PURPLE}{2}{6}{2}{2}{2}{6}
\end{center}
\vspace{-4pt}

\begin{questionbox}{How to play}
\begin{enumerate}
  \item Each player chooses a die (one of the four above).
  \item Both players roll, and the scores are recorded.
  \item The winner of each round is the player showing the higher number.
  \item After 10 rounds, the overall winner is the player with more round wins.
\end{enumerate}
\textit{Play it yourself at} \textbf{\textit{jmaths.xyz/play}} ---
join a class game with a code, or open \textbf{\textit{jmaths.xyz/play/solo}}
to pick any two dice and collect your own data.
\end{questionbox}

\begin{questionbox}{Your task}
Explain why Gates chose \textbf{not} to go first when picking the dice.
Your report should include:
\begin{enumerate}
  \item An introduction to the scenario and a basic plan \textit{(one paragraph)}.
  \item Diagrams of the dice and colour-coded sample-space diagrams for each
        matchup \textit{(blank grids on page 2)}.
  \item A summary of the theoretical probabilities that your sample-space
        diagrams demonstrate.
  \item A comparison of experimental data and theoretical probability, using
        your class data from the live game (your teacher can export the full
        class dataset).
  \item A discussion of conditional probability --- for example: \emph{given}
        a roll of \rule{1cm}{0.25pt}\,, what is the probability of winning or
        losing?
  \item A diagrammatic approach to (5) using tree diagrams
        \textit{(skeleton on page 2)}.
  \item A conclusion that discusses the `best die' in this game.
\end{enumerate}
\end{questionbox}

\begin{questionbox}{Rubric and submitting}
\begin{enumerate}
  \item You will be graded according to the rubric posted on PSL.
  \item Submit your work on PSL by the date specified.
\end{enumerate}
\end{questionbox}

\newpage

\begin{center}
  {\Large\bfseries\color{mypdark} Appendix --- diagram templates}\\[2pt]
  {\small Use these for your sample-space diagrams: label the axes with the
  faces of each die, then shade who wins each cell. The model below shows the
  method for \textcolor{dieyellow}{\textbf{Yellow}} vs
  \textcolor{diered}{\textbf{Red}} --- complete the grids for the other
  matchups yourself.}
\end{center}

\vspace{4pt}
\begin{center}
\begin{tikzpicture}[scale=0.5]
  % Model: Yellow (rows) vs Red (columns). Yellow wins where Red shows 1.
  \foreach \c/\rv in {1/5,2/5,3/5,4/1,5/1,6/1}{
    \foreach \r in {0,...,5}{
      \ifnum\rv=1
        \fill[diegreen!28] (\c,\r) rectangle ++(1,1);
      \else
        \fill[diered!18] (\c,\r) rectangle ++(1,1);
      \fi
    }
  }
  \fill[myplight, opacity=0.8] (0,6) rectangle (7,7);
  \fill[myplight, opacity=0.8] (0,0) rectangle (1,7);
  \draw[gridcol, thick] (0,0) grid (7,7);
  \draw[mypdark, very thick] (0,0) rectangle (7,7);
  \draw[mypdark, very thick] (0,6) -- (7,6);
  \draw[mypdark, very thick] (1,0) -- (1,7);
  \foreach \c/\rv in {1/5,2/5,3/5,4/1,5/1,6/1}{
    \node[font=\bfseries, diered] at (\c+0.5,6.5) {\rv};
  }
  \foreach \r in {0,...,5}{
    \node[font=\bfseries, dieyellow!80!black] at (0.5,\r+0.5) {3};
  }
  \node[font=\small\bfseries, diered] at (4,7.35) {Red};
  \node[font=\small\bfseries, dieyellow!80!black, rotate=90] at (-0.35,3) {Yellow};
\end{tikzpicture}\\[2pt]
{\small Yellow wins the shaded green cells: $\dfrac{18}{36}=\dfrac{1}{2}$
--- this matchup is perfectly fair. Are the others?}
\end{center}

\begin{center}
  {\small\bfseries\color{mypdark} Blank grids for your matchups}
\end{center}
\vspace{-6pt}

\begin{center}
  \begin{tabular}{cc}
    \samplegrid & \samplegrid \\[4pt]
    \samplegrid & \samplegrid \\
  \end{tabular}
\end{center}

\vspace{2pt}
\begin{questionbox}{Tree diagram skeleton}
\begin{center}
\begin{tikzpicture}[
    grow=right, level distance=2.6cm,
    level 1/.style={sibling distance=2.6cm},
    level 2/.style={sibling distance=1.3cm},
    every node/.style={font=\small},
    edge from parent/.style={draw, mypdark, thick}
  ]
  \node {}
    child { node {$\dfrac{\;\;\;}{\;\;\;}$}
      child { node {$\dfrac{\;\;\;}{\;\;\;}$} edge from parent node[below, font=\scriptsize]{label} }
      child { node {$\dfrac{\;\;\;}{\;\;\;}$} edge from parent node[above, font=\scriptsize]{label} }
      edge from parent node[below, font=\scriptsize]{label}
    }
    child { node {$\dfrac{\;\;\;}{\;\;\;}$}
      child { node {$\dfrac{\;\;\;}{\;\;\;}$} edge from parent node[below, font=\scriptsize]{label} }
      child { node {$\dfrac{\;\;\;}{\;\;\;}$} edge from parent node[above, font=\scriptsize]{label} }
      edge from parent node[above, font=\scriptsize]{label}
    };
\end{tikzpicture}
\end{center}
\end{questionbox}

\vspace{6pt}
\noindent{\small Background reading --- \emph{Playing with Probability:
Efron's Dice}:\\
{\scriptsize\url{http://oer.educ.cam.ac.uk/wiki/Playing_with_Probability_-_Efrons_Dice}}}

\end{document}
