A couple of bug type things
Displaying 1-20 of 29 total.
12 next
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Zip

Feel free to shove the code below in a system.vc and give it a go. Basically:
-Seeding the randomiser with a constant doesn't give a constant output
-The interface between b1 and key[SCAN_ENTER] is unreliable, and there's no way of 'pressing' the buttons apart from using key[]
-Oh, and is the switch() return bug gonna be fixed? :D
#define I_LOVE_LIFE 50

int numbers[I_LOVE_LIFE]; // Some numbers

void autoexec()
{
int i; // A looper
// If the next line is in, enter will automatically be pressed once,
// but ignore the press after that. If it's commented out enter
// works as would be expected, there is no Press(1)
key[SCAN_ENTER] = 1;
while (!b3) // If escape is not pressed
{
if (b1) // If enter is pressed
{
// Set the seen to a constant
// (so the next number should always be the same)
SetRandSeed(1);
// Generate a string of random numbers
for (i = 0; i < I_LOVE_LIFE; i++)
{ numbers[i] = Random(0, 100); }
// Randomize the seed again (keep up that good practice)
SetRandSeed(0);
unpress(b1); // Unpress enter
}
// Reset the screen buffer to plain black
RectFill(0,0,ImageWidth(screen),ImageHeight(screen),0,screen);
// Print our random numbers
for (i = 0; i < I_LOVE_LIFE; i++)
{ PrintCenter(ImageWidth(screen)>>1, i * 10, screen, 0, str(numbers[i])); }
ShowPage(); // Displays the buffer on the screen
}
exit("Bye!");
}

Zip

[Edit: Fixed the display on my 1024x768]

Posted on 2004-07-22 17:41:03 (last edited on 2004-07-24 13:26:07)

RageCage

how does ImageWidth(screen)>>1 work? Just curious, I've never seen that before.

Posted on 2004-07-22 19:19:24

Ness

>> is bitshift right - it's used to divide by multiples of 2. He shifted to the right once, so it has the same effect as dividing by 2, only a whole lot faster.

Posted on 2004-07-22 19:31:16 (last edited on 2004-07-22 19:32:57)

Zip

Yeah, just me being poncy and in the habit of bitshifting everything in sight.

Zip

Posted on 2004-07-22 19:37:28

RageCage

thats awsome

Posted on 2004-07-22 20:05:50

Zip

Another one maybe, unless this is a feature I know nothing about:

Are the following statements different logically?
if(y >= ground && yv >= 0) // Give me true
if(y >= ground && yv => 0) // Gives me false
Both instances y = ground and yv = 0

Zip

Posted on 2004-07-23 15:55:29

Ness

=> is not a valid operator as far as I know. The verge compiler dosen't catch it as an error, but try and put that in a c compiler and it will accuse you of rape

Posted on 2004-07-24 01:41:51

Zip

Yes, I appear to have had my idiot head on for that one. Wonder why it didn't just spilt an error...

Zip

Posted on 2004-07-24 03:48:38

zenogais

Umm, seeding the random number generator is a way to help it produce more random output that by not seeding it. Random number generators shouldn't produce constant output ;)

Posted on 2004-07-24 09:15:33

Zip

Nah, THIS one I'm not being an idiot on ;)

Quote:Originally posted by vec in v3changes.txt

- Added SetRandSeed() to allow setting the random number generator seed. Note that passing a value of 0 will set a random seed (since generating a random seed can be tricky if you already set the random generator's seed to something deterministic).


...er.... that's not as clear as I thought it was...

Quote:Originally posted by zero in the docs

This function may be used to initialize the random number generator with the seed of your choice. If you are careful, you may be able to rig your game to behave the same every time if you initialize it with the same random seed every time.


...that's not very clear either

Quote:Originally posted by In the wonderful Wikipedia

In addition, a PRNG can be started from an arbitrary starting point, or seed state, and will always produce an identical sequence from that point on.


*There we go*

Zip :D

Posted on 2004-07-24 13:20:24

Omni

PRNG?

Posted on 2004-07-24 16:51:18

Zip

*cough*CLICK THE BLEEDING LINK*cough*

:D

Zip

Posted on 2004-07-24 17:22:03

Kildorf

PRNG = Pseudo-Random Number Generator


Edit: Everything that follows below is likely much better explained by the Wikipedia article that Zip posted, that (were I smart enough) I would have just pointed you towards rather than writing my own pamphlet on it. -_-;



It is impossible to generate true random numbers on a computer, since they are deterministic machines. (Hell, it's pretty much impossible for humans to come up with random numbers too.) The closest they've gotten (far as I know) is machines that produce numbers by performing maths on certain atmospheric conditions that change constantly (like various kinds of particles striking the outer atmosphere, the levels of magnetism in the Earth's magnetosphere, whatever). Obviously something like that is somewhat out of the realm of possibility for a VERGE game.

Anyway, so we're stuck with pseudo-random number generators. They take a seed number, and perform wacky arithmetic to them (I've seen random number generator algorithms before, and let me tell you: they make no sense) taking advantage of modulus, big numbers, the wrapping around of values, etc. etc. If you provide the same seed, then you will always get exactly the same string of numbers out of the generator. This is useful if you wanna test something and always get consistent results (which is why we were asking for a seed-specifier).

Specifying a number is not so useful if you actually do want it to be random. The classic way, and the easiest way (and what I assume to be the VERGE way) is to assign the current second count since 1980 (or 1960 or whatever the epoch date for your operating system is) as the seed. This pretty much guarantees that any non-trivial program will not execute the same twice. On the other hand, if you run a program twice in the same second, it will be the same.

I'm sure that was more response than you intended to elicit from saying "PRNG?" but I tend to ramble sometimes. Have a good day. :)

And anyone who sees that I said something wrong, please correct me, as I like to know what I'm talking about. ^_^

Posted on 2004-07-24 17:22:41 (last edited on 2004-07-24 17:25:10)

Omni

Nope, looks right. I remember reading about this behavior in Python tutorials. I just wasn't sure about PRNG. EDIT: The acronym.

Seeding the current time in seconds in almost brilliance, though. I mean, that's cool. I bet the guy who thought of it thought he was pretty awesome, too.

Posted on 2004-07-24 17:28:49 (last edited on 2004-07-24 17:37:06)

Zip

Hehe, I just about beat Kildorf's polite, clear and well explained post with my rude and silly one. :D

For the curious, a PRNG I use in c:
//picks a random number from 0 to max-1

unsigned long randomn(unsigned long max)
{
r_num();
long double rand_y;
long double rand_i;
rand_i = 2147483648L;
rand_y = max*((long double)seed/rand_i);
return((unsigned long)rand_y);
}

//sets seed to a random number from 0 to 2 billion
unsigned long r_num(void)
{
seed=(seed*907725L+99979777L)%2147483648L;
return seed;
}

Zip

Posted on 2004-07-24 17:35:35

mcgrue

Aren't good psuedorandom seeding techniques supposed to use the system clock in their calculations?

Posted on 2004-07-24 19:40:40

Zip

Yes, and I presume vec's SetRandSeed(0) does something along those lines - you certainly don't want to use the time as a factor DURING any number generation though, otherwise getting constant output is impossible (and you wan it sometimes). In the example above, for instance, the seed is a global variable so I can set it based on time if I want, but will always generate the same string of numbers if given the same seed.

Zip

Posted on 2004-07-24 19:48:11

Kildorf

Although I actually kind of like the idea of a number generator using the systemtime as part of its during the actual number generation. Maybe pass the seeding function a flag whether to use a deterministic algorithm or a more-random time based one.

Of course, having really random numbers is only truly important in places with security concerns. I'm guessing no one's going to be attempting to write secure data storage with Verge or anything. ^_^


Although a video game might be a clever disguise for seekrit documents.

Posted on 2004-07-24 19:53:21

mcgrue

No no, it's up-up-down-down-left-right-left... wha... nuclear deployment plans for Turbekistan, timetable urgent? This isn't infinite lives!

(closes program)

Posted on 2004-07-24 20:50:46

Toen

Quote:Originally posted by Kildorf

Although I actually kind of like the idea of a number generator using the systemtime as part of its during the actual number generation. Maybe pass the seeding function a flag whether to use a deterministic algorithm or a more-random time based one.

Of course, having really random numbers is only truly important in places with security concerns. I'm guessing no one's going to be attempting to write secure data storage with Verge or anything. ^_^


Although a video game might be a clever disguise for seekrit documents.

Akujin inflated something he was making by like 90 megs to try to make the savegames unhackable. But then again he's special.

Posted on 2004-07-25 09:29:22


Displaying 1-20 of 29 total.
12 next
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.