Binding of Isaac: Rebirth Wiki
m (Text replacement - " ([\*\#\;\:]+)([A-Za-z0-9\'\"\(\[\{])" to " $1 $2")
No edit summary
Line 177: Line 177:
 
As nothing weighs some items specifically, it means each item combo probably has about a 0.005% chance of being your reward.
 
As nothing weighs some items specifically, it means each item combo probably has about a 0.005% chance of being your reward.
 
Testing material: 1000 Eden seeds
 
Testing material: 1000 Eden seeds
  +
  +
[[Category:Mechanics]]

Revision as of 02:50, 16 November 2018

This is a technical analysis of how the game randomly generates the various characteristics of the Eden character. Note that this analysis was performed by BLouBLue on version 1.05 (pre-Afterbirth). Thus, it may be obsolete now.

Launch

When launching the game, the main thing to know is the game will derive a bunch of subseeds that will be used by RNG instances dedicated to items, trinkets, pickups, enemies, level generation and character management.

This allows you to play your run slightly differently, yet still get the same items at the same place (for the most part, that's not entirely true).

One specific "character" subseed is used for Eden generation. This RNG instance is used during two phases:

  1. generate hearts, pickups and attributes, before level initialization;
  2. randomly pick cards, pills, trinkets and items, after level initialization.

It is reset to the character subseed before either phase. This means the same random numbers could come out of the RNG in the same order for both phases.

Hearts

Hearts are the first thing to be generated. The game tries its best to give you 3 full hearts, red and soul hearts altogether:

  1. the game randomly picks x = 0 to 3 red hearts;
  2. it will randomly pick between 0 and (3 - x) soul hearts;
  3. if no red hearts were picked at the first step, the game guarantees the player at least 2 soul hearts.

There cannot be any black hearts from this phase. Collectible items given afterward may exceed those limits.

Keys, Bombs and Coins

Eden has a 1/3 chance to start with either keys, bombs or coins. If you've been granted that chance, here are the possible outcomes:

  1. Eden starts with 1 key;
  2. Eden starts with 1 or 2 bombs;
  3. Eden starts with 1 to 5 coins.

Collectible active/passive items given afterward may give additional pickups, bringing the total beyond those limits.

The chance to start with a pickup is calculated as follows:

// rand(min,max) returns a random integer between min (inclusive) and max (exclusive)
if( (rand(0,3) > 0) && (rand(0,2) > 0) ) 
{ // 2/3 chance * 1/2 chance = 1/3 overall chance
    /* the player will get a pickup */
    tmp = rand(0, 3); // either 0, 1 or 2
    if(tmp == 1)
        give 1 key
    else if(tmp == 2)
        give 1 + rand(0,1) bombs
    else
        give 1 + rand(0,4) coins
}

Attributes

Attributes are based off Isaac's base attributes. An additive modifier (float value) is randomly chosen for each of the 6 attributes:

Attribute Eden's modifier range
damage -1.00 to +1.00
speed -0.15 to +0.15
tear delay -0.75 to +0.75
tear height -5.00 to +5.00
shot speed -0.25 to +0.25
luck -1.00 to +1.00

Here's what the attribute initialization part of the routine looks like:

// characterRng.Random() returns a float value between 0.0 and 1.0
Player->attributeModifierDamage       = (characterRng.Random() * 2.0f) + -1.0f;
Player->attributeModifierSpeed        = (characterRng.Random() * 0.3f) + -0.15f;
Player->attributeModifierTears        = (characterRng.Random() * 1.5f) + -0.75f;
Player->attributeModifierHeightRange  = (characterRng.Random() * 10.0f) + -5.0f;
Player->attributeModifierShotSpeed    = (characterRng.Random() * 0.5f) + -0.25f;
Player->attributeModifierLuck         = (characterRng.Random() * 2.0f) + -1.0f;

Pocket Items

Pills, cards, trinkets and items are picked after level generation. Two phases occur:

  1. give the player a chance to have either a pill, card or trinket;
  2. attempt to pick 1 active item and 1 passive item.

So, when consuming an Eden token, you have:

  • 1/3 chance to get a trinket;
  • 1/6 chance to get a pill;
  • 1/6 chance to get a card;
  • 1/3 chance to get none of the above.

These options are mutually exclusive. You cannot get a trinket and a card or pill. Here's what the actual routine looks like:

if(characterRng.Random(3) > 0) { // 2/3 chance to get pill, card or nothing
    if(characterRng.Random(2) > 0) { // 2/3 * 1/2 chance to get nothing
        give nothing
    }
    else { // 2/3 * 1/2 chance to get a pill or a card
        if(characterRng.Random(2) > 0) { // 1/3 * 1/2 chance to generate a pill
            give a random pill
        }
        else { // 1/3 * 1/2 chance to generate a card
            give a random card
        }
    }
}
else { // 1/3 chance to get a trinket
    give a random trinket
}

More about how pocket items of each type are selected:

  • pill colors and pill effects are shuffled based on a subseed derived from the main seed. 9 pill effects are selected and randomly affecter to each of the 9 flavors. If entitled to, Eden will randomly get one of those 9 pills;
  • trinkets are randomly chosen among the 62 trinkets. There are 32 random repicks, and another pass if unsuccessful. The game may give up, if the player hasn't unlocked any trinket;
  • Eden cannot start with the following cards/runes:
    • any rune,
    • 2 of clubs, 2 of diamonds, 2 of spades, 2 of hearts, Joker;
  • 2 sets of cards are created:
    • a special card set containing: Chaos card, Credit card, Rules card, A card against humanity and Suicide King,
    • a global set containing every other card except those that are forbidden,
    • Eden has a 1/25 chance to randomly get a card from the special set, and a 24/25 chance to get one from the global set.

Here's how the card selection is done, in pseudo-code:

// both isRunesAllowed and isSpecialCardsAllowed are set to false when initializing Eden.
// Card IDs can be found in the game's xml files
// cardRng.Random(min,max) returns a random integer between min (inclusive) and max (exclusive)
// cardRng.Random(max) returns a random integer between 0 (inclusive) and max (exclusive, so max-1 is the upper bound)
if(cardRng.Random(25) > 0) // 24/25 chance 
{
    if(cardRng.Random(10) || !isRunesAllowed) 
    {
        bool tmp = (cardRng.Random(5) != 0) || !isSpecialCardsAllowed;
        if(tmp == false) 
        {
            card_first = CARD_2_OF_CLUBS;
            card_last = CARD_JOKER;
        }
        else
        {
            card_first = CARD_0_THE_FOOL;
            card_last = CARD_XXI_THE_WORLD;
        }
    }
    else
    {
        card_first = RUNE_DESTRUCTION_HAGALAZ;
        card_last = RUNE_RESISTANCE_ALGIZ;
    }
}
else 
{
    card_first = CARD_CHAOS_CARD;
    card_last = CARD_SUICIDE_KING;
}

return cardRng.Random(card_first, card_last + 1);

Collectibles

The game does 101 attempts to fill both the active item slot and one passive item slot. At each attempt, it will randomly pick an item ID between 1 and 346.

There are a few disabled item IDs which cause the game to repick a random ID and go on to the next attempt:

  • #43: "Pills here!", an active item that does nothing and looks like a pill.
  • #59: "Tarot Card", a passive item that looks like a card and does nothing.
  • #61: Literally nothing, and is not defined in items.xml.
  • #235: Not Available
  • #238: Key Piece 1
  • #239: Key Piece 2
  • #263: Not Available

The first valid candidate (unlocked item) for the passive or active slot is selected, and will not be overwritten by subsequent attempts (there will be 101 attempts no matter what).

The player is given those items after 101 attempts, whether both slots are filled or not.

Therefore, Eden may start with up to 1 active item and up to 1 passive item. It is highly unlikely that a seed exists which gives Eden only 1 or no item.

As nothing weighs some items specifically, it means each item combo probably has about a 0.005% chance of being your reward. Testing material: 1000 Eden seeds