http://wiki.cs.princeton.edu/index.php/ChucK/Features/Release - the most prioritized feat for next release is extending maybe. As I just thought of it today and my thoughts are better than there - I think that a simple overload for multiplication operator would be just enough. Like this: if (maybe * 0.2) { // Runs with probability of 20% } Or, more coherent, but less nice: if (maybe(0.2)) { // Runs with probability of 20% } Then, when doing switches, how to handle those? It would be nice to have something like: switch { case maybe * 0.3: case maybe * 0.5: case maybe * 0.6: case true: } In case it would automatically fix all maybes - so that actual probabilities would add up to 100% and, thus, first one is fixed to about 0.2 and second one to slightly less than 0.5 ..this would allow really nice play with probabilities (and, of course, optimizations internally). Tambet
2010/8/24 Tambet
http://wiki.cs.princeton.edu/index.php/ChucK/Features/Release - the most prioritized feat for next release is extending maybe.
Well....... it's on the top of that list. The list *should* be prioritised but I don't think it is. How about this; fun int chance(float arg) { if (Std.rand2f(0, 1) > arg) return 1; else return 0; } You could add that to a public class called "mylib" and from there on it would be available in all your code, just like any other utility functions you might like to add. Hope that helps, Kas.
participants (2)
-
Kassen
-
Tambet