The Ur-Quan Masters Home Page Welcome, Guest. Please login or register.
Did you miss your activation email?
November 29, 2022, 01:08:02 pm
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)
| | |-+  Orz Marine Code
« previous next »
Pages: [1] Print
Author Topic: Orz Marine Code  (Read 1746 times)
Zebranky food
Offline Offline

Posts: 44

View Profile
Orz Marine Code
« on: February 28, 2007, 05:29:27 pm »

Okay so I wanted to know exactly how the marines work, and figure out how valuable they are.

So I decided to look at the code, and from what I can determine, it works like this:

For each iteration, a random value from 0 - 255 is generated. 
If this number is less than 16, the marine dies.
If it is between 16 and 143 inclusive, the ship loses one crew.

This would mean that each marine deals an average of 8 damage.

Can someone substantiate or refute this?

Re: Orz Marine Code
« Reply #1 on: February 28, 2007, 07:04:34 pm »

You are right. This has been also said by meep-eep:
It is also absolutely false.  Wink  The way the "marine code" works is (basically) that at various points in the game, it picks a random number between 0 and 4294967295, inclusive.  If that number happens to be of a value below 144, the marine kills one member of the crew, and if it is below 16, the marine dies.
Not quite. The random value is cast to a BYTE, thereby only taking the lowest 8 bits, giving a value between 0 and 255 (inclusive).
So each time the chance is 1/2 for an intruder to kill an enemy, 1/16 to die, and 7/16 to do nothing.

So 8 times out of 9 the marine kills a crew member, and 1 time out of 9 it is killed. So a marine, on average, kills 8 crewmen before dying. Just as you said.
Zebranky food
Offline Offline

Posts: 4

View Profile
Re: Orz Marine Code
« Reply #2 on: March 01, 2007, 12:59:32 am »

I can substantiate this with real math (ignore if you are allergic Tongue)
A(n) = chance of a marine being alive at turn n = ((15/16) ^ n)
K = chance of a marine killing a marine killing a enemy = (1/2)
Enemies killed = SUM as n goes 1 -> infinity of (1/2) * (15/16) ^ n
= (1/2) * (SUM as n goes 1 -> infinity of  (15/16) ^ n)
= (1/2) * (1 / (1 - (15/16) ) )
= (1/2) * (16)
= 8
For once, the guestimate got it right! Usualy, the estimate people make about this sort of thing is way off.
Offline Offline

Gender: Male
Posts: 917

Good Grief

View Profile WWW
Re: Orz Marine Code
« Reply #3 on: March 02, 2007, 09:53:59 pm »

Those little guys are tough. I love launching clouds of them at
slower ships.

What sound does a penguin make?
Pages: [1] 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!