Clicker Heroes Ruby chance

clicker-heroes

What is the chance of getting 1 Ruby from a Fish?

Is it a 50% chance, or the chance of not getting a Ruby is higher?

I get only coins more often than I get Rubies.
Ruby

What exactly is the chance of Rubies from a fish?

Best Answer

Let's take a look at the source code, shall we?

The script responsible for (currently) the fish and the bee is heroclickerlib.managers.HiddenObjectManager.

Inside that script we find a function private function onHiderClick(param1:MouseEvent) : void.
This function is responsible for the on-click event when you click the fish.

private function onHiderClick(param1:MouseEvent) : void
  {
     var _loc4_:* = 0;
     var _loc5_:* = NaN;
     var _loc6_:* = NaN;
     this.removeHider();
     if(Rnd.boolean(0.44))
     {
        _loc4_ = 1;
        if(Rnd.boolean(0.04 + this._userData.ancients.doubleRubyPercent / 100))
        {
           _loc4_ = 2;
        }
        this._userData.addRubies(_loc4_,"hidden_object",-1);
        _loc5_ = this._battleManager.display.mouseX;
        _loc6_ = this._battleManager.display.mouseY;
        this._battleManager.uiManager.battleUI.transientEffects.showGeneralMessage(_loc5_,_loc6_,_("+%s Ruby!",_loc4_));
     }
     var _loc2_:Monster = new Monster();
     _loc2_.id = 2;
     _loc2_.level = this._userData.highestFinishedZone + 1;
     var _loc3_:Number = this._userData.getMonsterReward(_loc2_) * 10;
     _loc2_.isBoss = true;
     this._battleManager.itemDropManager.goldSplash(_loc3_,_loc2_,ServerTimeKeeper.instance.timestamp);
     HeroClickerSoundManager.instance.playSoundEffectById(36);
     this._battleManager.uiManager.battleUI.transientEffects.showGeneralMessage(580,152,"Yay!!");
  }

Two function calls are important here:

  1. if(Rnd.boolean(0.44)): this internally checks if a (uniformly distributed) random number is less than 0.44. This evaluates to a chance of nearly exact 44% of at least one ruby.
  2. if(Rnd.boolean(0.04 + this._userData.ancients.doubleRubyPercent / 100)): This rather lengthy call checks if a random number is less than 0.04 + the additional double ruby percentage of your ancients. This means that in 4% of all cases of getting a ruby, you get 2.
    Without any ancients, the chance of getting 2 rubies is about 0.44*0.04=0.0176 => 1.76%

The average amount of rubies you get after 1000 times clicking on the fish is: 444,4 => 44,44%

440 times at least one ruby
=>  440*4%  =     11 times 2 rubies = 22    +
=>  440*96% =  422,4 times 1 ruby   = 422,4

==> 444,4 rubies => ~444,4/1000 = 44,44% chance of getting one ruby on average

The expected amount of rubies per click is then 0,4444.

I used JPEXS Free Flash Decompiler to get to the source code.