Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-23-2013, 03:15 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Sounds a bit like "normal distribution", or "the bell curve." You can generate numbers that act like that using the "Box–Muller transform." Look up these things.

My attempt at implementing it in GScript:
PHP Code:
function normal() {
  
temp.2.7182818284590452353602874713526624977572470936999;
  return 
cos(2*pi*random(01)) * (-log(temp.erandom(01)))^0.5;

It generates numbers that are more likely to be close to 0.

If you know in advance that you only need numbers 1 through 10 it's probably easier to do it another way.
__________________
Testbed user: I figured since I can never find any scripters it was time to take desperate measures...and...TEACH MYSELF 0.0
Reply With Quote
  #2  
Old 08-23-2013, 04:03 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by DrakilorP2P View Post
Sounds a bit like "normal distribution", or "the bell curve." You can generate numbers that act like that using the "Box–Muller transform." Look up these things.
This is what we did on Kingdoms for the mystery boxes (for determining which item you got). If you need more code samples, I can dig up our implementation as well.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:06 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.