(fixed) [0.66b] change in dsb_rand behaviour

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
kaypy
Artisan
Posts: 171
Joined: Sun Jan 19, 2014 7:11 am

(fixed) [0.66b] change in dsb_rand behaviour

Post by kaypy »

With the new random number generator, the semantics of dsb_rand have changed

Before, it generated a random number between min and max, inclusive. Now, the highest number returned is max-1

Something like

Code: Select all

local dist={}
local temp
for i=0,999999 do
   temp=dsb_rand(0,3)
   if (dist[temp] == nil) then
      dist[temp] = 1
   else
      dist[temp] = dist[temp]+1
   end
end
for k,v in pairs(dist) do
   __log(tostring(k) .. " -> " .. tostring(v))
end
in startup.lua demonstrates in nicely.

Note that this is not necessarily wrong, per-se, but it is a change from existing behaviour. (And may cause errors all through the base lua if that's expecting the old behaviour)
Friends don't let friends eat worm round
Post Reply