I would like to perform some simple simulation in latex/tikz (in order to produce dynamical graphs). Say something like cellular automata, Ising model, etc.
I need to store somewhere the value of variables (an array) and I tried pgfkeys. However, it does not seem to accept "computed" keys. This is a minimal example
%storing (and printing for check)
\foreach \i in {0,...,5} {
\FPrandom{\rand}\FPeval{res}{round(rand:2)};
\pgfkeys{/c/\i/.code=\res};
\draw (\i, 0) node{\pgfkeys{/c/\i}};
}
%retrieving
\foreach \i in {0,...,5} {
\draw (\i, 0) node{\pgfkeys{/c/\i}};
}
It says that the keys /c/0 ... are not known.
I imagine that this is due to the fact that one needs to expand the "\i" inside the key BEFORE it is used but I do not know how to get it.
\documentclass{...}
, the required\usepackage
's,\begin{document}
, and\end{document}
. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.