Advertisement
romanilyinfb

devtodev dice

Feb 17th, 2022
1,047
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.43 KB | None | 0 0
  1. dice_2d6 = {};
  2. for i = 1, 12 do
  3.    dice_2d6[i]=0;
  4. end
  5.  
  6. math.randomseed(os.time());-- инициализация генератора случайных чисел
  7.  
  8. count = 100000; -- число испытаний
  9.  
  10. for i = 1, count do
  11.    local result = math.random(1,6)+math.random(1,6);
  12.    dice_2d6[result]=dice_2d6[result]+1;
  13. end
  14.  
  15. for i = 2, 12 do
  16.    print ("Dice[".. i .."] = " .. 100*dice_2d6[i]/count .."%");
  17. end
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement