Different color for certain dice rolls [2d6]

I’m still setting up this tennis game and I’d love to accent the interesting dice rolls.

There are 3 results that I’d like to have a different color:

  • Doubles.
  • Any roll of a 7.
  • A roll of 12.

Any other roll is plain.

There are 36 possible results with 2d6 and I once made a 1d36 table with all the different dice rolls listed, this table I had it report the dice roll and the result.
But I’m not sure how to change the color for these specific rolls.

Hi,

You probably need a Symbolic Dice Button with 36 different images that highlight the interesting rolls. For example

dice

This was made with LATEX and my wargame package (shameless self-plug :smile: ) with the code

\documentclass[tikz]{standalone}

\usepackage{wargame}

\tikzset{
  die/.style={
    shape=d6,
    scale line widths,
    line width=1pt,
    transform shape,
    scale=.7
  },
  fg die/.style args={#1,#2}{
    die,
    fill=#1,
    text=#2,
    font=\sffamily\bfseries\Large,
    draw=gray!25!white},
  die shadow/.style={
    die,
    fill=black,
    draw=none,
    opacity=.5}
}  
\newcommand\DiceExample[4]{%
  %\begin{tikzpicture}[
  \node[die shadow,rotate=10]      (s1) at (.40,.07){};
  \node[die shadow,rotate=-10]     (s2) at (-.25,-.11){};
  \node[fg die={#1,#2}, rotate=10]      at ($(s1)+(-.05,.03)$) {#3};
  \node[fg die={#1,#2}, rotate=-10]     at ($(s2)+(-.05,.04)$) {#4};
  \draw(-.7,-.5)rectangle(.8,.5);}

\begin{document}
\begin{tikzpicture}
\foreach \n in {1,2,...,6}{
  \foreach \m in {1,2,...,6}{
    \pgfmathparse{int(\n+\m)}\edef\s{\pgfmathresult}
    \def\bg{white}\def\fg{black}
    \ifnum\n=\m\def\bg{red}\def\fg{white}\fi
    \ifnum\s=7\def\bg{blue}\def\fg{white}\fi
    \ifnum\s=12\def\bg{green}\def\fg{white}\fi
    \begin{scope}[shift={(1.5*\n,\m)}]
      \DiceExample{\bg}{\fg}  {\n}{\m}
    \end{scope}
  }
}
\end{tikzpicture}
\end{document}

Symbolic Dice Button lets you define any discrete probability mass function (pmf) by supplying an image for each possible outcome and assigning a value to that. Thus, you can build a 2d6 pmf - which is a triangular distribution, not a normal, or “bell”, distribution - by supplying 36 images and assign appropriate values to each.

One can also use Symbolic Dice Button to define a “loaded” die. Some gamers feel that “extreme” outcomes are more probable in some games than they ought to be. In that case, one can make an option where the probability mass function is more triangular - e.g.,

x P(x)
1 1 / 12
2 2 / 12
3 3 / 12
4 3 / 12
5 2 / 12
6 1 / 12

I have something like that - as an option - in my Gettysburg - Smithsonian Edition module (ch-1.x).

Hope that helps.

Yours,
Christian

This is really epic!
So i would make a symbolic dice button, add the 36 dice roll combinations, and put that piece of code in?

Thanks and I’ll check out your module too.

Just to be explicit and clear

Correct

Correct, each with it’s own image (cut out from the image above or make your own)

Depends on what you mean by “that … code”. If you mean

\documentclass[tikz]{standalone}

\usepackage{wargame}
...
\end{document}

then no. That code is LATEX code that simply produces the image above. In case you don’t know, LATEX is a typesetting system for producing high-quality, publication-ready manuscripts - particularly suitable and used for articles in journals of Natural Science. As such, LATEX has nothing to do with VASSAL or BeanShell.

Aside
My LATEX package wargame can take a LATEX document and make a (draft) VASSAL module via an intermittent Python script (pywargame).

What you need is

  • A Symbolic Dice Button - check show result in window -
    • with a single Symbolic Dice
      • with 32 Symbolic Dice Face
        • Each face has a single image (one of the 32 rectangles from above) that illustrates the result, and
        • Numerical value value set to the value of the roll

If you know LATEX, you can easily customise the dice colours above. In

    \def\bg{white}\def\fg{black}
    \ifnum\n=\m\def\bg{red}\def\fg{white}\fi
    \ifnum\s=7\def\bg{blue}\def\fg{white}\fi
    \ifnum\s=12\def\bg{green}\def\fg{white}\fi
  • The first line sets the default background to white (\def\bg{white}) and foreground to black (\def\fg{black})
  • The second line sets the background to red and foreground to white when the two die are equal
  • The third line sets the background to blue and foreground to white when the sum of the dice is 7
  • The fourth line sets the background to green and foreground to white when the sum is 12.

You can change these colours however you like - for example, to make a darker red, mix 50% red with 50% black by red!50!black. Suppose you save the above code in a file called dice.tex, then you can run LATEX on it with

$ pdflatex dice.tex 

to produce dice.pdf. This in turn can be made into PNG(s) with

$ pdftocairo -singlefile -png dice.pdf -o dice

or f.ex. Gimp. If you modify the above LATEX code like

\documentclass[tikz]{standalone}

\usepackage{wargame}

\tikzset{
  die/.style={
    shape=d6,
    scale line widths,
    line width=1pt,
    transform shape,
    scale=.7
  },
  fg die/.style args={#1,#2}{
    die,
    fill=#1,
    text=#2,
    font=\sffamily\bfseries\Large,
    draw=gray!25!white},
  die shadow/.style={
    die,
    fill=black,
    draw=none,
    opacity=.5}
}  
\newcommand\DiceExample[4]{%
  %\begin{tikzpicture}[
  \node[die shadow,rotate=10]      (s1) at (.40,.07){};
  \node[die shadow,rotate=-10]     (s2) at (-.25,-.11){};
  \node[fg die={#1,#2}, rotate=10]      at ($(s1)+(-.05,.03)$) {#3};
  \node[fg die={#1,#2}, rotate=-10]     at ($(s2)+(-.05,.04)$) {#4};
}

\begin{document}
\nopagecolor
\foreach \n in {1,2,...,6}{
  \foreach \m in {1,2,...,6}{
    \pgfmathparse{int(\n+\m)}\edef\s{\pgfmathresult}
    \def\bg{white}\def\fg{black}
    \ifnum\n=\m\def\bg{red}\def\fg{white}\fi
    \ifnum\s=7\def\bg{blue}\def\fg{white}\fi
    \ifnum\s=12\def\bg{green}\def\fg{white}\fi
    \begin{tikzpicture}
        \DiceExample{\bg}{\fg}  {\n}{\m}
    \end{tikzpicture}
  }
}
\end{document}

you will get a PDF with 36 “pages” - each correspond to a die combination, which you can then turn into individual PNGs (named dice-00.png, dice-01.png, …, dice-35.png) with

$ pdftocairo -png dice.pdf -o dice

which you can directly import into your VASSAL module.

Yours,
Christian

1 Like

Thank you this has all been very helpful