ainslec / adventuron-issue-tracker

Adventuron Issues Tracker
4 stars 0 forks source link

Randomly generated numbers are not working as expected #504

Closed hnejfnvjojgrogjwm closed 1 year ago

hnejfnvjojgrogjwm commented 1 year ago

The randomly generated numbers are not working as expected.

on_command{
   :match"test chance"{
      :if(chance(75)){
         :print"true";}
      :else{
         :print"false";}
      }
}
  1. Please try the code provided.
  2. Try the command TEST CHANCE as many times as you want.
  3. Observe the results. The result "true" will happen way too often, maybe 9 out of 10 times or more, when it should be only 3 out of 4 times.
hnejfnvjojgrogjwm commented 1 year ago

Other Adventuron users are investigating the issue in Discord. I am not sure to understand their findings, but here you have a link: https://discord.com/channels/718707322381402146/808287579321270283/1030212645514653896

ainslec commented 1 year ago

Appears to be the command readahead optimizer that is going wrong.

Testing with following script

start_at = my_location

integers {
   num_chances : integer "0" ;
   count_yes : integer "0" ;
   count_yes_2 : integer "0" ;
   count_yes_3 : integer "0" ;
}

locations {
   my_location : location "You are in a room." {
      on_describe {
         : while (num_chances != 1000) {
            : if (chance (75)){
               : set_integer var = "count_yes" (count_yes + 1) ;
            }
            : else_if (chance (50)) {
               : set_integer var = "count_yes_2" (count_yes_2 + 1) ;
            }
            : else {
               : set_integer var = "count_yes_3" (count_yes_3 + 1) ;
            }
            : set_integer var = "num_chances" (num_chances + 1) ;
         }
         : append (count_yes);
         : append ", ";
         : append (count_yes_2);
         : append ", ";
        : append (count_yes_3);
         : append ", ";

        : append (num_chances);
      }
   }
}
ainslec commented 1 year ago

Fixed in beta 76