Random number generation: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
m (typo)
(clarified separateness of channels and updated to current patch. apparently nectar and mutating effects reset brain brine too now!)
 
Line 1: Line 1:
{{Cleanup|Needs more info on main channel RNG, world generation, and Irritable Genome. Probably needs some rephrasing for clarity as well.}}
{{Cleanup|Needs more info on main channel RNG, world generation, and Irritable Genome. Probably needs some rephrasing for clarity as well.}}
Random number generation (RNG) is used in most mechanics in Caves of Qud. There are two kinds of RNG in Qud - the main channel, which is used for most random effects, and specially seeded channels, which are used for particular effects that cannot be rerolled.
Random number generation (RNG) is used in most mechanics in Caves of Qud. There are two kinds of RNG in Qud - the main channel, which is used for most random effects, and specially seeded channels, which are used for particular effects that cannot be normally rerolled.


== Main channel ==
== Main channel ==
The main channel is used by almost anything that needs random values. Anything dependent on the main channel can be rerolled with [[Precognition]]. Notably, the random result for mutants of {{favilink|Eaters' Nectar injector|plural}} uses the main RNG channel rather than a seeded channel, unlike {{favilink|drop of nectar|plural}}.{{Code Reference|class=Nectar_Tonic_Applicator}}
The main channel is used by almost anything that needs random values, including cooking with {{favilink|neutron flux}}{{Code Reference|namespace=XRL.World.Effects|class=CookingDomainDensity_UnitPermanentAV}}. Anything dependent on the main channel can be rerolled with [[Precognition]]. Notably, the random result for mutants of {{favilink|Eaters' Nectar injector|plural}} uses the main RNG channel rather than a seeded channel, unlike {{favilink|drop of nectar|plural}}.{{Code Reference|class=Nectar_Tonic_Applicator}}


== Seeded RNG ==
== Seeded RNG ==


A few rolls use RNG channels with a stored seed. A roll on one of these channels is uniquely determined by the seed, and generates a new seed which is then saved for the next roll.{{Code Reference|namespace=XRL.World|class=GameObject|method=GetSeededRandom}} This means that they cannot be rerolled with [[Precognition]] effects, as returning to the beginning of the vision will restore the original seed. The seeded effects are:
A few rolls use named RNG channels with a stored seed. A roll on one of these channels is uniquely determined by the seed, and generates a new seed which is then saved on the associated game object (usually the player) for the next roll.{{Code Reference|namespace=XRL.World|class=GameObject|method=WithSeededRandom}} This means that they cannot be trivially rerolled with [[Precognition]] effects, as returning to the beginning of the vision will restore the original seed. However, some seeded RNG channels can be rerolled by specific in-game effects outside of their main usages. [[Body swapping]] with a clone may also reset seeded effects. The seeded effects are:


* Obtaining [[Mutations]] - this applies mainly to the set of options when buying a new mutation.{{Code Reference|namespace=XRL.UI|class=StatusScreen|method=BuyRandomMutation}} The mutation RNG channel can be rerolled by applying an {{favilink|Eaters' Nectar injector}} or cooking with a {{favilink|drop of nectar}}. Additionally, the [[mutating]] effect (from the mutating gaze of a {{favilink|gamma moth}}) repeatedly rerolls this channel when it gives the message "You feel increasingly unstable.".{{Code Reference|namespace=XRL.World.Effects|class=Mutating}}
* Obtaining [[Mutations]] - this uses the "RandomMutationBuy" channel and applies mainly to the set of options when buying a new mutation.{{Code Reference|namespace=XRL.UI|class=StatusScreen|method=BuyRandomMutation}} The mutation RNG channel can be rerolled by applying an {{favilink|Eaters' Nectar injector}} or cooking with a {{favilink|drop of nectar}}. Additionally, the [[mutating]] effect (from the mutating gaze of a {{favilink|gamma moth}}) repeatedly rerolls this channel when it gives the message "You feel increasingly unstable.".{{Code Reference|namespace=XRL.World.Effects|class=Mutating|name="mutating"}}{{Code Reference|namespace=XRL.World|class=GameObject|method=PermuteRandomMutationBuys|name=permute}}


* Cooking with {{favilink|drop of nectar|plural}} - this is a separate channel from the mutation seeded RNG, but the cooking effect specifically rerolls the mutation RNG in order to reset the mutation buy options.{{Code Reference|namespace=XRL.World.Effects|class=CookingDomainAttributes_UnitPermanentAllStats_25Percent}}
* Drinking {{favilink|brain brine}} - this uses the "brainbrine" channel. While the effect type is determined by the seeded RNG, the specific result can be determined by other RNG channels. For instance, if drinking {{favilink|brain brine}} gives secrets or skills, it will continue to give the same number of secrets or skills even when rerolled with Precognition, but the specific secrets or skills will be picked using the general RNG channel. However, if it gives a mutation, it uses its own seeded RNG channel rather than the mutation RNG channel.{{Code Reference|namespace=XRL.World.Effects|class=BrainBrineCurse}} Like mutations, this RNG channel can be rerolled by applying an {{favilink|Eaters' Nectar injector}} or cooking with a {{favilink|drop of nectar}}. Additionally, the [[mutating]] effect (from the mutating gaze of a {{favilink|gamma moth}}) repeatedly rerolls this channel when it gives the message "You feel increasingly unstable.".<ref name="mutating"/><ref name="permute"/>


* Drinking {{favilink|brain brine}} - While the effect type is determined by the seed, the specific result is not always. For instance, if drinking {{favilink|brain brine}} gives secrets, it will continue to give the same number of secrets even when rerolled with Precognition, but it may give different secrets. However, if it gives a mutation, it uses its own seeded RNG channel rather than the mutation RNG channel.{{Code Reference|namespace=XRL.World.Effects|class=BrainBrineCurse}}
* Cooking with {{favilink|drop of nectar|plural}} - this uses the "CookingDomainAttributes_UnitPermanentAllStats_25Percent" channel. Note that this is a separate channel from the mutation and brain brine seeded RNGs, even though the cooking effect rerolls both of these channels.{{Code Reference|namespace=XRL.World.Effects|class=CookingDomainAttributes_UnitPermanentAllStats_25Percent}}<ref name="permute"/> It cannot be rerolled through any means.


== References ==
* Generation of Sultan murals in the [[Tomb of the Eaters]] - this uses the "SultanMural" channel.{{Code Reference|class=SultanMuralController}} This cannot be rerolled through any means and has no mechanical impact on gameplay.
<references/>
 
{{References|2.0.203.28}}

Latest revision as of 15:22, 4 April 2022

This article may need cleanup to meet quality standards.
Please help improve this page by editing it.

Reason: "Needs more info on main channel RNG, world generation, and Irritable Genome. Probably needs some rephrasing for clarity as well."

This article may need cleanup to meet quality standards.
Please help improve this page by editing it.

Reason: "Needs more info on main channel RNG, world generation, and Irritable Genome. Probably needs some rephrasing for clarity as well."

Random number generation (RNG) is used in most mechanics in Caves of Qud. There are two kinds of RNG in Qud - the main channel, which is used for most random effects, and specially seeded channels, which are used for particular effects that cannot be normally rerolled.

Main channel

The main channel is used by almost anything that needs random values, including cooking with neutron flux[1]. Anything dependent on the main channel can be rerolled with Precognition. Notably, the random result for mutants of Eaters' nectar injectors uses the main RNG channel rather than a seeded channel, unlike drops of nectar.[2]

Seeded RNG

A few rolls use named RNG channels with a stored seed. A roll on one of these channels is uniquely determined by the seed, and generates a new seed which is then saved on the associated game object (usually the player) for the next roll.[3] This means that they cannot be trivially rerolled with Precognition effects, as returning to the beginning of the vision will restore the original seed. However, some seeded RNG channels can be rerolled by specific in-game effects outside of their main usages. Body swapping with a clone may also reset seeded effects. The seeded effects are:

  • Obtaining Mutations - this uses the "RandomMutationBuy" channel and applies mainly to the set of options when buying a new mutation.[4] The mutation RNG channel can be rerolled by applying an Eaters' nectar injector or cooking with a drop of nectar. Additionally, the mutating effect (from the mutating gaze of a gamma moth) repeatedly rerolls this channel when it gives the message "You feel increasingly unstable.".[5][6]
  • Drinking brain brine - this uses the "brainbrine" channel. While the effect type is determined by the seeded RNG, the specific result can be determined by other RNG channels. For instance, if drinking brain brine gives secrets or skills, it will continue to give the same number of secrets or skills even when rerolled with Precognition, but the specific secrets or skills will be picked using the general RNG channel. However, if it gives a mutation, it uses its own seeded RNG channel rather than the mutation RNG channel.[7] Like mutations, this RNG channel can be rerolled by applying an Eaters' nectar injector or cooking with a drop of nectar. Additionally, the mutating effect (from the mutating gaze of a gamma moth) repeatedly rerolls this channel when it gives the message "You feel increasingly unstable.".[5][6]
  • Cooking with drops of nectar - this uses the "CookingDomainAttributes_UnitPermanentAllStats_25Percent" channel. Note that this is a separate channel from the mutation and brain brine seeded RNGs, even though the cooking effect rerolls both of these channels.[8][6] It cannot be rerolled through any means.
  • Generation of Sultan murals in the Tomb of the Eaters - this uses the "SultanMural" channel.[9] This cannot be rerolled through any means and has no mechanical impact on gameplay.

References

This information is reliable as of patch 2.0.203.28.
  1. XRL.World.Effects.CookingDomainDensity_UnitPermanentAV
  2. XRL.World.Parts.Nectar_Tonic_Applicator
  3. XRL.World.GameObject, method WithSeededRandom
  4. XRL.UI.StatusScreen, method BuyRandomMutation
  5. 5.0 5.1 XRL.World.Effects.Mutating
  6. 6.0 6.1 6.2 XRL.World.GameObject, method PermuteRandomMutationBuys
  7. XRL.World.Effects.BrainBrineCurse
  8. XRL.World.Effects.CookingDomainAttributes_UnitPermanentAllStats_25Percent
  9. XRL.World.Parts.SultanMuralController