The Ur-Quan Masters Home Page Welcome, Guest. Please login or register.
Did you miss your activation email?
October 10, 2024, 04:42:40 am
Home Help Search Login Register
News: Celebrating 30 years of Star Control 2 - The Ur-Quan Masters

+  The Ur-Quan Masters Discussion Forum
|-+  The Ur-Quan Masters Re-Release
| |-+  General UQM Discussion (Moderator: Death 999)
| | |-+  Pkunk rebirth algorythm
« previous next »
Pages: [1] 2 Print
Author Topic: Pkunk rebirth algorythm  (Read 5093 times)
Tiberian
*Smell* controller
****
Offline Offline

Gender: Male
Posts: 335



View Profile WWW
Pkunk rebirth algorythm
« on: November 30, 2003, 08:16:25 pm »

Are there some factors that affect in the Pkunk Fury rebirthing? Sometimes it feels as if they never reincarnate and sometimes they seem to do it all the time.

I remember my record was something like 6 rebirths in a row a long time ago when playing the original version. Has this issue been tampered with in Ur-Guan Masters?
Logged

Author of Star Control novelizations Groombridge Log and Eternal Doctrine. http://www.tommisalminenbooks.com
Nic.
Guest


Email
Re: Pkunk rebirth algorythm
« Reply #1 on: November 30, 2003, 08:43:13 pm »

See the following threads for an exhaustive discussion of this topic:

Topic: What is the logic how the pkuk reborn?

Topic: Problems with the game?
Logged
Tiberian
*Smell* controller
****
Offline Offline

Gender: Male
Posts: 335



View Profile WWW
Re: Pkunk rebirth algorythm
« Reply #2 on: November 30, 2003, 09:47:42 pm »

I read those, but I don't believe that it is 50-50 as they say it is. It seems like it is different in different situations. Maybe someone with actual knowledge of it could explain. Someone who knows the code. (no guesses here)
Logged

Author of Star Control novelizations Groombridge Log and Eternal Doctrine. http://www.tommisalminenbooks.com
Nic.
Guest


Email
Re: Pkunk rebirth algorythm
« Reply #3 on: November 30, 2003, 10:28:26 pm »

Believe whatever you like, but the code says otherwise.  The code in question lives in a function called pkunk_preprocess(), and the test is something like this (edited for clarity):

Code:
if (TFB_Random () & 1)

For those who don't speak C, it looks to see if the number returned from the random number generator is even or odd.  If it's odd, the Pkunk is reborn.  Your chances of getting an even vs. odd number out of the random number generator are 50/50.
Logged
Lukipela
Enlightened
*****
Offline Offline

Gender: Male
Posts: 3620


The Ancient One


View Profile
Re: Pkunk rebirth algorythm
« Reply #4 on: November 30, 2003, 10:31:48 pm »

Taken from one of the topics you were supposed to read:

Quote


The code that controls the Pkunk "phoenix effect" is in a function called pkunk_preprocess().  It is a simple "50/50" test against a random number.  No more, no less.  If you want to believe that other factors control it, go right ahead, but the code says what it says.

What is truly interesting part about Pkunk respawning is that whether or not the ship will respawn is determined BEFORE the fight even starts!  This really makes me laugh when I think of all the times I'd try to "influence" respawning by holding down keys as the ship exploded.  Silly hunam, the decision was made long before then!


No guesses, just simple code. Now, if you don't want to take Nics word for it, then you may as well go through the code yourself and have a look. Trust me, Nic does know what he is talking about

EDIT: Oopps, Nic beat me to it. And I wasted my 1K post... Sad Oh well, I betetr scurry over to OT and make a speech....
« Last Edit: November 30, 2003, 10:34:28 pm by Lukipela » Logged

What's up doc?
Rib Rdb
Frungy champion
**
Offline Offline

Gender: Male
Posts: 85



View Profile WWW
Re: Pkunk rebirth algorythm
« Reply #5 on: December 03, 2003, 02:42:23 am »

Quote
Believe whatever you like, but the code says otherwise.  The code in question lives in a function called pkunk_preprocess(), and the test is something like this (edited for clarity):

Code:
if (TFB_Random () & 1)

I've been reading about PRNG's for the GBA port I'm working on, and most of the stuff I've read says that the lower bits of most linear congruential prng's are not really very random.  This could explain why people have complained about long periods with no rebirths then many rebirths in a row. Some of the things I've read recomend the rng returning

Code:
seed ^ seed >> (sizeof(seed)/2)


Instead of changing the RNG maybe it would be better to say
Code:
if (TFB_Random () & 0x100000)

or something like that.  Then again, I haven't done any tests. Maybe TFB's PRNG has a perfectly random LSb, and we're all just imagining that the rebirthing isn't 50/50.

Edit: I'm not sure, but it looks like there's some sort of test for ship mass in intercept_pkunk_death() that may influence the rebirthing process.
« Last Edit: December 03, 2003, 02:51:53 am by Rib_Rdb » Logged
Culture20
Enlightened
*****
Offline Offline

Posts: 917


Thraddash Flower Child


View Profile
Re: Pkunk rebirth algorythm
« Reply #6 on: December 03, 2003, 04:19:10 am »

Sorry if this thread is getting too technical, but why wouldn't the lowest bit (one/zero;odd/even) be somewhat evenly distributed in a psuedo-random number generator?
Logged
Michael Martin
Core Team
*Smell* controller
*****
Offline Offline

Posts: 387



View Profile
Re: Pkunk rebirth algorythm
« Reply #7 on: December 03, 2003, 06:23:46 am »

Quote
Sorry if this thread is getting too technical, but why wouldn't the lowest bit (one/zero;odd/even) be somewhat evenly distributed in a psuedo-random number generator?


One of the biggest failures of the ISO C standard is mandating the PRNG -- and mandating it to something with absolutely terrible properties by almost any metric you care to name.  In particular, the lowest byte or so is very nonrandom, and tends towards streaks or (for more than one bit) a lot of cycling.

I haven't looked too carefully at the code surrounding TFB_Random but I'm pretty sure that it uses its own generator.
Logged
Rib Rdb
Frungy champion
**
Offline Offline

Gender: Male
Posts: 85



View Profile WWW
Re: Pkunk rebirth algorythm
« Reply #8 on: December 03, 2003, 07:02:37 am »

TFB_Random does use it's own algorithm, but it looks like it's still a linear congruential, and my understanding is that most prng's of this type have problems with the lower bits.
Logged
meep-eep
Forum Admin
Enlightened
*****
Offline Offline

Posts: 2847



View Profile
Re: Pkunk rebirth algorythm
« Reply #9 on: December 05, 2003, 05:40:31 pm »

FYI, TFB_Random is called a lot during combat, each time changing the internal state of the RNG. And there's no reinitialising it with some fixed seed in the mean time.
So even if the RNG itself would be flawed, the outcome of the pkunk rebirth roll should be very random.
And very random means there can be streaks. And ofcourse it's the streaks that one remembers.
And considering that a pkunk has 50% chance of surviving, one in every 8 pkunks lives 4 times.
Logged

“When Juffo-Wup is complete
when at last there is no Void, no Non
when the Creators return
then we can finally rest.”
Culture20
Enlightened
*****
Offline Offline

Posts: 917


Thraddash Flower Child


View Profile
Re: Pkunk rebirth algorythm
« Reply #10 on: December 05, 2003, 07:47:08 pm »

Bah!  Statistics be damned!  It all depends on how hard I press the key combination: ctrl-alt-5-b.  Then 3/24 pkunks regenerate 4 times.   Roll Eyes
Logged
meep-eep
Forum Admin
Enlightened
*****
Offline Offline

Posts: 2847



View Profile
Re: Pkunk rebirth algorythm
« Reply #11 on: December 08, 2003, 01:52:13 pm »

Quote
Bah!  Statistics be damned!  It all depends on how hard I press the key combination: ctrl-alt-5-b.  Then 3/24 pkunks regenerate 4 times.   Roll Eyes

I said "live 4 times", not "regenerate 4 times".

Logged

“When Juffo-Wup is complete
when at last there is no Void, no Non
when the Creators return
then we can finally rest.”
Nic.
Guest


Email
Re: Pkunk rebirth algorythm
« Reply #12 on: December 08, 2003, 07:19:43 pm »

Something that might be fun if/when code add-ons get going:

I think it would be sublimely cruel to the player if the Pkunk special toggled the death function pointer between "death" and "rebirth" every time it was invoked.  Imagine the grand fun people could have making sure that they only taunted the opposing player in amounts divisble by two!
Logged
Culture20
Enlightened
*****
Offline Offline

Posts: 917


Thraddash Flower Child


View Profile
Re: Pkunk rebirth algorythm
« Reply #13 on: December 08, 2003, 08:27:39 pm »

Quote
I said "live 4 times", not "regenerate 4 times".

Hmm, my mistake.  If they regenerated 4 times, then they'd be living 5 times.  Living and regenerating are not the same.  Embarrassed
Logged
Rib Rdb
Frungy champion
**
Offline Offline

Gender: Male
Posts: 85



View Profile WWW
Re: Pkunk rebirth algorythm
« Reply #14 on: December 09, 2003, 12:12:16 am »

i did some tests and the randomness does seem fine.  Does anyone know the code well enough to see if that mass stuff in intercept_pkunk_death affects regeneration.  It looks to me that if the mass points are to high the pkunk won't regenerate.  but I don't know how the mass points gets set.
Logged
Pages: [1] 2 Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!