Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / randomize

Author
Message
Quirkyjim
16
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 30th Nov 2008 16:06
I'm making sort of a basic monster fight game, and I'm wondering how I can use the randomize command to have uniques attacks for each turn. I don't really understand how it works.

~QJ
Ashingda 27
17
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 30th Nov 2008 16:11
I'm not quite sure I understand you but maybe this might help.

Quirkyjim
16
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 30th Nov 2008 16:24
yeah, I was thinking you only used it in
, but it said in the help that it could also be an integer value...

~QJ
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 30th Nov 2008 18:01
I think you are confusing two commands: RANDOMIZE and RND() .

RANDOMIZE sets the 'seed' i.e. the starting point for calculations to be made by the random number generator. The random number generator doesn't really generate random numbers. It actually generates a series of seemingly random numbers based on the 'seed'. Because timer() changes by the millisecond, it is unlikely to have the same seed every time you run the program, therefore randomize timer() is a common way to set the seed.

RND() runs the random number generator and returns an integer between 0 and the value in the () up 32767 .

Enjoy your day.
Quirkyjim
16
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 30th Nov 2008 18:04
Oh! I see now. Thanks Latch!

~QJ
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Dec 2008 00:12 Edited at: 1st Dec 2008 00:14
I thought I was a genius coming up with RANDOMIZE TIMER() but turns out people have been using it for years
Try setting RANDOMIZE with an integer and you'll see you get the same random numbers every time you run the program! I think editing your code changes it though for some reason.

@QuirkyJim
Do you mean you want to add a random element to your combat?
adding a random number to a static number will give you a "biased" random number.
Here's the beginnings of a combat system, I wrote it very quickly so it's a bit cruddy but shows how you can use random numbers and different attributes in combat.


Oh it also shows that you need RANDOMIZE unless you want to fight the Leviathan all day!

A small program that works is better than a large one that doesn't.

DBC Challenge Rank: Rookie
Ashingda 27
17
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 1st Dec 2008 00:28
Quote: "Haven't coded this outcome yet!"

LOL!

Login to post a reply

Server time is: 2025-06-07 17:28:48
Your offset time is: 2025-06-07 17:28:48