This is closely related to my PhD. It was many years ago but if I remember rightly there is no need for the assumption of determinism - Bell Inequalities hold just as well for random local hidden variables. Simulating the correlations with computer programs is an interesting idea, partly because it challenges to those who still believe in a "local" reality to demonstrate Bell Inequality violations in distributed clas…
Regarding determinism, I think the reason the assertion is "no deterministic local hidden.." is that, you need to break both the deterministic and locality assumption. However there is a nuance, which is, do you need to break both properties to..
(a) break the Bell inequalities, or, to
(b) reproduce quantum mechanics..
which is not exactly the same thing.
For example, in my toy simulation framework, this [1] simple setup --- where Alice's two measurement devices always return +1, and Bob's two measurement devices are conditioned on Alice's returned value, without any randomness --- breaks the Bell-inequalities at S=4, but:
(1) it's not physical, because it also breaks the Tsirelson bound (4 > 2.82), ie. you can't actually achieve this with any known real-world physical system
(2) it's deterministic in the sense that the code does not call `random()`
(3) but from the perspective of Bob, who "calls" the measurement function, it would still appear random, since it depends on whether Alice measures H or T, which was the outcome of a random coin flip; so whether we consider this random is quite nuanced..
So the above is an interesting thought/Python experiment for what it takes to break the Bell inequalities. Then, if we modify the code to reproduce quantum mechanics (for which the 2 qubits stand in), which is the code shown in the original post, in that case we cannot even avoid calling `random()`, because the "first" to measure their qubit must also get +1 and -1 with equal probabilility, so the theory cannot be deterministic.
[1] https://gist.github.com/mtrencseni/de13f766911aaaf5bfd5d4636...