ext/games_dice/probabilities.c in games_dice-0.3.2 vs ext/games_dice/probabilities.c in games_dice-0.3.3

- old
+ new

@@ -6,14 +6,14 @@ #ifndef DBL2NUM #define DBL2NUM( dbl_val ) rb_float_new( dbl_val ) #endif // Force inclusion of hash declarations (only MRI includes by default) -#if RJB_RUBY_VERSION_CODE < 190 -#include "st.h" -#else +#ifdef HAVE_RUBY_ST_H #include "ruby/st.h" +#else +#include "st.h" #endif VALUE Probabilities = Qnil; /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -228,10 +228,10 @@ pl->offset = combined_min; double *pr = alloc_probs_iv( pl, s, 0.0 ); int i,j; for ( i=0; i < pl_a->slots; i++ ) { for ( j=0; j < pl_b->slots; j++ ) { int k = mul_a * (i + pl_a->offset) + mul_b * (j + pl_b->offset) - combined_min; - pr[ i + j ] += (pl_a->probs)[i] * (pl_b->probs)[j]; + pr[ k ] += (pl_a->probs)[i] * (pl_b->probs)[j]; } } calc_cumulative( pl ); return pl; }