Talk:Trading

Ore


I don't think there is actually a new ore block, but I'm not sure. The image of that block (in the inventory) looks very similar to the smooth stone block, but there seems to be little specks as shown in the enlarged file image. - Asterick6 (talk) 06:07, 22 May 2012 (UTC)


 * That's what an ore block is. It's an overlay on a smoothstone image. Joe4429 06:08, 22 May 2012 (UTC)


 * (I know what an ore block is). Ok then this isn't a real image, and I don't think there is an actual ore block for the coin. - Asterick6 (talk) 06:13, 22 May 2012 (UTC)


 * It's in the top-right corner of the image. I created this out of what I can see. Joe4429 06:22, 22 May 2012 (UTC)


 * Ah I see it now. Interesting. - Asterick6 (talk) 06:36, 22 May 2012 (UTC)


 * Wait maybe this isn't a new ore, but just a new texture for the redstone ore. If there's a new gravel texture, then there might be a new redstone ore texture. We should just wait until more info is released... - Asterick6 (talk) 06:48, 22 May 2012 (UTC)
 * Here's an enhanced screenshot btw. - Asterick6 (talk) 21:43, 22 May 2012 (UTC)


 * I'm under the impression it's either a new texture, an ore he made just for testing, or something which may or may not be related to the trading system. In the case of testing, it'd drop coins just so he knows how the game drops them. I honestly wouldn't like an ore that drops acceptable coins or being able to personally craft coins which a Villager would accept. If money worked like that... Well. If it's crafted from some new gem, maybe it'd make sense, but you'd still have to craft it. The same picture shows 20 raw chickens gets a coin. MegaScience 09:52, 22 May 2012 (UTC)


 * Btw for the other comment about the trade file: I just copied that from the Villager article. You gotta remove that one too then. - Asterick6 (talk) 21:01, 22 May 2012 (UTC)

Chicken clarity
Although it says 1 coin for twenty chickens i bet it is similar to how if you put 64 wood blocks the output on the crafting table still says 4 planks, and you just press it 64 times or shift-click.It basically means you get 64 sets of four, so chicken would go 20 groups of 1.


 * I suspect similarly. Until we're sure of anything, we shouldn't put like "This equals that." or "This ends up as that." I might have added something similar, sorry if I did. Coins might stack to different amounts... Who knows? MegaScience 19:21, 22 May 2012 (UTC)


 * I just spawned around 100 villagers and tried to trade with them. First thing I realized is that most have only one Item in their Inventory, and only few had the possibility to trade 2. Then, I saw that ONE sold me Bottles o' Enchanting, meaning they are now avaliable in Survival Mode. Next thing to mention is that the Prices may differ (2 villagers both sold diamond Chestplates, one for 16, one for 17 Emeralds), and that the price system does not make much sense (4 diamonds for 1 Emerald WUT? never gonna do that). Librarians usually buy Paper/Books and sell Bookshelves.
 * --JayTie


 * You can even trade for chain armors (among all the iron and diamond tools and armors the game has) with blacksmiths. Also only the priests (purple clothes) can give you bottles o' enchanting. However, I noted that the prices aren't always the same from one villager to another.
 * --Pauolo 17:15, 24 May 2012 (UTC)

More Trade Get!
After trading, I noticed the villager had a purple swirly particle effect. The villager then had more options available for trading. So apparently, by trading with a particular villager, you can gain favor and open up more items to trade with that one villager with eight trades maximum. --108.76.103.35 16:44, 24 May 2012 (UTC)


 * That's right, but sometimes it requires more trading than only one to access to new options (maybe a bug, it seems this snapshot is quite laggy and has problems with map loading).
 * --Pauolo 17:01, 24 May 2012 (UTC)

Trading info on Villager article
I added trading info to the Villager article before I knew this article existed. I included a table which includes the quantities villagers buy/sell items and their prices, and I also included a chart of 55 test offers made by each villager class. I'm not sure how to merge that into this article, as some of the information here seems outdated or missing, but I don't think overwriting those parts of this article is necessarily a good idea. If anyone wants to make the merge when more is known about trading, feel free to do so. Just avoid throwing out data from either article :p --WolfieMario 21:09, 24 May 2012 (UTC)


 * I'm doing the trade data on this article. I'll go ahead and merge your findings with mine, and remove the table from the Villager page. (I'll leave the picture there for now; that's nifty.)


 * ...Oh, I haven't been paying attention to professions! I'll add the gold ingots to other professions, thanks. I'm merging by taking the min and max from each. I'm going to keep the table format here, but if someone wants to consolidate the formatting down the line, that'd be fine.

--Zeta0134 22:40, 24 May 2012 (UTC)


 * I'm going to bring the Trading text from Villager over to the Trading page, and replace it on the Villager page with a link. That should eliminate the redundancy and let us maintain it in one place.

--Zeta0134 22:49, 24 May 2012 (UTC)

EDIT: All done. Check to make sure I didn't butcher anything; it looks correct to me. --Zeta0134 22:53, 24 May 2012 (UTC)


 * You omitted some data (specifically, larger price ranges I found). I also re-added my observation chart, as there's currently nothing indicating how rare or common various offers are. --WolfieMario 23:13, 24 May 2012 (UTC)


 * Ayaaa, I updated my list in notepad++ but didn't transfer to the wiki. My bad, but looks like you fixed it. This page is certainly coming together. :D Most of the prices have stabilized for my testing; if anything, I think the only deviations will be in the blacksmith. --Zeta0134 23:25, 24 May 2012 (UTC)

pricing is a joke
i do hope this gets made more reasonable at official release, i mean damn, 4-5 diamonds/8-9 iron for a single Em and a compass costs 10 Em? sheeeeeeet. 96.61.162.71 04:21, 25 May 2012 (UTC)


 * You can also sell (renewable) wool at the rate of 20/1, and buy diamond gear for as little as 7 Em. There does not appear to be any kind of internal value to the items, I mean, a compass costs more than a diamond helmet.2.109.200.145 15:51, 25 May 2012 (UTC)Anonymus


 * I agree about diamonds, but 1 stack of logs gets you 3 Em if you cook them into charcoal so you can get lots of Ems cheaply. 78.150.199.100 13:54, 27 May 2012 (UTC)


 * They buy paper. One can make a huge automatic sugar cane farm for that. 4 stacks of sugar cane buy a diamond pickaxe, or a stack of cooked meat. 17,5 stacks of sugar cane buy a full diamond armor set. 2 inventories and a half buy Bottle o' Enchanting for lvl 50. --88.173.92.54 06:40, 29 May 2012 (UTC)

"villager" class villager
Can anyone find out if the villager (green robes, don't naturally spawn) has anything to sell, and if so, what?
 * It always only buys 8-9 gold ingots per emerald, and has no other offers. I put this information up before, but it seems it's been removed - it seems anything that does not normally occur in vanilla tends to get removed from this wiki :/ --WolfieMario 14:09, 25 May 2012 (UTC)

Will Obsidian be renewable?
You could buy Redstone and pour lava onto it, but is that a bug that might be fixed some time? 78.150.199.100 13:37, 27 May 2012 (UTC)


 * Obsidian is renewable. Since iron is renewable, so is a bucket, when 4 flowing lava meet they make still lava, and since water is renewable, pour water on the still lava to make obsidian. 71.46.222.254 14:15, 1 June 2012 (UTC)


 * The thing with the lava doesn't work anymore since a few versions. --☺ Sven R.I.P. Donna Summer 15:35, 1 June 2012 (UTC)


 * You could abuse nether portals for unlimited obsidian, also. OverPortal A to NetherPortal A.  NetherPortal A is autoconstructed.  NetherPortal B to OverPortal B.  OverPortal B is autoconstructed.  Harvest OverPortal B.  Return to nether through OverPortal A.  Return to Overworld through NetherPortal B.  OverPortal B is autoconstructed.  Harvest OverPortal B.  Repeat.  Since diamond picks are no longer limited, this method of harvesting obsidian is not limited.  --99.44.177.77 19:25, 4 June 2012 (UTC)

Will Lapis Lazuli be renewable?
Lapis Lazuli does not appear anywhere so I guess that is still non-renewable. 78.150.199.100 13:49, 27 May 2012 (UTC)

Price Information On all Items
Putting forward the idea to have item/block summary box (usually in the top right of a items page)have a new row added for example |cost = 1:8-10 (1 emerald for 8 to 10 of said item) So that when your on the items page you can see its costs 176.251.34.210 11:17, 28 May 2012 (UTC)

Villager Trading - Multipart Trades
The new trading system allows for multipart trades; 2 items go in (usually one of them Emerald), one item comes out. So far, I'm only seeing the PRIEST use this for applying enchantments. I'm presently building up a list of the options. So far, all enchantments that I've seen are level II of various things on tools and armor. --Zeta0134 14:35, 31 May 2012 (UTC)

Edit: There's the mentioned gravel trade with a blacksmith: 10 gravel and 1 Emerald for 2-3 Flint. No clue why anyone would actually do this of course. I'm also noticing a pattern with the enchantments; it seems to be a random set of enchantments, but the cost is always 2-4 emeralds. My guess is the level is always constant, maybe level 20? (That would make logical sense, requiring the player to get level 30 enchantments on their own.) More testing is needed, but I have to go to work now. Here's my list so far; if someone wants to continue and put this in the wiki, have at. This is bound to be very incomplete.

Enchants (priest) Iron Axe -> 4 -> Unbreaking II - Efficiency II Iron Axe -> 3 -> Unbreaking III Iron Pickaxe -> 2 -> Fortune I

Iron Chestplate -> 2-4 -> Fire Protection II Iron Chestplate -> 4 -> Projectile Protection III

Diamond Axe -> 4 -> Unbreaking II Diamond Pickaxe -> 2 -> Efficiency III

Diamond Chestplate -> 3 -> Protection II

Sells (priest) Eye of Emerald (1) -> 7 - 10

Buys (Librarian) Written Book -> 1

Sells (Librarian) Watch -> 10

Sells (Blacksmith) Arrow (5) -> 1

Converts (Blacksmith) Gravel (10) -> 1 -> Flint (2-3)

Buys (Farmer) Fish (9) -> 1 --Zeta0134 14:51, 31 May 2012 (UTC)


 * Are you sure that's what you got on a diamond axe? I made the same trade, and I got an axe with Unbreaking III and Efficiency III... Which would suggest that 1) These trades are just as random as actual enchanting, or 2) It's dependent on your level: I was in Creative mode, which automatically gives you maximum enchantability. ~GorgeousTaylor


 * The enchantments are random using level 5-19. (What that actually means is sort of up in the air, since enchantments were also scaled back to max level 30 with the update.) WolfieMario is doing disassembly of the code and filling in exact values, so the article should be completely accurate by the end of the day. To answer your question, yes the items will get different enchantments randomly, but it's not based on the player's level. --Zeta0134 17:24, 31 May 2012 (UTC)

Code analysis of 12w22a villager trading
Sorry, I didn't feel like making 275 trades again, so I instead decided to peek at the code :p For 12w22a, the villager class is. appears to be the method behind generating offers, and conveniently lists all offers. is the item class and  is the block class. Ctrl+Clicking in Eclipse makes it easy to find out what each offer is.

At the end of the method, it's revealed that the method is capable of adding multiple offers at once, but all calls to the method only request one new offer to generate. In addition, if no potential offers are generated, a default offer of buying gold ingots is generated - this is why the unused villager will only request gold ingots.

The method  called in the offer-generating method makes a new buy offer, while calls to   make new sell offers.

All buy offers are in exchange for 1 emerald. The quantity of item bought is derived from the contents of the  hashmap defined in the static section at the bottom. If no definition exists for an item in this hashmap, the quantity defaults to 1. If the first Integer in the pair of Integers of  (as defined in the static section) is greater than or equal to the second, then that is the amount which will be used for the stack quantity bought. Otherwise, the stack amount will range anywhere between the two integers (note that it can be as low as the minimum value, but only as high as the maximum value minus one, due to how  means coal is always bought in stacks of 16-23.

For sale offers, the stack value is determined in an identical manner, using the  hashmap (also defined in the static block at the bottom). However, the hashmap has negative values defined for some items. If this happens, the quantity is used (negated of course, so it is positive) for the item stack sold, and the cost in emeralds is 1. Otherwise, the quantity is the cost in emeralds and the item stack sold is 1. Therefore, it is impossible (with the current code) for a generated offer to have multiple emeralds in exchange for multiple items. Note that for negative values, the first Integer is actually the negation of the upper bound, and the second is the negation of one less than the lower bound.

For help understanding the  hashmap entries:   means flint and steel, in exchange for exactly 3 emeralds (remember that the second number is the upper bound plus one, so the actual range is [3,4), or [3,3], aka simply 3).   is bread, sold in stacks of 3-4 (consistent with observed values).

The probability of a given offer being a potential offer is equal to the float value passed to  or. However, the actual probability of getting this offer is less: first all potential offers are selected, and one offer will be selected at random out of these. Nevertheless, this is helpful at gauging the relative rarity of any given offer, so I will add information such as "rare" or "common" to the article itself.

Note that there are also special offers, not generated with the  or   methods.

The first unique offer is a farmer offer: at 50% chance, the following code will add a new potential offer:. This is 10 gravel and an emerald, in exchange for flint in quantities of 2-3.

The other special offers are by priests. Specifically, a 10% chance of each enchantment offer being a potential offer. Items which can be enchanted are iron and diamond swords, iron and diamond chestplates, iron and diamond hatchets, and iron and diamond pickaxes. The line  is repeated for each of these items (assuming that particular item will be a potential offer, which I already mentioned is a 10% chance). The request is the item in question and 2-4 emeralds, and the sold item is, to my understanding, the same item enchanted with a level of 5-19.

Here is the entire code of  (the villager class, containing all information on trade offers):

I'll be updating the article shortly. --WolfieMario 16:56, 31 May 2012 (UTC)


 * Neat! I updated the Enchantment area for Priests based on the code. I'm not sure if you should be posting the code here, but as the Bukkit team (employed by Mojang) regularly posts disassembled code in their public github, I'm sure it's not a problem.


 * I suppose the trickiest part will be matching up the items, as those garbage class names aren't helping us any. --Zeta0134 17:18, 31 May 2012 (UTC)


 * If I'm reading the code correctly, any time a villager's list is empty (which is rare, but possible) the game adds the offer for Gold Ingots to the list as a fallback. This explains why the green villager only ever offers that trade, and also why it rarely shows up for all the other professions. This also means that the Farmer can very rarely offer it; I'll update the list. --Zeta0134 17:36, 31 May 2012 (UTC)


 * Yes, you're reading it right. I find it amusing that the potential probability of a librarian offering to buy a written book is 1.3, or 130%. That means it can never default to gold ingot for a librarian, until Jeb fixes this. Kind of annoying since Written Book slightly throws off all other actual probabilities by always being in the draw for a new offer, but I suppose written book is a rather good deal, eh? :p --WolfieMario 20:26, 31 May 2012 (UTC)

Put it on pastebin for the sake of the page loading faster. Unrelated: how did you decompile/deobfuscate it? C ali nou - talk × contribs » 20:28, 31 May 2012 (UTC)
 * Oh, cool, I wasn't aware of that site. I didn't want to paste it inline, but I didn't know of any good alternatives.


 * Anyways, I used JAD (JAva Decompiler) to decompile all classes after extracting them from minecraft.jar (it lets you use the wildcard modifier, e.g. "*.class", to decompile all classes in a directory). I didn't deobfuscate it, as you can tell by the horrendously messy and difficult-to-read code. I did my best to understand it, however. See this post for how I figure out which classes to look in.


 * In this case, I noticed the text "Offers" in the NBT structure of a villager that has offers (using NBTedit on a schematic), and figured that must exist as a raw string somewhere in the code. Doing an Eclipse file search for that confirmed my notion - the only class with that string is EntityVillager, aka the class I had pasted here. --WolfieMario 20:44, 31 May 2012 (UTC)

Fun fact: there are 4 unused buy offers, found in the hashmap that indicates costs:

- 3 enderpearls for an emerald

- 34-47 seeds for an emerald (I would love this offer considering how many I have after using stacks of bonemeal in the dark to get loads of flowers :p)

- 30-37 melon seeds for an emerald

- 30-37 pumpkin seeds for an emerald

There are, of course, also the no-longer-used priest offers to buy eyes of ender and rotten flesh.

Finally, the following curiosity:

- the offer for arrows, but the greater value is the first slot. This means that the code will not bother generating a random number, and instead only offer 5 arrows. If the numbers are flipped, it's 6-19 arrows, and if the failsafe didn't exist it would have been 5-18 arrows (which isn't too far off). Hopefully Jeb fixes this one; it would be nice to buy arrows if you don't have a skeleton grinder. --WolfieMario 20:56, 31 May 2012 (UTC)

For those curious, the only change to trades brought by 12w23b is a correction to the librarian: He no longer has a 130% chance of potentially offering to buy written books; it's now the expected 30%. The arrow quirk, where the minimum value is greater than the maximum, is not fixed. --WolfieMario 23:56, 7 June 2012 (UTC)

Enchantments - Multiple of one Item?
Can someone verify whether a Priest will offer to enchant the same item multiple times? Does it check to see if the enchantments are the same, or would a new offer to enchant, say, an Iron Pickaxe with Unbreaking III replace the previous offer of an Iron Pickaxe with Efficiency II?

Unlocking more offers
What is the most efficient way to unlock more trading offers in a survival game? Should I build a large nursing facility and pick vilagers out using a wagon until I get the right offer? --217.128.124.56 14:52, 4 June 2012 (UTC)
 * I'm not sure what you mean by a wagon, but it seems tedious to make a new villager for every offer you want. You'd have to search for that specific villager every time you want to make that trade, and that sound like more trouble to me than it's worth. Also, villagers breed until their population is 0.35x the number of "houses" (read: doors with ceilings). On a survival server I play on, I actually made a building with the 5 types of villagers each in a slot. Come 1.3, I'll just trade with them until all their offers are available. There's a 12-stack sugarcane farm nearby, which can be readily turned to paper and sold to librarians for roughly a half stack of emeralds each harvest. As long as you are trading the rightmost offer, new offers should get generated until all the common offers have been generated. If you're lucky, by the time only rare offers remain, the rightmost will be an offer to sell items (as emeralds are easy to farm from several materials). Fortunately, the worst deal, 5 diamonds for an emerald, belongs to the blacksmith, who's very likely to generate a new offer every time - thus you'd likely only need to spend 5 diamonds once. Remember, villagers can only generate a new offer after you've closed the trading interface. --WolfieMario 15:30, 4 June 2012 (UTC)

Giant octopods?!?!?!?
In part of the trivia section, it says: "This includes Written Books, with the requirement of obtaining Ink Sacs from Giant Octopods. It requires writing in a Book and Quill."

I'm thinking we should change that to say squids, as there is no evidence of any giant octopods in minecraft Jatsburgern 06:17, 5 June 2012 (UTC)


 * Well, I wrote this part, and remembered Marine Biology, the Prof. was Really sure that they were better-classified as "octopod(s)," so I actually looked it up. It seemed to support the Greek original of "octopus(es)," with "-pi" being a well-known False way to use it, as it was Not a Latin, original.  Meanwhile, "octopodes," and "octopods" were both other alternatives, used in the Latin naming scheme (which probably began what, like 150 years ago, more-or-less?).  But: my key point is that they Don't look anything-like "giant 'Squid'," since squid have 2 Really Long tentacle-like things, in addition to their regular, tentacles, whereas these MC giant Octopuses /-pods definitely Don't.  Oh, and to inform people reading about Trading that Written Books (I haven't seen this offer, yet, but I'm still letting Villagers breed in now-2 Villages near each other) are their best way to get Emeralds.  Yilante, June 5th, 2012.

I don't care if they are technicly octopods, if notch calls them flying purple space monkeys then thats what they are.--Diamond warrior 16:09, 8 June 2012 (UTC)

I happen to know the explanation.

The squids in Minecraft is indeed octopods. The reason for the mistake is that Minecraft was made by a Swede, and in Swedish, octopods and squids share the same name, bläckfisk. In fact, I thought, until recently, that octopi and squids were the same creature.

Difficulty in gauging the actual probability of an offer
To keep language simple/brief, I'm using the euphemism "hat" for the modified ArrayList which stores potential offers. As such, my simplification of the way an offer is generated is the following: Each offer in the code has a "probability value", which is the chance that offer is put in the hat. One offer is selected at random from this hat as the newly generated offer. For all intents and purposes, each offer in the hat has an equal chance of being drawn from the hat.

If somebody better versed in probability theory than me can help, that would be nice. Currently, I've realized that, due to how offers are generated, the only way I know to accurately calculate the actual chance of a given offer is rather unfeasible. Namely, it involves checking the probabilities of all possible combinations of other offers occurring, combined with the chance that a given item is the one to be picked.

For example, take the calculation involved for the percent chance a farmer will offer to buy wheat, assuming this farmer does not already offer to buy wheat:


 * 0.9 is the probability value for whether a wheat-buying offer is 'thrown in the hat.' We'll only check all cases when this has happened.


 * The probability values of all other offers a farmer provides (except the default gold offer, which lacks a probability value) are also needed.


 * The exact, actual probability of a farmer offering to buy wheat is 0.9 * n, where n represents the sum of the following combinations:


 * Each element to be summed into n is the probability that, assuming wheat is in the hat, wheat is drawn from the hat.


 * A given element of n may be 'the chance that wheat is drawn from the hat, assuming it is the only offer in the hat.' In this case, there is a 1.0 probability of the wheat offer being drawn, which we multiply by the probability of all other offers failing (0.5*0.5*0.6*0.1*0.7*0.7*0.7*0.7*0.7*0.7*0.5*0.5, or 0.00044118375).


 * Another element may be 'the chance that wheat is drawn from the hat, assuming the cooked fish offer is also in the hat.' In this case, there is an 0.5 probability of the wheat offer being drawn, and we multiply this by the probability of all other offers except fish failing (0.5*0.5*0.4*0.1*0.7*0.7*0.7*0.7*0.7*0.7*0.5*0.5, or 0.0002941225).

Why do I say this is unfeasible? All Possible combinations need to be accounted for in calculating n. Even ones such as 'the chance that wheat is drawn from the hat, assuming the cooked chicken, raw chicken, and shears offers are also in the hat' (which would be the 0.25 probability of wheat being drawn, multiplied by 0.5*0.5*0.6*0.1*0.7*0.7*0.7*0.3*0.7*0.3*0.5*0.5, or 0.00008103375). How many individual elements of n are there? For the farmer, 4096 combinations exist in which one offer is always used and the rest may or may not be used. That's 4096 calculations which you must sum together to obtain the value of n, which you then multiply by 0.9 just to figure out the chance a farmer will offer wheat (or, thankfully, any other offer with a probability value of 0.9).

That's 4096 calculations I'm sure nobody is going to make. For a given offer of the blacksmith, you would need to make 33,554,432 such calculations. Even with the librarian, the villager with the fewest offers, there are 64 distinct combinations to worry about.

If anybody with expertise in probability theory knows of a better way to get an accurate calculation of the probability of any given offer, please do help.

Either that, or if you're willing to write a program that can somehow produce an automated solution to this problem (as I imagine is more than possible, but I myself don't know enough about combinatorics to attempt it. Wolfram Mathematica may be a good shot, as it seems to already have the capability to list combinations from a set of elements).

I myself may take an empirical approach, and simply have a program simulate billions of offers generated, based on the actual game code, which could then provide decently accurate approximations of the actual probabilities. However, I won't get around to it right now; I may do it someday if nobody else can pose a better solution. --WolfieMario 02:32, 8 June 2012 (UTC)


 * Wow, that's even worse than the random number of weighted random items in stronghold etc. chests. Making a program to do all the work shouldn't be too hard, though. One approach would be to make a list of all possible 'hats' and their probabilities, stored in an array. Use the array index as a bitfield, with a 1 or 0 indicating if an offer is in the hat or not. For example, for the librarian, index 22 (binary 0010110) could indicate that written book, glass, and compass are in that hat. Once that's done, for each offer, iterate across the array checking for hats that include it (e.g.,  for the written book). Divide the chance of the hat by the number of items in it, and add that to a running total. When you reach the end of the list, record the total chance of that offer, and repeat for the next one. Does that make sense? I'm inclined to implement it in C for speed (blacksmith needs 26 iterations across a 67-million element array), but Java would also work. -- Orthotope 03:33, 8 June 2012 (UTC)


 * Blacksmith is being annoying, keeps giving me a segfault at about 62 million hats, but the rest worked nicely. I'll see if I can make a Java version that complains less tomorrow. Here's the data on the others; gold ingot chance is calculated as 1 - sum(other item chances) and came out the same as what's on the page now, so I'm fairly confident this is correct.


 * -- Orthotope 09:11, 8 June 2012 (UTC)


 * Thank you very much for this. Your method seems to make sense, and the results do as well (offers with equal probability values have the same chance of occurring, and the gold ingot check worked out as well). I really like how you used the array index to effectively store the hats. For extra confidence, maybe you could iterate over an imaginary villager I manually solved the probabilities of (when I was trying to discern whether my methodology was even a valid solution)?


 * {| class="wikitable"


 * Common || 0.8
 * Uncommon A || 0.2
 * Uncommon B || 0.2
 * Uncommon C || 0.2
 * Gold Ingot (default) || 10.24%
 * }
 * Uncommon C || 0.2
 * Gold Ingot (default) || 10.24%
 * }
 * Gold Ingot (default) || 10.24%
 * }


 * The proper solution is the following:


 * {| class="wikitable"


 * Common || 59.04%
 * Uncommon A || 10.24%
 * Uncommon B || 10.24%
 * Uncommon C || 10.24%
 * Gold Ingot (default) || 10.24%
 * }
 * Uncommon C || 10.24%
 * Gold Ingot (default) || 10.24%
 * }
 * Gold Ingot (default) || 10.24%
 * }


 * As you can tell, I kept my numbers simple so the calculations would be simple (common is .8*(1*(.8*.8*.8)+0.25*(.2*.2*.2)+.5*(3*(.2*.8*.8))+(1/3)*(3*(.2*.2*.8))), and uncommon are all .2*(1*(.2*.8*.8)+.25*(.8*.2*.2)+.5*(.8*.8*.8)+.5*(2*(.2*.2*.8))+(1/3)*(.2*.2*.2)+(1/3)*(2*(.8*.2*.8))) ). It surprised me that the uncommon items share the same chance with the default offer, but I wouldn't put too much thought into it.


 * Also, when you are iterating the blacksmith's results, remember there are two gold ingot offers (one being the default), and you can probably save a lot of computation time by only iterating once per each unique probability value (e.g. 0.7, 0.5, 0.3, 0.2, and 0.1). Thus far your program has calculated the same chance for all items of equal probability values (and, mathematically, this is how it should be), so it's safe to say 5 iterations of that 67-million-long array will get us exactly the same amount of information that, say, 26 would :p


 * Lastly, do you plan to add this data to the article, or should I? If you do, please add it in a new column (feel free to reword the probability column to something like "probability value" or anything else you feel is descriptive enough, and name the new column whatever you think makes sense). I think the actual probabilities, which should of course include the % sign so there is no confusion, should be to the right of the current probability values, because these are calculated values just as "price per unit ingredient" is. Either way, the original probability values should be kept, as they are easier to retrieve any time there is an update, and they are independent of each other (not to mention, they are needed so you can do what you just did :p).


 * Thanks very much again for your contribution! --WolfieMario 14:33, 8 June 2012 (UTC)


 * Test case works out the same as your results. There is a lot of duplication, especially with so many of the trades having the same probabilities; the trick is to figure out exactly how many duplicates there are. I'm working on a more efficient algorithm, as the performance loss with Java is rather substantial, and this will have to be recalculated every time the trade lists change. (C gives me about enough time to make a cup of tea before it runs out of memory. Java also runs out of memory (with a 1.5GB heap), but I could have sex with the S.O. (and take my time with it!) while waiting.)


 * I'll let you add it to the article, as you have a sense of how you want it to look. Knowing my aesthetic design skills, you'd probably reformat it anyway if I added it. ;) -- Orthotope 10:02, 9 June 2012 (UTC)


 * And done; blacksmith added to above table. Changed the program to add up hat probabilities as it goes, rather than storing them. Same number of iterations, so it takes a few minutes to process, but total memory used is under 1 MB. I can provide the source code, if anyone's interested. -- Orthotope 11:13, 9 June 2012 (UTC)