<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://nethackwiki.com/index.php?action=history&amp;feed=atom&amp;title=Talk%3AHorn_of_plenty</id>
	<title>Talk:Horn of plenty - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://nethackwiki.com/index.php?action=history&amp;feed=atom&amp;title=Talk%3AHorn_of_plenty"/>
	<link rel="alternate" type="text/html" href="https://nethackwiki.com/index.php?title=Talk:Horn_of_plenty&amp;action=history"/>
	<updated>2026-06-04T04:07:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.5</generator>
	<entry>
		<id>https://nethackwiki.com/index.php?title=Talk:Horn_of_plenty&amp;diff=80941&amp;oldid=prev</id>
		<title>Blackcustard: Nice source diving!</title>
		<link rel="alternate" type="text/html" href="https://nethackwiki.com/index.php?title=Talk:Horn_of_plenty&amp;diff=80941&amp;oldid=prev"/>
		<updated>2012-10-08T00:42:43Z</updated>

		<summary type="html">&lt;p&gt;Nice source diving!&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 00:42, 8 October 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot; &gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The selection of which item a horn of plenty gives you is done in the function {{function|apply.c|doapply}} via a call to {{function|mkobj.c|mkobj}} after picking potion (1/7 chance) or food (6/7 chance). {{function|mkobj.c|mkobj|x}} picks from the entire class based on the priorities in objects.c; {{function|apply.c|doapply|x}} then modifies that selection. For potions, if a magical potion is initially selected, it is changed via a call to {{function|objnam.c|rnd_class}}. Additionally {{function|objnam.c|rnd_class|x}} called repeatedly until something other than sickness is selected. The original potion probabilities on the page assumed {{function|objnam.c|rnd_class|x}} uses equal weight in making its selection. However, it uses the probability weights as mkobj. For example water has a 92 (out of 1000) probability, the magical potions have a combined probability of 742, and the non-magical potions excluding sickness have a combined probability of 216. If you assume {{function|objnam.c|rnd_class|x}} selects equally you get 9.2 + 74.2 / 5 = 24. If probabilities are applied as they are in {{function|objnam.c|rnd_class|x}} you get 9.2 + 74.2 * 92 / 216 = 40.8. When I changed numbers on the page I added links to the source code mentioned above. Also, I thought it would be useful to have overall probabilities, which is simply a matter of multiplying the class numbers by 1/7 for potions and 6/7 for food. --[[User:Skidragon2|Skidragon2]] ([[User talk:Skidragon2|talk]]) 17:47, 7 October 2012 (UTC)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The selection of which item a horn of plenty gives you is done in the function {{function|apply.c|doapply}} via a call to {{function|mkobj.c|mkobj}} after picking potion (1/7 chance) or food (6/7 chance). {{function|mkobj.c|mkobj|x}} picks from the entire class based on the priorities in objects.c; {{function|apply.c|doapply|x}} then modifies that selection. For potions, if a magical potion is initially selected, it is changed via a call to {{function|objnam.c|rnd_class}}. Additionally {{function|objnam.c|rnd_class|x}} called repeatedly until something other than sickness is selected. The original potion probabilities on the page assumed {{function|objnam.c|rnd_class|x}} uses equal weight in making its selection. However, it uses the probability weights as mkobj. For example water has a 92 (out of 1000) probability, the magical potions have a combined probability of 742, and the non-magical potions excluding sickness have a combined probability of 216. If you assume {{function|objnam.c|rnd_class|x}} selects equally you get 9.2 + 74.2 / 5 = 24. If probabilities are applied as they are in {{function|objnam.c|rnd_class|x}} you get 9.2 + 74.2 * 92 / 216 = 40.8. When I changed numbers on the page I added links to the source code mentioned above. Also, I thought it would be useful to have overall probabilities, which is simply a matter of multiplying the class numbers by 1/7 for potions and 6/7 for food. --[[User:Skidragon2|Skidragon2]] ([[User talk:Skidragon2|talk]]) 17:47, 7 October 2012 (UTC)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:Thank you for that explanation! I made the function names in your above text link to their definitions in the source code; I hope that's OK. --[[User:Bcode|Bcode]] ([[User talk:Bcode|talk]]) 18:06, 7 October 2012 (UTC)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:Thank you for that explanation! I made the function names in your above text link to their definitions in the source code; I hope that's OK. --[[User:Bcode|Bcode]] ([[User talk:Bcode|talk]]) 18:06, 7 October 2012 (UTC)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;:Hey that if...do...while bit in doapply is a nifty little construction, thanks for digging it up and puzzling it out. Nice source diving :). Am I reading this right, that the only way for a potion of sickness to appear is for it to be selected on the first roll? And that's what accounts for the low probability of sickness? (4.2% of potions, even though its probability for usual random generation is 42/1000; while oil's probability for usual random generation is only 30/1000, but it accounts for 13.3% of potions from the horn) Kind of a weird way to implement it, but that's the devteam for ya. [[User:Blackcustard|Blackcustard]] ([[User talk:Blackcustard|talk]]) 00:42, 8 October 2012 (UTC)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Blackcustard</name></author>
		
	</entry>
	<entry>
		<id>https://nethackwiki.com/index.php?title=Talk:Horn_of_plenty&amp;diff=80938&amp;oldid=prev</id>
		<title>Bcode: Linkify</title>
		<link rel="alternate" type="text/html" href="https://nethackwiki.com/index.php?title=Talk:Horn_of_plenty&amp;diff=80938&amp;oldid=prev"/>
		<updated>2012-10-07T18:06:10Z</updated>

		<summary type="html">&lt;p&gt;Linkify&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 18:06, 7 October 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Probabilities ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Probabilities ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The selection of which item a horn of plenty gives you is done in the function &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;doapply in &lt;/del&gt;apply.c via a call to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;mkobj in &lt;/del&gt;mkobj.c after picking potion (1/7 chance) or food (6/7 chance). &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;mkobj picks from the entire class based on the priorities in objects.c; doapply then modifies that selection. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;For potions, if a magical potion is initially selected, it is changed via a call to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;rnd_class in &lt;/del&gt;objnam.c. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;Additionally rnd_class called repeatedly until something other than sickness is selected. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;The original potion probabilities on the page assumed rnd_class uses equal weight in making its selection. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;However, it uses the probability weights as mkobj. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;  &lt;/del&gt;For example water has a 92 (out of 1000) probability, the magical potions have a combined probability of 742, and the non-magical potions excluding sickness have a combined probability of 216. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;If you assume rnd_class selects equally you get 9.2 + 74.2 / 5 = 24. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;If probabilities are applied as they are in rnd_class you get 9.2 + 74.2 * 92 / 216 = 40.8. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;When I changed numbers on the page I added links to the source code mentioned above. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;Also, I thought it would be useful to have overall probabilities, which is simply a matter of multiplying the class numbers by 1/7 for potions and 6/7 for food. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/del&gt;--[[User:Skidragon2|Skidragon2]] ([[User talk:Skidragon2|talk]]) 17:47, 7 October 2012 (UTC)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The selection of which item a horn of plenty gives you is done in the function &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{function|&lt;/ins&gt;apply.c&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;|doapply}} &lt;/ins&gt;via a call to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{function|&lt;/ins&gt;mkobj.c&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;|mkobj}} &lt;/ins&gt;after picking potion (1/7 chance) or food (6/7 chance). &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{function|mkobj.c|&lt;/ins&gt;mkobj&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;|x}} &lt;/ins&gt;picks from the entire class based on the priorities in objects.c; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{function|apply.c|&lt;/ins&gt;doapply&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;|x}} &lt;/ins&gt;then modifies that selection. For potions, if a magical potion is initially selected, it is changed via a call to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{function|&lt;/ins&gt;objnam.c&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;|rnd_class}}&lt;/ins&gt;. Additionally &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{function|objnam.c|&lt;/ins&gt;rnd_class&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;|x}} &lt;/ins&gt;called repeatedly until something other than sickness is selected. The original potion probabilities on the page assumed &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{function|objnam.c|&lt;/ins&gt;rnd_class&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;|x}} &lt;/ins&gt;uses equal weight in making its selection. However, it uses the probability weights as mkobj. For example water has a 92 (out of 1000) probability, the magical potions have a combined probability of 742, and the non-magical potions excluding sickness have a combined probability of 216. If you assume &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{function|objnam.c|&lt;/ins&gt;rnd_class&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;|x}} &lt;/ins&gt;selects equally you get 9.2 + 74.2 / 5 = 24. If probabilities are applied as they are in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{function|objnam.c|&lt;/ins&gt;rnd_class&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;|x}} &lt;/ins&gt;you get 9.2 + 74.2 * 92 / 216 = 40.8. When I changed numbers on the page I added links to the source code mentioned above. Also, I thought it would be useful to have overall probabilities, which is simply a matter of multiplying the class numbers by 1/7 for potions and 6/7 for food. --[[User:Skidragon2|Skidragon2]] ([[User talk:Skidragon2|talk]]) 17:47&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, 7 October 2012 (UTC)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:Thank you for that explanation! I made the function names in your above text link to their definitions in the source code; I hope that's OK. --[[User:Bcode|Bcode]] ([[User talk:Bcode|talk]]) 18:06&lt;/ins&gt;, 7 October 2012 (UTC)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bcode</name></author>
		
	</entry>
	<entry>
		<id>https://nethackwiki.com/index.php?title=Talk:Horn_of_plenty&amp;diff=80937&amp;oldid=prev</id>
		<title>Skidragon2: /* Probabilities */ new section</title>
		<link rel="alternate" type="text/html" href="https://nethackwiki.com/index.php?title=Talk:Horn_of_plenty&amp;diff=80937&amp;oldid=prev"/>
		<updated>2012-10-07T17:47:33Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Probabilities: &lt;/span&gt; new section&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Probabilities ==&lt;br /&gt;
&lt;br /&gt;
The selection of which item a horn of plenty gives you is done in the function doapply in apply.c via a call to mkobj in mkobj.c after picking potion (1/7 chance) or food (6/7 chance).  mkobj picks from the entire class based on the priorities in objects.c; doapply then modifies that selection.  For potions, if a magical potion is initially selected, it is changed via a call to rnd_class in objnam.c.  Additionally rnd_class called repeatedly until something other than sickness is selected.  The original potion probabilities on the page assumed rnd_class uses equal weight in making its selection.  However, it uses the probability weights as mkobj.   For example water has a 92 (out of 1000) probability, the magical potions have a combined probability of 742, and the non-magical potions excluding sickness have a combined probability of 216.  If you assume rnd_class selects equally you get 9.2 + 74.2 / 5 = 24.  If probabilities are applied as they are in rnd_class you get 9.2 + 74.2 * 92 / 216 = 40.8.  When I changed numbers on the page I added links to the source code mentioned above.  Also, I thought it would be useful to have overall probabilities, which is simply a matter of multiplying the class numbers by 1/7 for potions and 6/7 for food.  --[[User:Skidragon2|Skidragon2]] ([[User talk:Skidragon2|talk]]) 17:47, 7 October 2012 (UTC)&lt;/div&gt;</summary>
		<author><name>Skidragon2</name></author>
		
	</entry>
</feed>