Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Wasteland People Bitching About Jamming

Immortal

Arcane
In My Safe Space
Joined
Sep 13, 2014
Messages
5,062
Location
Safe Space - Don't Bulli
The funny thing is that we could never prove the numbers are lying, unless we looked at the code...

Code:
public override bool CheckForJammed()
{
ItemInstance_WeaponRanged itemInstance_WeaponRanged = this.pcStats.GetWeaponInstance() as ItemInstance_WeaponRanged;
if (itemInstance_WeaponRanged == null)
{
return false;
}
if (itemInstance_WeaponRanged.CheckForJammed())
{
this.PrintFloatingText(Language.Localize("Weapon Jam!", false), Color.get_red(), null, false);
AudioManager.Play("Weapon_OnJam", base.get_transform());
EventInfo_WeaponJammed eventInfo_WeaponJammed = ObjectPool.Get<EventInfo_WeaponJammed>();
eventInfo_WeaponJammed.mob = this;
eventInfo_WeaponJammed.weapon = itemInstance_WeaponRanged;
eventInfo_WeaponJammed.isJammed = true;
MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish(eventInfo_WeaponJammed, false);
return true;
}
return false;
}

Checks if your weapon is a long range weapon.. if so it runs the algorithm to see if you will be jammed for this attack.


Code:
// ItemInstance_WeaponRanged
public int GetChanceToJam()
{
ItemTemplate_WeaponRanged itemTemplate_WeaponRanged = this.template as ItemTemplate_WeaponRanged;
int num = itemTemplate_WeaponRanged.chanceToJam;
foreach (ItemInstance_Mod current in this.mods)
{
num += (int)current.GetBonus("chanceToJam");
}
num = Mathf.Clamp(num, 0, 100);
return num;
}

This is the code that generates the actual ChanceToJam Percentage.. it's based off a weapon template and any mods you added to the weapon. No other factors *APPEAR* to matter.

Only the base % of the weapon to Jam and any mods that may increase or decrease chance to Jam.


Code:
public bool CheckForJammed()
{
int chanceToJam = this.GetChanceToJam();
int num = Random.Range(0, 100);
if (num < chanceToJam)
{
this.SetJammed(true);
return true;
}
return false;
}

This is the actual algorithm code that people think is broken.. Here We Go..

Essentially

int chanceToJam = this.GetChanceToJam();

Take the chance % for a weapon to Jam then generate a random number between 1 and 100... if that number is below the percentage then your weapon Jams..

Curious about the Random number generator?

Unity uses the Marsaglia's Xorshift 128 Algorithm - http://en.wikipedia.org/wiki/Xorshift

"A naive C implementation of a xorshift+ generator that passes all tests from the BigCrush suite (with an order of magnitude fewer failures than Mersenne Twister or WELL)"

This random generator out performs Mersenne Twister when put up against the BC Suite.. which is on equal par with the .NET random generator implemented by Microsoft (Donald E. Knuth's subtractive random number generator algorithm)

Here are the results of a program I wrote for my Statistical Theory Course comparing MT with Donald's Subtractive algorithm (Again the one employed by .NET)

Source Code for my implementation of MT (If you want to test this algorithm next to .NET or Unity)

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RNGTool
{
  class MT_Random
  {
  // State of Random Generator
  private UInt32[] genState;
  private UInt32 index;

  // MT19937 uses 623 Entries, Accounting for 0 Index
  private const Int16 N = 624;

  // For Bit Shifting and Exclusive ORing
  // Reference For Bits - Hiroshima University C++ Code
  private const UInt32 UPPER_MASK = (UInt32)0x80000000; /* most significant bits */
  private const UInt32 LOWER_MASK = (UInt32)0x7fffffff; /* least significant bits */


  // Default Constructor
  public MT_Random()
  {
  UInt32 GenSeed = 1337;
  UInt32.TryParse((Environment.TickCount & Int32.MaxValue).ToString(), out GenSeed);

  // If no Seed is Provided use Time (Tick Count)
  inititialize(GenSeed);
  }

  // Seed Provided for constructor
  public MT_Random(UInt32 seed)
  {
  inititialize(seed);
  }


  // Initialize the Random Generator
  private void inititialize(UInt32 seed)
  {
  // Set Boundaries for This Algorithm
  genState = new UInt32[N];

  index = 0;
  genState[0] = seed;

  // Initialize State of Generator
  // last 32 bits of(1812433253 * (State[i-1] xor (right shift by 30 bits(State[i-1]))) + i) // 0x6c078965

  try
  {
  for (UInt16 i = 1; i < N; i++)
  {
  genState[i] = ((UInt32)1812433253 * (genState[i - 1] ^ (genState[i - 1] >> 30)) + i);
  }
  }
  catch(Exception ex)
  {
  ex.Message.ToString();
  }

  }

  // Extract a tempered pseudorandom number based on the index-th value,
  // calling generate_numbers() every 624 numbers
  private UInt32 extract_number()
  {
  if(index == 0)
  {
  generate_numbers();
  }

  /* Tempering */
  UInt32 y = genState[index];
  // y := y xor (right shift by 11 bits(y))
  y ^= (y >> 11);
  // y := y xor (left shift by 7 bits(y) and (2636928640)) == 0x9d2c5680
  y ^= (y << 7) & 0x9d2c5680;
  // y := y xor (left shift by 15 bits(y) and (4022730752)) // 0xefc60000
  y ^= (y << 15) & 0xefc60000;
  // y := y xor (right shift by 18 bits(y))
  y ^= (y >> 18);

  // index := (index + 1) mod 624
  index = (index + 1) % 624;

  return y;
  }

  // Generate an array of 624 untempered numbers
  private void generate_numbers()
  {


  for (UInt32 i = 0; i <= 623; i++)
  {
  // bit 31 (32nd bit) of MT[i]
  UInt32 y = (genState[i] & 0x80000000)
  // bits 0-30 (first 31 bits) of MT[...]
  + (genState[(i + 1) % 624] & 0x7fffffff);

  // MT[i] := MT[(i + 397) mod 624] xor (right shift by 1 bit(y))
  genState[i] = genState[(i + 397) % 624] ^ (y >> 1);

  // Check if Y is Odd Number
  if ((y % 2) != 0)
  {
  // MT[i] := MT[i] xor (2567483615) // 0x9908b0df
  genState[i] = genState[i] ^ 0x9908b0df;
  }
  }
  }



  // Reference: Jerry Coffin
  // Provided a Method to Give Range Values without introducing SKEW

  // Using Modulus or Division introduces SKEWed values and
  // will not give a uniform distribution (except for powers-of-two)
  public int getNoSkewInteger(int max)
  {
  int divisor = (int) (UInt32.MaxValue / (max + 1));
  int newVal;

  do
  {
  newVal = (int)(extract_number() / divisor);
  } while (newVal > max);

  return newVal;
  }


  // Returns a random value in the range between
  // min and max values
  // Value may lose some of it's randomness with skewed
  // modulus value
  public int Next(int min, int max)
  {
  return (int) extract_number() % (max - min + 1) + min;
  }

  }
}


Tl;dr - The Jamming Works Fine Mathematically*

So Far Nothing Appears modifies Jam except adding Mods to The Gun

NPC's follow the same rules for jamming as you do

The Random Generator in Unity is generally more resistant to repeating numbers then .NET or MT..


The formula is a simple unbiased comparison, they don't floor() the number or use division to generate a percentage which would introduce number
SKEW

Inb4 Matt comes in here and lectures me on Statistics


* True Random Doesn't Exist But It's as close as your gonna get


Warning: I spent about 10 minutes looking at the code and writing this response.. I will keep looking it over and if I missed something then I will update the thread, or if one of the other 1337 hax0rs wants to contest my thread then please go ahead.
 
Last edited:

Owlish

Dumbfuck!
Dumbfuck Douchebag! Village Idiot Repressed Homosexual Possibly Retarded Edgy Shitposter
Joined
Sep 14, 2013
Messages
2,817
How about you shut your word hole, buddy? All the numbers and the colors and the facts, backed by the rumors and the figures and the stats, too much to know too much to see it might mean something to you but it's nothing to me! Just another ad for someone's version for how they think it should be...
 

GarfunkeL

Racism Expert
Joined
Nov 7, 2008
Messages
15,463
Location
Insert clever insult here
No, just confirms that - as usual - it's nothing more than confirmation bias at work here. I've got a number of jams but not excessive amounts, and they have been extremely rare after putting sturdy mags on most of my guns. Meanwhile, I've seen enemies get jammed at least four times so I'm quite content.

Reminds me of the bitching at Pdox games when AI behaved identically/similarly in two games in a row and some people complained because of course seeing something twice means it happens 100% of the time.
 

Gozma

Arcane
Joined
Aug 1, 2012
Messages
2,951
Wasteland 2 obviously should have shipped with a sample of nuclear waste and a sensor that produces random numbers based on quantum mechanically indeterminate radioactive decay events, nothing less will do
 

Norfleet

Moderator
Joined
Jun 3, 2005
Messages
12,250
ITF: people don't understand probability.
I would imagine that this cuts both ways: People think that a weapon jams too much because it DOES jam too much.

But 7% of the time my sniper rifle jams every time. YOU CAN'T EXPLAIN.
I'm not sure if this is an actual stat from the game, but let's look at the numbers: If your weapon jams 7% of the time, then it will correctly fire 93% of the time. You have an 11% chance (0.93^30) of successfully emptying a 30 round magazine without jamming. Let's say we use 1% chance of jamming (99% chance of cycling): 0.99^30 = Only 74% chance of reaching the bottom of a 30 round mag.

In short, if the percentage chance of failure can be expressed as an integer, it's too damn high, and while users may not comprehend probability terribly well, neither do the designers who set those values.

Most people, both designers, and users, see values of 90% or better as "very good". An engineer will tell you that even 99% is shit. Any engineer building you something that only works 99% of the time is going to find himself embroiled in a vicious lawsuit and/or lose his job.
 

Volourn

Pretty Princess
Pretty Princess Glory to Ukraine
Joined
Mar 10, 2003
Messages
24,924
WAAAAAAAAAAAAAAAAAAA!


That's the true jam.

You guys whine more than the friggin' sheep in the game. LMFAO
 

Makagulfazel

Educated
Joined
Sep 14, 2012
Messages
80
Sigh...
IT'S A FUCKIN' GAME. Wait, nvm, gotta go whisper something in a black cat's ear so can increase luck.
 
Self-Ejected

ZodoZ

Self-Ejected
Patron
Joined
Nov 6, 2013
Messages
798
Shadorwun: Hong Kong
Okay your fancy statistics are pretty something, BUT!

Murphy's Law >>>> Any of your fancy statistical analysis

I dunno who this Murphy is but his guns jammed so much in WL2 he invented an immutable law.

hah so there
 

kain30

Cipher
Joined
Aug 7, 2014
Messages
543
Location
spain
i don´t mind that my weapons jams sometimes 3 times in a row because that happened to enemies too and adds more to the challenge
 

gunman

Arcane
Developer
Joined
Jan 4, 2008
Messages
1,050
Code:
public bool CheckForJammed()
{
int chanceToJam = this.GetChanceToJam();
>> int num = Random.Range(0, 100);  <<
if (num < chanceToJam)
{
this.SetJammed(true);
return true;
}
return false;
}

shouldn't this be:
int num = Random.Range(0, 99);
?

I mean, if chanceToJam is 100, you can still have a 1/101 chance of not happening
 
Self-Ejected

ZodoZ

Self-Ejected
Patron
Joined
Nov 6, 2013
Messages
798
Shadorwun: Hong Kong
"i don´t mind that my weapons jams sometimes 3 times in a row because that happened to enemies too and adds more to the challenge"

+1
Good point

Desert Raiders have cornered your rag tag group on it's way to uncover a hidden cache you heard rumors about.
Everyone is surprised by a crazed Red Skorpion grenade lobber running full tilt towards 3 of your mates caught flat footed.
As he raises his arm to toss the 'nade you have just enough time to fire off your bullpup sniper rifle.

"Click"

JAMMED

"uh oh"
 

J_C

One Bit Studio
Patron
Developer
Joined
Dec 28, 2010
Messages
16,947
Location
Pannonia
Project: Eternity Wasteland 2 Shadorwun: Hong Kong Divinity: Original Sin 2 Steve gets a Kidney but I don't even get a tag. Pathfinder: Wrath
i'M SUPER AWESOME STATISTIC PROGRAMMER GUY, CHECK OUT HOW CLEVER I AM. BLA BALA BAL BLA ALB
Thanks the info. Weapons still jams a little too many times, but it seems it is just bad luck.
 

Immortal

Arcane
In My Safe Space
Joined
Sep 13, 2014
Messages
5,062
Location
Safe Space - Don't Bulli
Code:
public bool CheckForJammed()
{
int chanceToJam = this.GetChanceToJam();
>> int num = Random.Range(0, 100);  <<
if (num < chanceToJam)
{
this.SetJammed(true);
return true;
}
return false;
}

shouldn't this be:
int num = Random.Range(0, 99);
?

I mean, if chanceToJam is 100, you can still have a 1/101 chance of not happening

Returns a random integer number between min [inclusive] and max [exclusive] (Read Only).

Code:
if (num < chanceToJam)


The max number is not counted so it's a Random number between 0 - 99.. Also the if statement only does a less than comparison.
If my % to Jam is 3% and I generate a random number of 3.. My weapon will not jam.. I must generate a 0, 1 or 2.

which has a 3% chance given a min value of 0 and a max of 99. (assuming my number generator is not biased which this one isn't in any determinable way as far as any person playing the game is concerned)


FYI: if people hate Jam.. it takes 1 second literally to disable them.. I will be really sad if that's the first mod people actually want.



Wasteland 2 obviously should have shipped with a sample of nuclear waste and a sensor that produces random numbers based on quantum mechanically indeterminate radioactive decay events, nothing less will do

Should have been a backer pledge. REAL NUCLEAR WASTE! GLOWS IN THE DARK! Create a modern day wasteland in your own home!

All Nuclear waste kindly donated by Japan. :salute:
 
Last edited:

Dickie

Arcane
Patron
Joined
Jul 29, 2011
Messages
4,254
Steve gets a Kidney but I don't even get a tag.
Most people, both designers, and users, see values of 90% or better as "very good". An engineer will tell you that even 99% is shit. Any engineer building you something that only works 99% of the time is going to find himself embroiled in a vicious lawsuit and/or lose his job.
Like the Xbox360?

I'm slightly disappointed that nothing else modifies it. It would be nice if luck or weapon skill or even the weaponsmithing skill would have some effect.
 

Immortal

Arcane
In My Safe Space
Joined
Sep 13, 2014
Messages
5,062
Location
Safe Space - Don't Bulli
Most people, both designers, and users, see values of 90% or better as "very good". An engineer will tell you that even 99% is shit. Any engineer building you something that only works 99% of the time is going to find himself embroiled in a vicious lawsuit and/or lose his job.
Like the Xbox360?

I'm slightly disappointed that nothing else modifies it. It would be nice if luck or weapon skill or even the weaponsmithing skill would have some effect.

all of these things would take 5 minutes to change.. The hard part isn't doing that... but figuring out what makes sense and what is balanced..

If you were going to reduce JAM based on these skills and factors. I think the base JAM % should then go up.. right? I mean 3% - 6% is just enough to impact combat once and a while without being overbearing.. if your able to reduce these %'s they should be higher to incentivice that.. no?

ITF: people don't understand probability.
I would imagine that this cuts both ways: People think that a weapon jams too much because it DOES jam too much.

But 7% of the time my sniper rifle jams every time. YOU CAN'T EXPLAIN.
I'm not sure if this is an actual stat from the game, but let's look at the numbers: If your weapon jams 7% of the time, then it will correctly fire 93% of the time. You have an 11% chance (0.93^30) of successfully emptying a 30 round magazine without jamming. Let's say we use 1% chance of jamming (99% chance of cycling): 0.99^30 = Only 74% chance of reaching the bottom of a 30 round mag.

In short, if the percentage chance of failure can be expressed as an integer, it's too damn high, and while users may not comprehend probability terribly well, neither do the designers who set those values.

Most people, both designers, and users, see values of 90% or better as "very good". An engineer will tell you that even 99% is shit. Any engineer building you something that only works 99% of the time is going to find himself embroiled in a vicious lawsuit and/or lose his job.

The point is that the numbers that appear in the tooltips are accurate.. If your now arguing about the design decision that old guns will Jam more... (NPC's weapons Jam in the exact same way) then that's another argument. Or you can just modify the game to be the way you want.. remove Jamming completely.

FYI the second post you quoted was a troll post.
 
Last edited:

AN4RCHID

Arcane
Joined
Jan 24, 2013
Messages
4,799
Weren't people reporting getting jams after modding their weapons to 0%? Someone should do an analysis using real world data e.g. http://sinepost.wordpress.com/2012/11/11/is-xcom-truly-random/

ymJl11M.jpg
 

Vault Dweller

Commissar, Red Star Studio
Developer
Joined
Jan 7, 2003
Messages
28,035
I fought some red scorpions, the last guy had 1 (one!) HP left, my sniper had 95% chance but the fucking rifle got jammed and the bastard threw a pipe bomb which killed 3 of my men. True story, bros.
 

Immortal

Arcane
In My Safe Space
Joined
Sep 13, 2014
Messages
5,062
Location
Safe Space - Don't Bulli
Weren't people reporting getting jams after modding their weapons to 0%? Someone should do an analysis using real world data e.g. http://sinepost.wordpress.com/2012/11/11/is-xcom-truly-random/

ymJl11M.jpg

We don't need to because we have the code.. Also I question this authors sample size.. My sample size was 25 millionish and that still was too low to accurately detect any noticeable number bias between .NET and C++ BOOST implementations.
If there's a issue with the 0% JAM then it would likely be a bug. From what I saw this edge case was accounted for by using a less than operator. (This is where I would ask for the bug to be reproduced by a QA tester)
 

imweasel

Guest
Weapons still jams a little too many times, but it seems it is just bad luck.

5% chance to jam ≙ statiscally, 1 out of 20 shots will cause your gun to jam

So we mod our gunz with this baby here:

bW6t7gZ.jpg


1% chance to jam ≙ statiscally, 1 out of 100 shots will cause your gun to jam

mind-blown-2.gif
 

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom