www.piclist.com/techref/microchip/math/index.htm?key=random

BY : Mike Singer email (remove spam text)

I would suggest:

How to get randomly-biased dice number.

1. Associate six 8-bit registers with six dice numbers.

2. Init them with 128 values.

3. On each loop subtract 5 from that register which

number was hit until it reached 0, of course.

And add 1 to other registers until they reached 255.

4. Get 16-bit Sum of the registers.

5. Get random value from 0 to the Sum.("White noise"-Jinx

is a Guru, "Black noise"-Roman is a Master ;-) :o)

6. Summarize register values until this sum reached

previous "The Sum". Last register's number involved

with this summarizing is the "randomly-biased dice

number".

7. Go to "3."

No multiplication. No 32-bit calcs. "Numbers which had

been rolled less often" are of more probability to be hit.

Mike

---

Sorry, if someone has expressed the idea, I hadn't chance

of reading the thread: summertime seaside matters.

Brendan Moran wrote:

{Quote hidden}

--

http://www.piclist.com hint: To leave the PICList

EraseMEpiclist-unsubscribe-requestspamBeGoneTakeThisOuTmitvma.mit.edu

In reply to: <036301c242e6$48e00f30$199f42d8@czhang>

See also: www.piclist.com/techref/microchip/math/index.htm?key=random