Searching \ for '[PIC]: Pic and games' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Pic and games'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Pic and games'
2001\03\03@004217 by Mike

picon face
part 1 1523 bytes content-type:text/plain; charset=us-ascii (decoded quoted-printable)

Bob Ammerman wrote:
> Mike,
> > Don't use a random number generator for a dice project. Instead just run a
> counter as fast as you can and stop it when the user hits the button.
> > Be sure that each state of the count takes the same number of cycles.

Now there's an idea.  Probably a lot easier, too.

<thinking_out_loud> Guess I'd just set the top point for the counter - i.e. where the counter
would wrap back to 1 - at whatever the max possible for that particular die
is.  If doing a 20 sided die at the moment, have the counter wrap from 20 to
1 (or from 19 to 0 then add 1 before displaying).  Or just let it wrap 255
to 0 and do some sort of scaling based on the die type?  Like perhaps a
lookup table of some sort?  I'll have to do some fiddling to see what works
best for me.  And then there's doing multiple dice simultaneously ...
</thinking_out_loud>

Thanks for the hint - I'm too used to dealing with PC type programming. I've been lurking on this list for some time now, but am only just now
starting to actually write code for PICs.  At a first glance this is the
kind of project that I think might be a good first "serious" - i.e. not
school assigned - project for me.
-- Mike Werner  KA8YSD   | He that is slow to believe anything and
                     | everything is of great understanding,
'91 GS500E            | for belief in one false principle is the
Morgantown WV         | beginning of all unwisdom.



part 2 233 bytes content-type:application/pgp-signature (decode)

part 3 154 bytes
--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\03\03@031021 by Roman Black

flavicon
face
Mike wrote:
>
> Bob Ammerman wrote:
> > Mike,
> >
> > Don't use a random number generator for a dice project. Instead just run a
> > counter as fast as you can and stop it when the user hits the button.
> >
> > Be sure that each state of the count takes the same number of cycles.
>
> Now there's an idea.  Probably a lot easier, too.
>
> <thinking_out_loud>
> Guess I'd just set the top point for the counter - i.e. where the counter
> would wrap back to 1 - at whatever the max possible for that particular die
> is.


If using a cheap PIC they always have 8bit free run
counter TIMER0. When the user presses the button you
just grab the timer0 value straight away, then when
they let the button go you grab it again.

This gives you a 16 bit value, between 0 and 65535.
Or it gives you two 0-255 figures.
Then you should be able to do some math on the data
and get a pretty good psuedo random result. :o)
-Roman

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\03\03@085059 by Bob Ammerman

picon face
Mike,

Be careful of using scaling -- you'll likely skew your results so that not
every result is equally probable.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...