User talk:MentalMouse42/Anvil Mechanics

I'm trying to build on Opaquer's excellent work on the anvil, and experimenting with item repair.

This started at Talk:Anvil_mechanics, but I figured I'll start dumping my data and findings here, so as not to clutter up the talk page. First, I'll type in my notes from the last few days. My experiments started in 1.4.3, with exceptions to be noted. I'm also considering a rewrite of the Anvil Mechanics page, which will be developing here.

Summary findings
For bows, durability up to 153 costs 1, each additional 100 durability costs another 1 level, up to 4.
 * I've been working with swords, but I have various reasons to think this will apply to other tools:
 * Swords and tools of a given material generically have the same durabilities.
 * The complexity of the diamond unit-repair costs -- I somehow doubt that would be used solely for swords.
 * Limited experiments with iron picks suggest they follow the identical repair pattern to iron swords.
 * The level cost to repair a tool (including swords) with materials is the item's base cost plus a per-unit cost, - you need more units of material for a heavily-damaged item. Each unit restores up to 25% of the item's maximum durability.  The per-unit cost in levels varies with material:
 * for most materials, it is 1 plus the number of enchantments (regardless of level).
 * For diamonds, besides paying the number of enchantments, each unit costs up to three levels depending how much durability is restored. It looks like one level gets you 199 units, two levels covers up to 299, and three gets a full 390.
 * Repairing with a matching, non-enchanted item is different. You always pay the base cost for the target item, but the additional costs vary by material, and sometimes by the durability of the "sacrifice" item.
 * The resulting durability appears to be floor(a+b+0.12*m), up to the item's maximum durability.. That is, it's the sum of the two item durabilities, plus a bonus of 12% of the maximum durability, rounded down (for swords, the bonus is 3 for gold, 7 for wood, 15 for stone, 30 for iron, 187 for diamonds).
 * The cost of the repair depends on durability as well. For items with low maximum durability (under 178), the cost is simply 1.  If the item has remaining durability of 200-floor(MaxDur * 0.12), it will cost another level, plus another for every 100 durability it has above that value.  This breaks down as follows:
 * For wood, gold, and stone, the repair cost is just 1.  This also applies to flint & steel, fishing rods, and carrot-on-a-sticks, also to leather and gold armor.
 * For iron tools, it's 1 if the sacrifice has durability under 170, or 2 if its durability is 170 or above. For shears, it's similarly 1 up to durability 171, 2 at durability 172 and up.
 * For diamond tools, the second level is paid at durability 13, and continues with each 100 afterwards up to 17 at 1513.
 * For iron and diamond armor, each piece has its own offset, but the pattern continues.
 * Naturally, if the sacrifice is enchanted, you will also pay for any enchantments transferred to the target, as noted under combining enchantments. You don't pay for enchantments that are weaker versions of what the target already has.

Golden Swords

 * When repairing an enchanted sword with a plain one, the damage of the plain one does not affect the cost. Also, doing this will be cheaper in levels than even the one-ingot cost for repairing with materials.  The cost appears to be the base cost plus 1.
 * ETA: When combining two enchanted swords, that "plus 1" penalty appears and disappears, I haven't quite nailed down what the rules are.
 * ETA2: When repairing a sword with a "subset" sword (that is, the target sword will not change its enchantments), it costs the same as with a plain sword.
 * [...] If you've read my forum/reddit post, you'll know I tried some theories as to how to calculate the cost of combining two enchanted swords without common links, and some got very close to working. I had that same problem. I found a way to make it work, tested in on 5 swords, and it worked perfectly. Then I tried on one more to be 100% sure, and I was missing 1 level. Couldn't figure out where. Kept trying, and I was always correct or 1 level short. Still haven't figured out why this happens or where that level comes from :(. Opaquer 00:37, 6 November 2012 (UTC)

Diamond swords
Early experiments with diamonds are bizarre. With plain diamond swords, I'm getting 2+1/diamond for repair... but combining a damaged one with a whole one costs 17 levels, and combining two damaged swords, only 13! And it gets worse: A damaged Bane 1 sword costs 20 to repair with a whole sword, but only 16 with a damaged one. For a Bane II sword, that's 22 and 18. It also costs 18 to repair the Bane 2 sword with the Bane 1 one (both damaged). Repairing them with diamonds costs 5+2/unit and 7+2/unit respectively. (In all cases I'm assuming the unit costs are in fact constant; it was hard enough wearing my "mother sword" down below 75%.)

[Deleting incorrect extrapolations about the unit costs]

The real shocker is the sword-on-sword costs -- Even if there's a cost dependent on damage, I would not expect using a damaged sword to be cheaper. The cost for combining two damaged plain swords is 13 (12 more than expected), and using a whole sword on a damaged one mysteriously adds another 4.

Given this, the Bane repair costs are as expected:
 * Combining the Bane swords with damaged plain ones, adds the cost of the Bane swords.
 * Combining the Bane 1 sword onto the Bane 2 one costs the same as repairing the Bane 2 one with a plain sword.
 * Repairing the Bane swords with diamonds adds the cost of the Bane swords, and 1/unit for a single enchantment.

Next I think I'll try enchanting some intact swords and further damaging another "blank" sword. These experimental entries are getting long... should I perhaps be moving these experiments to my own userspace? --Mental Mouse 11:23, 6 November 2012 (UTC)
 * Hmm. Sounds like it's going quite well. What's your method of damaging the swords quickly? I might be able to join you soon, but won't have a long time to damage the swords down :(. Also, if you want to send me the data so I can have a look over it too, I would be happy to. If so, is there some way to send stuff over the wiki, or you want to talk on the forums/reddit or something? Let me know though, I love looking at data (you should see my original spreadsheet for the anvil data stuff :P). Opaquer 11:27, 6 November 2012 (UTC)


 * I'm using /gamemode to go to survival, then swinging at dirt blocks. I just started using F3+H to get durability values.  Most of my data is scrawled onto graph paper, but I can probably type it in over at my own userspace.  Newest findings:  unit repair for diamond swords costs up to 3 levels per unit, depending on the durability gained with that unit.  The third unit goes from 1 at durability 595 (up to 777 or more), to 2 around 573, and 3 around 479.  None of these are exact, I was testing at intervals while beating down the sword. --Mental Mouse 13:36, 6 November 2012 (UTC)
 * Hmm... Fair enough. So you're saying that it could be that less than 1/3 durability, it costs 3 diamonds, between 1/3 and 2/3, it costs 2 diamonds, and above that, it costs 1 diamond? --Opaquer
 * Or rather, 1/12 of the entire durability (four units, each costing up to 3 levels). I'm about to test a transition point on that.  Another note on methods:  In creative mode, you can use frames and "pick block" to duplicate a damaged weapon.  Doesn't seem to copy enchantments, though.  :-( --Mental Mouse 13:45, 6 November 2012 (UTC)
 * The pick block in frames is amazing. It's how I made so many items to enchant for the first anvil tests :P. So, at 1/12th the durability, you're saying it'll cost 12 levels to fully repair? Not quite sure if I'm getting it right :(. Kinda tired :(. Opaquer 13:48, 6 November 2012 (UTC)
 * Right, if it's worn down to a nubbin. Latest findings:  For the first ingot, the cost changes from 1 level to 2, between durability 1371 and 1361.  That's a little awkward -- it could be half-way between the twelfths (that is, rounding to the nearest twelfth). --Mental Mouse 14:08, 6 November 2012 (UTC)
 * Hmm. That's a really weird number :S. That's around 10.5/12. Maybe it's split into 24 segments, and that would relate to the 21st segment out of the 24, and every second odd one, the cost changes? 21/24 makes me happier than 10.5/12 :P. Opaquer 14:14, 6 November 2012 (UTC)
 * Yeah, that's equivalent to the rounding. But the next transition happened between 1280 and 1251, which has distinctly high for that pattern (should be 1235).  :-(  --Mental Mouse 14:34, 6 November 2012 (UTC)
 * So it is D:. Those are some odd numbers then D:? Might certainly have to do more testing, maybe with other materials too. I doubt golden swords will be split up into 24 sections too :P. Opaquer 15:04, 6 November 2012 (UTC)

Costs for Unit Repair
Question marks indicate predicted values.

Next:
 * Pin down the transition points for unit repair (done)
 * figure out how costs for combining plain swords depend on the durability of each. Theory:  the sacrifice sword is considered as one or more ingots according to its remaining durability.  See below for initial data, feel free to add more or note your conclusions.

Costs for merging
Unenchanted diamond swords of various durability.

Getting a bit bored with this, so it may be a while before I continue, but I wanted to get this data up here. Looks like the cost is dominated by the second sword if that is less worn. --Mental Mouse 01:03, 7 November 2012 (UTC)


 * Just by looking at these numbers, for diamond swords at least, it looks like the formula for it can be given by: floor(a+b+0.12*m). Floor is rounding down a number (so, floor(12.95)=12), a is the durability of the first item, b is the durability of the second item, and m is the max durability for that item (1562 in the case of diamond swords). It should be noted that if this number is greater than the max number of uses for an item, the amount of uses on the tool is the max item (so, for the example with 573 and 1123: floor(573+1123+0.12*1562)=floor(1696+187.44)=floor(1883.44)=1883, which is more than 1562, so the uses for that sword is just 1562. Not sure if that 12% thing applies for non diamond stuff though, or if it's only for diamond swords. Opaquer 06:27, 7 November 2012 (UTC)
 * Thanks! I knew there had to be a rule, but after two days enchanting swords I was short on durability myself.   --Mental Mouse 21:54, 8 November 2012 (UTC)  (P.S:  Any idea about the level costs?)
 * Hmm. Maybe. It seems that the level cost is given by the item in slot B only. 777+91=2 levels only, as does 573+91, but 573+871=10 levels, and 573+1123=13 levels. So, it's only based on slot B's durability I would say. I've found a formula, but it's not 100% right. It's *almost* there, but just not. It's floor(B/100)+2, with B being the durability of the item in slot B. The only problem with it is for the ones that have 101 durability. That formula says it should cost 3 levels, not 2. But the other values work. I'd need more data though - there's only 6 unique points, so maybe it's B/150 instead of 100 or something? Opaquer 23:58, 8 November 2012 (UTC)
 * Hey, I think I can test that with the stuff I have on hand.... --Mental Mouse 00:40, 9 November 2012 (UTC)
 * Yay! Tell me the numbers too :D! I think we're onto something big here! If this is right, most of the mechanics for anvils are done :D! Opaquer 00:56, 9 November 2012 (UTC)
 * Unfortunately, they don't really fit your formula, though it does seem to be all on the second sword. Data below...  I don't have the patience tonight to nail down all the transition points and missing values, but feel free to add any you find. --Mental Mouse 02:35, 9 November 2012 (UTC)

Enchanting Created Monday 05 November 2012

Again, question marks indicate predicted values.


 * I didn't think it would be perfect, but I though I'd try it! Anyway, this one is a bit more accurate. The only point it doesn't work on is 1123 costing 13 levels :(. This formula thinks it should cost 12 :(. But all the other ones it works, so hopefully that means I'm close :). The formula is: round(B/100)+1, where round is rounding to the nearest whole number, and B is the durability of the second item. So close though! Opaquer 03:07, 9 November 2012 (UTC)
 * Well, that tells me where to look for transitions. (Of course, the unit repair table turned out to be ad-hoc partitioning.)   I'll check it out within a day or two.  I realized tonight that I've probably broken 1000 blocks just on this investigation.   ;-)  And I haven't even gotten to iron swords, let alone armour.  But iron swords won't be nearly as much hassle.  Diamond armor, on the other hand....   :-(

--Mental Mouse 03:47, 9 November 2012 (UTC)
 * Yeah, the diamond stuff won't be too fun :(. I'm hoping it's the same formula for everything :P. Would be nice :P. Let me know how it goes. That 1123 point is annoying me though :(. Opaquer 03:48, 9 November 2012 (UTC)
 * While I'm at it I'll double-check the 1123 thing.I hope iron and wood/leather are the same as gold, too.. --Mental Mouse 04:26, 9 November 2012 (UTC)
 * Please do! I would love for it to actually cost 12 levels instead of 13 :P. Opaquer 04:27, 9 November 2012 (UTC)
 * OK... even without completing the table, it looks like a nice pattern is emerging: transitions at n13, that is is L=1+floor((D+87)/100) .  So you were almost there, there's just an offset. ETA:  Yeah, filled in another link in the middle.  I'm not going through all of them for completeness.  --Mental Mouse 15:15, 9 November 2012 (UTC)
 * Ah, cool! So close! And that works for everything too? Nice :D!. Opaquer 05:23, 10 November 2012 (UTC)

More Questions
Brief experiments with iron pickaxes indicate they follow the same rules as swords. I'm not quite up for testing diamond pickaxes right now, but I think it very likely they likewise match diamond swords.

The bigger questions are for armor...

Oh yeah, there's also the renaming business, and someone is now claiming that removes the "retread" penalty. I think I'll investigate that even before armour repair, because it's liable to be quicker. --Mental Mouse 20:28, 9 November 2012 (UTC)

Repair: My initial results don't seem to make much sense, but it may just be too late in the evening: First sword, durability 91: Renamed at a cost of 7, after which the next repair would have cost 5 (3+2, same as an unrenamed sword that had been repaired once before.

A more complex and detailed attempt, alternately repairing a sword one unit at a time, and renaming it: I have a nasty feeling the durability may be a player here too. --Mental Mouse 02:27, 10 November 2012 (UTC)
 * 1) Durability 101, rename presumably would have cost 7, but I repaired it. (cost 3).
 * 2) Durability 491, would cost 9 to rename, 3+2 for repair. I repaired it
 * 3) Durability 881, would cost 11 to rename or 7 (3+4) for repair. I repaired it.
 * 4) Durability 1271, would cost 8 (2+6) to repair or 13 to rename.    So far so good... then I renamed it.
 * 5) Durability 1271, 13 to rename or 2+3 to repair.  (Wait, what?  3?)
 * 6) wiped name (accidentally ;-) ):
 * 7) 2+6 to repair or 13 to rename.  Renamed it.  (umm...)
 * 8) 13 to rename or 2+3 to repair.  Repaired it.  (I'm so confused...)
 * 9) Durability max, 12 to rename, after some damage 1+2 to repair  (And that's it for the night.)

Followup experiments:
 * Repeatedly renaming a random object costs 5 the first time, then stays 9 for all later renames.
 * Doing the same for diamond swords or iron pickaxes, of low or max durability, costs 7 the first time, 12 for all later renames. The repair cost for the low-D ones is then 3 for the iron pick, 5 for the diamond sword (that is, 2 above usual) --Mental Mouse 15:21, 10 November 2012 (UTC)


 * Hmm. Sounds like it was going well at first :S. Oh, how I wish there was an easy way to get an item down a lot of durability very quickly to make testing faster :P

And a slight distraction: shears can't be unit-repaired, but they can be merged, for 1 or 2 levels depending on sacrifice durability. ETA: Cost 2 is at is at durability 172, 72.3% of 238   --Mental Mouse 01:32, 11 November 2012 (UTC)

Oh dear... repairing with an intact bow costs 4 levels. --Mental Mouse 01:38, 11 November 2012 (UTC)

Values in table are durability ranges for the sacrifice.
 * Doesn't look like shears and bows follow the same rule for level cost as the other stuff above D:. According to the thing before, it should have cost 3 levels for 172 durability, and 4 for 238 durability. Maybe there's not the same offset of 87 for shears? -- Opaquer
 * Oh, definitely not, I'm pretty sure the offset of 87 was just for diamonds... and might be just for diamond tools. Compare the iron tools, with yet another offset. --Mental Mouse 12:19, 11 November 2012 (UTC)
 * True, but once we find any transition point, assuming it follows the 1+floor((D+n)/100) rule, we can find out what n is for each tool, which make things a lot easier
 * Oop. Here might be something. For the bow, it looks like the formula for it is 1+floor((D-54)/100), with the condition that if the cost is less than 1, make it equal to 1. Or, at least, it works for all the values it seems... Opaquer


 * For the other tools, it could be that it does cost more than 1, but since the durability is so low, we don't get to see it? Just trying to figure out a general formula here :P. Opaquer 13:35, 11 November 2012 (UTC)


 * OK. This is interesting (to me at least :P). The n value for shears is -72 (1+floor((171-72)/100)=1, which for 172-72, it equals 2). What I find interesting though, is the value. the transition point for shears is 172, while the n point is -72. The transition point for the bows was 154, and the n value was -54. See a pattern :P? In fact, this can be applied to the swords. Instead of using 1+floor((D+87)/100), we could use 2+floor((D-13)/100), since the transition points for diamond swords are at the 13th of every level like you found! For iron (using transition point between 170 and 171 gives the formula to be 1+floor((D-71)/100). Why diamond is 2+ though, I'm not sure. I guess to make it more expensive? Or maybe it's based on how many total uses an item has? I guess without having lots of other items that have a lot more durability, we'll never know! Still though, a general formula could be something like: a+floor((D-n)/100), where a is either 1 or two (depending on the tool type, D is the durability, and n is the last two digits on the transition points. We're going to need a way to figure out an easy formula for them too :P. Let me know what you think :). Opaquer 14:07, 11 November 2012 (UTC)

Now you're editblocking me! I combined the data so far into the table. -MM
 * Haha, sorry :P. My bad :P. Hate it when it happens :P. Opaquer 14:13, 11 November 2012 (UTC)
 * OK, put in the iron armour. (I loaded up on skeleton eggs, then dropped them in survival/peaceful mode.  One shot per egg.)  The numbers look pretty arbitrary to me.  :-(  --Mental Mouse 15:16, 11 November 2012 (UTC)
 * Hmm. The transition points aren't jumping out at me just yet, but the formula is the same as above ^^^^. 1+floor((D-n)/100). I'm going to guess that diamond has the same formula as tools, just different transition points perhaps? Opaquer 15:19, 11 November 2012 (UTC)
 * Well, most of these only have one transition point, so X/100 is besides the point. The breakpoint for the second level actually rises as total durability drops (I reordered the table to show that) but the line isn't quite straight.  It's probably time to bite the bullet on diamond armor (or renaming, but that got weird).   BTW, regarding methods, I also set up some beacons a ways back to give me regeneration, speed, and haste.  Still managed to get killed once anyway, but I have a bed too.  --Mental Mouse 15:49, 11 November 2012 (UTC)
 * A very good point. But, for iron armour, n can be found by calculating floor(-m/10)+97, with m being the max durability of the armour. It seems to work, though why 97, I have no idea :(. Gives n=72, 74 and 77 for chestpiece, legs and boots. At least then for the formula, it's now something that can be calculated through one variable (like 97 for iron). It seems that from this n value, we can calculate the transition point by adding 100 to it. It also explains why iron helmets don't have a transition point - the n value of the helmet is 80, and 100+80 is 180, which is more than the max durability of the iron helmet (166). Diamond would need to be tested, but, guessing a theory here - if you give me a transition point, we should be able to make a formula for it assuming it follows the same rules as before (floor(-m/10)+b), and we'd only need a single transition point for it (in theory of course :P). Opaquer 16:03, 11 November 2012 (UTC)
 * So far it looks like they are by hundreds with offsets, but the offsets are on another curve. Possibly a different divider?  --Mental Mouse 19:40, 11 November 2012 (UTC)

OK, I'm convinced the pattern holds for armor, probably not going to test the last column or two unless I need more worn-down stuff for unit repair. ETA: Guess not. All the armor costs one level per unit. --Mental Mouse 22:40, 11 November 2012 (UTC)
 * Regarding the formula: Perhaps it's always D=(L&times;100) + N.  But N depends inversely on max durability... and for diamond tools, that huge durability makes it negative. --Mental Mouse 22:49, 11 November 2012 (UTC)
 * Oh yeah, I just installed a plotting program and got a graph of offset vs. max durability, and it's a dead straight line. I'm not sure what the parameters are yet, but we'll figure it out.  (I was using the upper end of the ranges for the offset, thus -88, 56, etc.) --Mental Mouse 23:35, 11 November 2012 (UTC)
 * Got it. 100-floor(MaxDur * 0.12) gives the offset,  the shift to level N+1 is at N*100+Offset.  And where have we seen that number before?  --Mental Mouse 00:07, 12 November 2012 (UTC)
 * Very cool! So, let's see if I got this right: A general formula for the level cost for repairing is given by: 1+floor((D-n)/100), D being the durability of the second item, and n being an offset which we can find by using 100-floor(0.12*MaxD), with MaxD being the maximum durability of the item. Also, we can use 1+floor((D-n)/100) for everything including diamond (ignore the 2+ from before) because the n value=100-floor(0.12*1562)=100-floor(187.44)=100-187=-87. This then makes the level cost be 1+floor((D-(-87))/100)=1+floor((D+87)/100). Look familiar :P? The transition point that's between level P and P+1 (I won't call it N like you did to avoid getting n and N mixed up :P) can be found by using P*100+n, and this gives the lowest durability for level cost of P+1. So in diamond, the transition point between level 15 and 16 is 15*100+(-87)=1500-87=1413, which is the lowest durability you can have on a diamond sword to make it cost 16 levels (though if you want the max durability of level P instead of the lowest of P+1, you can simply take 1 away from this). This can of course be rearranged to get P=1+floor((D-n)/100) to give exactly what we had before. At least we're consistent :P! So, we've got a formula for the level cost of an item based on it's durability; now all we need is the amount of durability it will have at the end, which is given by floor(D1+D2+0.12*MaxD), with D1 and D2 being the durabilities of the first and second items, and MaxD again being the maximum durability of the tool. Have I missed anything here, or is this everything? It looks very complete to me :). Opaquer 00:58, 12 November 2012 (UTC)
 * Yup, you've got it. Now I was poking into combining enchantments again... I'm seeing that mystery +1, and wondering if it represents enchantments that didn't get merged.  I'll probably follow that up another night....  --Mental Mouse 02:03, 12 November 2012 (UTC)
 * Sweet! What do you mean by enchantments that didn't get merged? Opaquer 02:21, 12 November 2012 (UTC)
 * Like Smite over Sharpness... Anyway, I'll see what I can figure out. My first chest of diamond swords is overflowing. :-)  And yeah, I'll get back to the renaming thing eventually.  There, it looks like there are at least two parallel penalties going on -- that is, I think the frequent-flyer penalties are *not* actually part of the base cost, but apply separately to repair and renaming, with different rules.  It sucks that the anvil doesn't display the level of a single item anymore....  --Mental Mouse 10:57, 12 November 2012 (UTC)
 * A very good point. In one of my very first tests, I had a theory that worked for the 2 swords that had clashing enchantments, and then stopped working :P. Also, I just figured out something. I put in the formulas we have, and combined them and got something simpler. The durability thing is the same, but for the level cost, instead of having L=1+floor((D-n)/100) and n=100-floor(0.12*MaxD), we can combine these quite easily to get L=floor((D+0.12*MaxD)/100). Easier formula to use in my opinion. And if you really want to find where the transition points are, you can use the formula from above, though with the general formula for level cost, you don't really need it that much. Or you can plot the graph and find out that way :P. But yeah, I think all we have left to do is find out how renaming works, how it calculates the cost of enchantments that don't get merged, what happens when two items have no (or some) common links (like a sharpness 4 and knockback 2 sword), and if these combine (so, combining a damaged sharpness 4 with another damaged knockback 2 sword). I think once we figure that out (which looks like a lot, but won't be), that's it. We win anvils :P. Opaquer 12:43, 12 November 2012 (UTC)
 * Oh, good work combining the formulas! By the way, have you looked at the rewrite I'm working on for the original page?  It's not complete, but I'm planning to delete most of the stuff below my "progress header", once I finish ransack it for stray details and examples.  Given that, do you think it'll be a reasonable replacement? --Mental Mouse 01:07, 13 November 2012 (UTC)
 * I shall have a read of it now :D! Opaquer 01:10, 13 November 2012 (UTC)
 * OK, had a read. I'm assuming the "Old text follow... merge in" is what I wrote on the current anvil page as is, and just needs to be put in place into your one? As to your one though, it looks good. A few things that will need to be changed (some reordering of the headings - I think after you explain the base cost thing, the next thing should be combining enchantments instead of repairing, but that's just me). Also there are a few grammatical errors in, but nothing a big edit can't fix :). Also, a big thing is the formulas. We know what they mean, since we discovered them, but someone who hasn't been following this won't know what a, b and m are in floor(a+b+0.12*m). Also, we use m and MaxD as the maximum durability, so we'll need to fix that too, and go through and make all the variables the same. Other than that, I think a few more pictures would help, especially if we could predict what will happen. I don't know if it's just me, but people seem to understand better when they see what they've just predicted? Apart from that, I don't think I saw anything else that was too major. Looked good though :). Do you think we should change it once we completely figure out the combining of two items section and figure out that +1 penalty, or start fixing it up and merge it in even though it's not fully complete just yet? Opaquer 01:24, 13 November 2012 (UTC)

Anvil mechanics rewrite
The last section had gotten too long... so, new section.

I've just finished the merger. At this point, if you see grammatical errors, feel free to fix them. I will continue on the variable consistency and such. Also, we need more examples. I'm dubious about screenshots of the anvil GUI -- they say less than the text, and take up a lot of screen space. Once we've got the niggling details done, I'd say propose a replacement on the original talk page, and give it a few days. (I think we're the only ones working on it, but it's still polite to ask first.) After that, we can add new findings as we discover them. Just to recap, we're looking for:
 * How renaming works:
 * how the cost is figured
 * how the penalties work for future repairs and future renames.
 * How it affects the prior-repair penalty
 * Is there a mystery cost for enchantments that don't get merged? If not, where is that dratted +1 coming from?

(Knockback and sharpness would certainly combine without incident. If the target is damaged, you just pay for the repair too.) --Mental Mouse 01:49, 13 November 2012 (UTC)


 * Good thinking! So, by merger, you mean the thing you wrote up? I'll go through it now quickly and fix some stuff up :). Opaquer 01:52, 13 November 2012 (UTC)
 * Cool. By the way, I put unit-repair before because it's ultimately simpler -- one item, and doesn't involve the second-slot cost.  Then sacrifice repair of unenchanted items, because adding in the base cost is easy, and finally the complexities of merging enchantments, because that potentially involves both of the previous plus the second-slot values.  --Mental Mouse 02:01, 13 November 2012 (UTC)
 * A very good point. I guess it made more sense to me beforehand because that's how I had it before :P. But now that we've got the whole repairing thing, it's easier to do it your way :P. Going through the page now and fixing up stuff :). Opaquer 02:02, 13 November 2012 (UTC)
 * Hey, can you stop editting your page for a bit? I'm editting it too, and don't want to get edit blocked :P. I'm taking in your edits though so far, so you won't have to do them again :)
 * OK, I was just fixing up the equations and such. Oh yeah... I forgot to check, and I'm almost ready for bed:  Do you pay prior-repair penalties for a sacrifice item?  Either way, it should go in the page. --Mental Mouse 02:15, 13 November 2012 (UTC)
 * Yup, doing that too :P. Won't be too much longer :). And yeah, I'm pretty sure you do. I did a test with 2 sharpness 4 swords that I made using 2 sharpness 3 swords, and it cost me 7 levels for the first sword in the anvil (as expected), then I'm pretty sure it was an extra 4 to cost 11 levels total, which meant that sharpness 4 sword had the extra 2 levels. Opaquer 02:17, 13 November 2012 (UTC)
 * OK, done my editting. Took in your things too, but expanded slightly on the formulas. Let me know what you think :). Opaquer 02:23, 13 November 2012 (UTC)
 * Looks good, though I've still been tweaking it some more. Yep, I get Sharpness 4 &rarr; BV 5, with 2 for the second-slot cost.  If it cost 11, that's two penalties.  --Mental Mouse 03:25, 13 November 2012 (UTC)
 * It is indeed 2 penalties :). But I'll need to double check my notes when I get home to be sure. Also, with your example "And a simple one: A Sharpness 4 sword (BV 5) for the target, and a Looting 2 sword (BV 9) for the sacrifice. You pay 5+8&arr;13 levels, for a sword with Sharpness 4, Looting 2 (BV 4+8+3&arr;15)". Is that right? I didn't think for things with no common links you could just add them up like that? Opaquer 03:26, 13 November 2012 (UTC)

First response to that last: Why not, isn't that what the anvil is for? Second thought: Better check. After churning out way too many diamond swords, I had the sense to switch to iron pickaxes. And... WTF. Unbreaking II (BV 5, SS 4) + Efficiency I (BV 2, SS 2) does work, but it costs 9. Switch them and it costs 12. Damage each of them and it's 11 and 14, so sacrifice repair isn't involved. Either way, the combination does work, but there's 2 or more points unaccounted for. Also, and on a tangent: there seems to be some explicit surcharge for having the more powerful item in the second slot, but I don't see how that works. --Mental Mouse 13:42, 13 November 2012 (UTC)
 * There's always been that extra cost for having the higher level item in the second slot. I think I mentioned it in the anvil page? And the problem we were having was that things without any common links don't just add up simply unfortunately (from my testing). A sword with looting 3 combined with a sharpness 1 doesn't just cost the base values of each of the swords, does it? Opaquer 13:44, 13 November 2012 (UTC)
 * Part of my testing problem is that I haven't gotten a pure Looting sword. That's why I switched to pickaxes, where both Efficiency and Unbreaking are common.   Have you verified any more complex cases where the second item is transferring a new enchantment?  I thought I had, but I may not have time to double check before I leave for work.  Do you have any ideas on how the higher-item penalty works, or at least the conditions?  Is it "any enchantment with a higher level than the target's highest?" --Mental Mouse 13:55, 13 November 2012 (UTC)
 * 1.4.4 has a nice new feature that could be very handy! use /enchant [enchantment id] [level] to enchant anything that can be enchanted. And the best part, it doesn't undergo any penalties! So, we can get pure sharpness 5 swords to test stuff with! The enchantment id is given from the enchanting page (left column of the table is the id). Might make things a bit easier :D. Also, any time there's a lower level item in the left slot, it will cost more and have this weird penalty. Haven't quite figured out much else about it other than "you have to have the lower base cost of the two items in the first slot" :(. Opaquer 13:58, 13 November 2012 (UTC)
 * Base cost, well, that's something. I started experimenting, and realized there's a lot about combination that we really haven't verified.  First try:  Smite 2 KB 1 (BV 4+3=7) + Bane 2 KB 1 (BV 7, SS (4+) 2) costs... 15?  Either way, which is good because those should have identical BV and SS profiles.  And now I need to sign off until evening. --Mental Mouse 14:05, 13 November 2012 (UTC)
 * Yeah, combining things without common links has always been problematic. We've got to sort that out unfortunately :(. I suspect once we figure out how stuff without any common links works, we'll also figure out how stuff with only some common links work :). Also, it's quite late here, so I might be forgetting something, but what's SS? Second Slot? Opaquer 14:07, 13 November 2012 (UTC)
 * Yes, SS is Second Slot. The new /enchant command should make things much easier, but it'll still be tricky... I need to think up suitable test cases.  --Mental Mouse 22:23, 13 November 2012 (UTC)
 * You can try Looting 3 combined with a sharpness 1, 2, 3, 4 and 5, then with a bane and see how the level change. I suspect that there will be a constant value between them. Next you can try it with looting 2 instead, or knockback or something. Just make sure that the higher of the two items is in the left slot unless you want it to be a lot harder :P. Opaquer 22:24, 13 November 2012 (UTC)
 * Yeah, that's similar to what I was thinking. Unfortunately, I just realized that 1.4.4 is the next release, which doesn't come out until tomorrow.  Also, it's a pity that frame-duplication doesn't retain enchantments.  :-(  --Mental Mouse 22:46, 13 November 2012 (UTC)
 * 1.4.4 pre release is out though :). And doesn't it :S? I thought item frames kept everything? Otherwise do what I did to get all my stuff - use the pick block button on the sword in your inventory. Easiest way to get 15-20 double chests full of swords like I have :P. Opaquer 22:48, 13 November 2012 (UTC)
 * I did not know you could pick block from inventory! Picking an enchanted weapon from a frame gets an unenchanted version with the same durability.  And I Do Not Want to manage 15-20 double-chests of anything, I've already got 8! --Mental Mouse 00:29, 14 November 2012 (UTC)
 * It's handy, isn't it :P? I figured it out by accident while playing around with the original anvil stuff :P. I think what I did though was just get unenchanted swords and then enchant them :P. And yeah, 15-20 double chests of swords are not fun, especially when you're trying to find the one you need that has the exact enchantment you need :P

Transferred from rewrite's previous talk page
It looks like with the merge, most of the stuff got taken out and replaced with a few paragraphs. Is everything that was taken out really explained already in a few paragraphs :O? Not saying it's not good, just surprised all that space disappeared basically :P. Opaquer 01:40, 13 November 2012 (UTC)

Hey, give me about 5 more minutes to get through the rest of the page :). I've gone through and editted most of it, but I don't want to be edit blocked and go through it all again :P. Won't be long, promise :). Opaquer 02:09, 13 November 2012 (UTC)

And a belated comment: Yeah, the page got a lot shorter, but combining the redundant sets of tables was a lot of that. --Mental Mouse 14:05, 23 November 2012 (UTC)

Combining items
Last section was getting long, and I was tired of counting how many :'s I needed to be on the right level :P. Anyway, been playing around and found some stuff. Not much, but it's almost there!

Anyway. Mission almost completely successful. I had a bit of free time finally and got on Minecraft. Tested out anvil stuff. And tada. I got a more complete formula for level cost for combing items :). This includes:


 * Items that have some common links
 * Items that have no common links

This does not include:


 * Items that have clashing enchantments (like sharpness and bane)

The formula, which used to be:

LF=Bk+(nk-1)*Ik+E+2*A

Was used to find the level cost for the first item. Then L=LF+Ik was used to combine two items

Can now be made to (more complicated, I know, but that's the cost of it being more complete! Also, one formula!):

L=B1+nk*Ik+x(T-1)+1+2*A

Here, L is the level cost of the process, B1 is the base cost of the first item, nk is the tier of the kth enchantment, Ik is the initial increment value for the kth enchantment (so, looting 3, even though it's at maximum level, will still have an initial increment value of 8, not 4), x is the number of NEW enchantments on the second item, T is the total number of enchantments you end up with, and A is the number of times it's been through the anvil process.

So, that probably didn't make much sense, so to an example or two or three (assume new swords in these examples, so that A=0 always for these examples. That said, I didn't test with any examples where A>0, so it might break apart there):

Example 1: Combining a Sharpness 4, Knockback 2, Fire 1 sword with a looting 2 sword (no common links).

L=B1+nk*Ik+x(T-1)+1+2*A

B1=Base cost of first sword: 18 nk=4 for the sharpness, 2 for the knockback and 1 for the fire Ik=2 for the sharpness, 4 for the knockback and 8 for the fire x=1 new enchantment on the final item T=total number of enchants on the final item=4

So, we have:

L=18+4&times;2+2&times;4+1&times;8+1(4-1)+1

L=18+8+8+8+1(3)+1

L=46

Which is what I got from my tests :)

Example 2: Combining a knockback 1, smite 3 sword with a fire 1, knockback 1 sword (1 common link)

L=B1+nk*Ik+x(T-1)+1+2*A

B1=Base cost of first sword: 11 nk=1 for the fire and 1 for the knockback Ik=8 for the fire and 4 for the knockback x=1 new enchantment on the final item (NOTE: Even though there's 2 enchantments on the second sword, knockback will combine with the knockback on the first sword, leaving you with only fire being a new enchantment) T=total number of enchants on the final item=3

L=11+1&times;8+1&times;4+1(3-1)+1

L=11+8+4+1(2)+1

L=26

Again, with my calculations :)

Now, while these calculations are good and all, it doesn't explain what happens if you have a bane a smite sword clash, or a unified formula. As a scientist, I love unified formulas. At the moment though, if every item is a common link, use the old formula. Otherwise if theres no clashes and no/some common links, use this new formula

Anyway, let me know what you think :). I think we're almost all the way through understanding everything there is to know about anvils! Opaquer 13:32, 14 November 2012 (UTC)


 * I still prefer seeing the components listed textually -- lists of parameter values make my eyes cross. :-~  I'd also suggest abstracting that "2*A" into "P", the prior-use penalty, because we know that renaming will make that more complicated.  And you're saying "increment", then using the SS values  (Increment was the per-level cost).  Also, the next question is how it break on disjoint (no common factor) combos?


 * Lets look at my pickaxes from above:  "Unbreaking II (BV 5, SS 4) + Efficiency I (BV 2, SS 2) does work, but it costs 9. Switch them and it costs 12. "   So, we have:
 * target BC: 5
 * target enchantment Unbreaking II: 2&times;4 &rarr; 8
 * new enchantments: 1&times;(2-1) &rarr; 1
 * constant 1
 * Total cost: 5+8+1+1 &rarr; 15 Hmm.


 * I haven't been offered the upgrade yet, but I think it'll be available in another hour or two. --Mental Mouse 14:06, 14 November 2012 (UTC)


 * What do you mean by seeing the components listen textually? I'm a scientist, so I love lists of parameter values :P. And yeah, 2A=P from now on :P. By "increment", I mean the base SS value (i.e., the value of the SS of each enchantment at level 1). So, looting 1 and 2 have a SS value of 8, while looting 3 has a SS value of 4. But, in the formula, when you're using the Ik, that's the initial SS value (so, 8 in the case of looting). Are you saying my formula didn't work at all for your example, or just when the lower level thing was in the first slot? If it's the latter (which is hopefully the case :P), my formula doesn't take into account the level costs. It assumes that you have the higher of the two items in the left slot :). Also, I think I've got a unified formula for the all common links, some common links and no common links :). Give me a few minutes to test it before I start talking and maybe making a fool of me :). Opaquer 14:13, 14 November 2012 (UTC)
 * OK, so my theory didn't quite work. Was off by one level again :(. Until a unified formula is figured, we might have to stick to the old one if everything is common. Anyway, I'm about to go to bed, but I'll hopefully be able to get back to testing in 12-13 hours :). I don't sleep for that long unfortunately, but I am getting up in 7 hours and going to be busy for another 5-6 hours after that :P. Opaquer 14:38, 14 November 2012 (UTC)


 * Another thing: The SS values previously applied to the sacrifice, but you're using the values for the target. That will certainly break at least some working prior examples!  I was trying to see how the disjoint example broke, and I got 6 above the measured cost, 8 above the old-formula cost.  Though actually, it works  if I use the sacrifice's n&times;SS instead:  2 instead of 8 gets us back down to 9.  Also, "initial" SS value is distracting, since we simplified the tables and made the halving a special case.


 * Textual description:
 * The total Level cost of the process is the sum of these values:
 * The base cost (BC) of the target item.
 * For each enchantment "k" on the target (???), the SS value (k)times the level (ELk).
 * Consider N as the number of new enchantments (on the sacrifice but not the target, not combined, (maybe?) not suppressed), and T as the total number of enchantments you will end up with. Add N&times;(T-1).
 * Add a constant 1, plus any penalties (P) for prior repair.
 * To summarize this as a formula, L=BC + (SS1&times;EL1 + ...) + N&times;(T-1) + 1+P
 * --Mental Mouse 14:45, 14 November 2012 (UTC)
 * Well, it wouldn't break the examples too much, will it? Especially if we can get a unified formula. I had an idea to use the difference between the current level of the enchantment from the second item and the current level of the enchantment from the first item, and if they were equal levels, make it do something. But it didn't quite work :(. Anyways, I'm also rather tired, so maybe if I sleep on it (for another 6 hours :, it'll come to me. Or maybe it'll come to you in your more alert state than I'm currently in :P. Opaquer


 * If it doesn't match prior measurements, then it doesn't cover the domain. We might indeed find one or two cases of "if this is so, add that factor", but notice how when we actually got sacrifice repair sorted out, all the fudge factors dropped out?  : Also, regarding descriptions: Notice how in item 3 above, I'm treating each enchantment as a unit.  The numbers for a list of enchantments are naturally a list of tuples, and you were presenting them like a parallel pair of lists -- which you then took a dot product of.  That's what got my eyes crossed, and will absolutely leave behind most readers.  --Mental Mouse 14:57, 14 November 2012 (UTC)
 * Nah, it's just a different thing. One way we used the level of the first item with all those extra thing, and just add the second slot value. The way I just found, it's just more complete. The old way didn't work at all for combining things that had no common links. Speaking of which, THIS is (hopefully) a more complete formula:

L=B1+(nk-Pk+1)*Ik+y+1+A


 * I know it's long, but it has to be complete :P


 * With everything the same (I've made the 2*A penalty become A now. I didn't want to use P because it makes more sense for the P variable to be called P :P), except for a few things. Pk now refers to the PREVIOUS level of enchantment that was on the first item. If the enchantment wasn't on the item, P=0. Sorry, this probably doesn't make too much sense yet, but just keep reading :). Hopefully it'll make more sense :P. The other difference is y (or whatever you want to call it. I just used y because it came to mind first :P)


 * Here, y depends on how many EXTRA enchantments are being added. If there are no extra enchantments being added to the target item, y=-1. Otherwise, y=x(T-1), with x being the number of extra enchantments and T being the total number of enchantments on the final item. Hopefully this makes sense :P.


 * Also, I totally blame the whole not making sense thing on being tired :P. I had like 3 hours of sleep because I wanted to get up to see the solar eclipse, and was quite tired :P. Feel free to edit the grammar if the time comes :D.


 * And it does work for previous examples. Let's look at the current one on the wiki page: first slot, a sword with sharpness 3, knockback 2 and looting 2 being combined with a sword that has sharpness 3 and looting 2. We use our formula. B1 is the base cost of the first sword: we know this is 21 (I trust you know this sword's base cost by now off by heart :P). For the (nk-Pk+1)*Ik part, we use the values from the second item. n1=3, since we have a sharpness 3, and n1=2 because the level of looting on the second sword is 2. P1 is the level of the first enchantment (sharpness) on the first item, which in this case is 3 as well, while P2 is the level of the second enchantment (looting), which is 2. I1 is the initial SS value for sharpness (we might have to define it as something else instead of the SS value, but for now, we'll call it that), which is 2 for sharpness and 8 for looting. Here we're adding no NEW enchantments onto the sword (since we've already got sharpness and looting on the first item, so y=-1. Subbing everything in, we get (when I have [] next to a number, it's showing where that number came from):

L=21[base cost of first item]+(3[level of sharpness on second sword]-3[level of sharpness on first sword]+1)*2[increment value of sharpness]+(2[level of looting on second sword]-2[level of looting on first sword]+1)*8[increment value of looting]-1[y value]+1+0[new swords, so no anvil penalty]


 * Which, with the text taken out to read it easier:

L=21+(3-3+1)*2+(2-2+1)*8-1+1+0

L=21+2+8

L=31


 * Look familiar :P? And, something I just noticed. The old formula added the SS value for each enchantment the second sword had. But, it also assumed that every enchantment on the second sword was on the first sword (y=-1), AND that they were at the same level (i.e. n1=Pk). When we put that into our new formula and simplify, we get:

L=B1+(1)*Ik-1+1+A

L=B1+Ik+A


 * Again, look familiar :P?


 * So yeah, hopefully that explains that. I know it's a much longer formula, but I much prefer it, probably because it's more unified. I haven't tested if this works if you combine a sharpness 3 and looting 2 sword with a sharpness 4 sword. I only tested it with same value enchantments, but if I'm right (which I could very well not be!), then it should work for any level thing :). Then all we've got to look at is the formula for when the item in the first slot isn't the higher level of the two (and do we still need to refine renaming :S?) :)


 * Let me know what you think though :)
 * Opaquer 08:25, 15 November 2012 (UTC)


 * Oh no D:. I was just re-reading this again and found a mistake. I knew I should have checked the formula since last night when I was tired :(. Don't try figure out math while you're tired! It doesn't quite work :(. Ach, I feel terrible now :(. The problem is that if there's no common link, then the P value is 0, so we end up with (n+1)*I, which when expanded in n*I+I, when we only want n*I. We can't get rid of that +1 though, because if P=n (i.e. the level of the enchantment on the previous item is the same as the level on the second item), we would end up with (n-P)*I [if we get rid of the +1], which gives 0, which is also wrong. What we want is to have something like (n-P+t)*I, where t is some random variable that I can't think up a proper name for. If n=P, t=1, otherwise t=0? Of course, based on the little testing I've done, that's actually t=1 when n=P, and t=0 when P=0... My first reaction is t=P/n, which would work for t=1 and t=0, but we need more testing to see if that's a universal thing. It might then need a bit of rounding :(. Though, if it does, it *might* explain that weird +1 thing if it's still coming up? maybe it was doing floor(12.2+16.7+4.4)=floor(33.3)=33, even though 12+16+4=32? I'm probably not making sense here, so I'll shut up and try figure this out (and double check it tomorrow before I post if I find anything!) Opaquer 15:04, 15 November 2012 (UTC)


 * OK, so, it's not a complete waste to read what I said up there. It's still not 100% right (first attempt works perfectly to combine items only if they have all common links, second attempt (if it makes sense - I'm rather tired here so it might make no sense) works perfectly to combine same level items regardless of common links or not (as long as you use t=1 for n=P and 0 otherwise). However, neither work for different level items such as Looting 1 and Bane 5 sword being combined with a looting 3 sword :(. If you have any ideas, let me know. I'm going to bed now (yay for 2AM!), but should check back tomorrow every so often. I feel like I'm so close with what I had, but it's just out of my reach :(. Opaquer 16:15, 15 November 2012 (UTC)


 * It's gonna be a while before I can evaluate that, as I've got real-world things going on this couple of days. More later when I have time.  --Mental Mouse 21:22, 15 November 2012 (UTC)
 * Yeah, that's OK! I'll keep working on it. I feel so close, but just not there yet! Opaquer 23:33, 15 November 2012 (UTC)


 * So, bit more playing around with it in my head. I've got to head off very soon, but I think we can use:

L=B1+(nk-Pk+tk)*Ik+y+1+A


 * Where we have t being different values depending on n and P. If n=P, but they are not at their maximum level for that enchantment, t=1. If they are both at the maximum level, t=0.5, and otherwise, t=0. Also, if P>n, nothing will happen, since you can't put combine a target sword with sharpness 5 and looting 1 with a sacrifice sword that has sharpness 3. Anyway, until I know more, I think that's the formula we want :). Hopefully :P. Opaquer 23:49, 15 November 2012 (UTC)

Remember that what we've been calling the second-slot value is always twice the per-level cost -- that would seem to be the proper "increment" (more fundamental), and it would get rid of that 0.5. Maybe... I think I've lost track of what exactly some some of those parameters mean, notably "n" which has acquired a subscript. --Mental Mouse 13:46, 16 November 2012 (UTC)
 * Nah, the twice per-level cost won't get rid of that 0.5. That 0.5 is for adding two enchantments that are at max level. Here n is the level of the kth enchantment on the sacrifice item, hence the subscript. you get all the other parameters? Opaquer 13:48, 16 November 2012 (UTC)
 * Using the per-level cost instead of the second-slot cost would let you double t. But there's a worse problem, when n=P=0... you need to special-case t again to be 0 then, or you're theoretically paying second-slot costs for all the enchantments that aren't involved at all!  T is pure fudge ... when you don't need a fudge factor, that's how you'll know you've got it.  I might be able to do some experimentation over the next few days, but we'll see... things are still a bit busy here. --Mental Mouse 21:15, 16 November 2012 (UTC)
 * Good point with the n=P=0 case... Didn't think of that... Also, I forgot what you meant by per level cost; I thought it was the same as the SS value :P. But, if we do use the per level cost, all we're doing is doubling t to make it 0 when n doesn't equal P, 1 when n=P=max level and 2 when n=P otherwise, except n=P=0. And I know t is a fudge factor. Unfortunately I haven't yet been able to think of a way to get rid of it. Except this new per level cost might be more helpful maybe? Also, doing a bit of testing, using the per level cost won't quite work as is. Since we just halved it instead of using the SS value, we need to use 2*per-level cost. So if we double t, we'll still be off. unless we double the values of n and P as well, to end up with (I won't write out the entire equation):

(2*nk-2*Pk+tk)*PLk


 * Where t is the same as above, but doubled, n and P are the same, and PL is the per-level cost. I personally prefer what we had. I think it's easier to add 0, 0.5 or 1 and only have single values of n and P instead of doubling them, but that's just me. Any other ideas? 121.210.196.107 00:17, 17 November 2012 (UTC)


 * With the new /enchant command, I'm thinking of some exhaustive tests, like all combos of Efficiency and Fortune. I'm going to start that now and post the data in a new section.  Somehow, I think that "higher in second slot" penalty is going to be key in understanding transferred enchantments.
 * BTW, the proper syntax for /enchant is "/enchant [username] [enchant-id] [level]". First time I've needed to use my Minecraft username in-game.... --Mental Mouse 02:43, 17 November 2012 (UTC)

Combining, raw data
The target is represented by rows.

The crossbreed tables are utterly smooth, but the same-enchantment tables have interesting behavior around the maximums. Possible next, bigger step: make picks with the 15 combos of Efficiency and Looting, and do a table of those? That's 225 entries not including the single-enchantment swords... Or would something else be more revealing? --Mental Mouse 03:34, 17 November 2012 (UTC) ETA: On consideration, I think Sharpness vs. Smite might be more useful. --Mental Mouse 03:41, 17 November 2012 (UTC)

Of course the most interesting thing about these is, they aren't all zeros. ;-) But notice that a Smite sacrifice on Sharp goes up one level cost per enchantment level. --Mental Mouse 14:17, 17 November 2012 (UTC)
 * Sorry, I'm not quite getting what these tables mean. Is it using the columns as a target item and the rows as the sacrifice item? Also, what are you trying to get out of it? Opaquer 14:30, 17 November 2012 (UTC)
 * Oh, wait, I think I see. So, with the third table for example (fortune vs efficiency). You're looking at the values of combining a fortune X with an efficiency Y pick? That is, no common links? Is that right, or am I missing something/got the table the wrong way around etc? The main ones I'm interested in are the sharpness vs smite though. I haven't done testing yet on what happens when you get rid of an enchantment... Opaquer 14:36, 17 November 2012 (UTC)

The rows are target items, so in the third table the Fortune picks are the targets. The idea is both to verify what we think we know (q.v. Smite vs. Sharpness), and to get complete datasets for certain combinations, from which we can draw patterns. And I just figured out what might be the ultimate table for that: (Protection 0-4 &times; Respiration 0-3) &times; (Blast Protection 0-4 &times; Respiration 0-3). 400 entries B-0, but some of those can be done as sub-tables. --Mental Mouse 14:47, 17 November 2012 (UTC)
 * You wouldn't need to do all the entries. I've found from the tables that patterns appear quite quickly if the right combinations are done :P. The main thing I'm not so sure about is what happens if an enchantment gets wiped out (such as the sharpness and smite case - the sharpness adding 1 is REALLY throwing me off :S. I made a note AGES ago [when I first started testing anvils before the wiki page even existed!] that when an enchantment gets wiped off, take away a level for that enchantment. Of course, that was in my early days and it was hard to get good randomly enchanted swords, and I don't think it really works, but still, might be an idea :P). That's the only thing my formula hasn't quite got yet as far as I can tell in my rather tired state :P. Also, why do you want a complete database of certain combinations? It sounds tedious and large to me? Also, I've made a very simple program in Visual Basic for testing it out. It works so far with all the value I've got, but could still be wrong, since I used the formula above in it, which is incomplete it seems :(. Also, with damage stuff: it looks like you just have to find the level cost and durability like we did before, and add that level cost to the cost of the enchantment using my formula from above. At least we've got damaged sorted then :). Opaquer 14:56, 17 November 2012 (UTC)
 * OK, I've got a theory. I think that for every enchantment that doesn't get added on because of clashes, add one level. From what I've seen, it's literally that easy :D. I can give you my data if you want :). My formula would also work with it: If enchantment X from the target item and enchantment Y from the sacrifice item don't mix, n=P=t=0, or SS=0 (or something so that that term=0), and x (the amount of new enchantments) doesn't get increased at all :). That's from what I've seen though. It also makes sense for the smite to only add one level too :P. Also, you can double check it by combining a silk touch with a fortune 1 tool. Silk touch has a base cost of 9, and since we can't add fortune to it, we add a level and get that the cost is 10, as confirm in game :). Opaquer 15:32, 17 November 2012 (UTC)
 * Annnddd my brain just kicked in. What I was saying was right, but what I was saying about my formula wasn't quite there. Give me a bit to figure this out. Opaquer 15:37, 17 November 2012 (UTC)
 * OK, take 2. After a bit of playing around, I was pretty much right (of course, all based on what I've seen etc). Main problem was that for some reason I thought that + was the same as -, so in the formula I kept subtracting one level per enchantment that didn't get added :P. Anyway, the formula is exactly the same, but at the end of it, you've got to add a new factor in. I called it Q (because I was never any good at naming variables and for some reason, Q was the first letter into my head :P), but call it what you want. Basically, Q=level of enchantment that wasn't added. For example, if you have a sharpness 5, looting 3 sword, and you want to combine it with a smite 2 sword, Q=2. Other than that, everything I said above is the same: if enchantment X from the target item and enchantment Y from the sacrifice item don't mix, n=P=t=0, or SS=0 (or anything along those lines so that (n-P+t)&times;SS=0 [I ignored subscripts because it's easier, but that would apply for any enchantment that doesn't make it through]), and x (the amount of new enchantments being added onto the target item) doesn't get increased at all :). Let me know what you think :). Opaquer 15:54, 17 November 2012 (UTC)

Well, the thing is, incomplete data can get incomplete patterns, which is why you're struggling with those mysterious 1s. The table I'm describing, with 1- and 4-point enchants, would utterly nail down what's going on with deleted enchants, and new enchants. And this one would only involve constructing less than three dozen items, then it's just filling in slots. I won't be able to work on it at least until evening, though... busy day ahead. --Mental Mouse 15:27, 17 November 2012 (UTC)
 * True for the incomplete data part. But, so far, everything has been very... ordered? Hopefully that's the word I'm looking for. The difference between sharpness 1 and 2 in the first slot is 1 level, which is the same difference between sharpness 4 and 5. The only real curve was the triangular numbers at first, since that's not a linear progression. But, if you have 10 things to test, and the first 3 are linear, the rest should follow that pattern. And, if through testing we find that it's not, we can fix the formula. Also, I think I've now figured out that mysterious 1 issue. I've made another post above ^^^, so have a read through that. Unfortunately, I don't remember what items I was combining to be 1 level off anymore :(. Do you still remember your items that you had trouble with? Opaquer 15:32, 17 November 2012 (UTC)


 * Yes, it's been more ordered than I expected -- did you notice the lack of a "more powerful item" breakpoint in the crosses above? It's just part of the pattern. I'm also thinking as a programmer -- even though this isn't a time-critical operation, I suspect the computations will be as simple as possible while maintaining balance -- in fact if we could see the code I doubt it would refer to the resulting item, only to the inputs.


 * That said, let's see if I've got your new formula straight -- if I haven't, please edit for correctness. [edited, and moved to new section]

--Mental Mouse 00:25, 18 November 2012 (UTC)
 * From what I can see, you've almost got it. I agree with everything except the PLI term. Not quite sure where that's from, but it should be:

L=B1+(2⋅nk-2⋅Pk+tk)&times;Ik+y+Q+1+A


 * Where I is the per-level cost. The way I used to have it (which I personally still use), is by taking out the factor of 2 in the n-P+t term, so that t=0, 0.5 or 1, but you end up with:

L=B1+2&times;(nk-Pk+tk)&times;Ik+y+Q+1+A


 * Which I personally find easier to work with. And it just so happens that 2&times;I is the second slot value :P. Opaquer 00:30, 18 November 2012 (UTC)


 * OH! One thing we missed! At the end of the formula, we need to add an extra variable of D, which is the level cost due to repairs, as we found way above :). Opaquer 01:02, 18 November 2012 (UTC)
 * That was A. Anyway, I edited the summary.  Also, I've just added "0" rows to the prior batch of tables, for completeness and comparison. --Mental Mouse 01:06, 18 November 2012 (UTC)
 * Ah, right. I thought the A was for the times it went through the anvils, and didn't count the durability as well :P. Opaquer 01:07, 18 November 2012 (UTC)
 * No, it seems I misunderstood you. I've been assuming that any repair cost was handled independently and before we reach enchantments.  On the other hand, I just realized there's an ambiguity there... do repair costs in fact apply to the original target, or to the result? --Mental Mouse 01:35, 18 November 2012 (UTC)

ETA: Confirmed, to the original target. Also, fixed more of my text above.

Opaquer's Formula
This section should be edited as the formula gets solid modifications.


 * 1) L=R+(Ek...)+y+A
 * 2) R is any repair cost for the target.  If the target is undamaged, it is simply the base cost of the target.
 * 3) For each enchantment on the sacrifice, Ek will be one of the following, added into the cost.
 * 4) If the enchantment is incompatible with an enchantment on the target (e.g.. Smite over Sharpness), add its level to the cost, but the target is unchanged.
 * 5) If the enchantment is lower level than the target, the target level is unchanged, and you pay nothing for it.  (Ek = 0)
 * 6) If the enchantment is at max level on both target and sacrifice, add its per-level cost to the total.   (Naturally, it will not be changed on the target.)
 * 7) If the enchantment is equal on both items, but not maxed, the target will be raised by one level, costing twice its per-level cost. (t=2)
 * 8) If the enchantment is higher level than the target, the target will be raised to that level, costing twice the per-level cost times the difference in level (t=0).


 * 1) Finally, add miscellaneous items:
 * 2) If any enchantments are being added (not just raised) to the target, let X be the number of enchantments added, and T the total number of enchantments on the result.  Add y=X&times;(T-1)+1.  (If no enchantments are added, y=0)


 * 1) Prior-repair penalties (A).

Moar Tables
Working towards a grand table of (Protection 0-4 × Respiration 0-3) × (Blast Protection 0-4 × Respiration 0-3).

The Respiration self-table, unsurprisingly, exactly matches the Fortune table.

Almost the same as Sharpness, except 4+4.

Mostly notable that BlastR also costs 1 level/level when it fails to transfer.

Just for completeness.... That's all the zero-edge sub-tables, plus some extras.

Hmm, maybe I'm wrong about the code not referencing the result item.
 * What do you mean? Opaquer 01:36, 18 November 2012 (UTC)
 * Or maybe not. Same cost for adding N to N and putting N+1 over N.  But not N+1 over N-1.  Ran into a hitch... the Enchanting page says Protection's ID is 0, but /enchant rejects an ID of 0:  "too small".  Probably wrapping for the night.... --Mental Mouse 01:45, 18 November 2012 (UTC)
 * Yeah, I read somewhere that's a known bug unfortunately :(. Opaquer 01:47, 18 November 2012 (UTC)
 * I managed to work around it by spamming helmets at the E-table. Proceeding with more sub-tables...  Any combos in particular you'd like to see early? --Mental Mouse 16:01, 18 November 2012 (UTC)
 * I just moved the text version of your formula into its own section. I also reworded it to get rid of the fudge factors, by distributing their conditionals over them.  Can you check to see that the new version is equivalent? --Mental Mouse 20:55, 18 November 2012 (UTC)
 * I think I agree. One thing I will say is to explain what the variables are. Also, in the descriptions, when you're talking about the values of t, it might be worth it to say exactly what t is for each case. Also, is the durability account for in A? Opaquer 22:49, 18 November 2012 (UTC)
 * OK, but one reason I wrote out t was because for some of the cases, the rest of its term cancels out. The durability cost comes up front -- I replaced base cost with R, repair cost, to include that. --Mental Mouse 23:23, 18 November 2012 (UTC)
 * What do you mean by the rest of the term cancels out? And yup, R could work, though I personally prefer having B+R, since if R=0, you just use B. But that's just personal preference :). Opaquer 23:24, 18 November 2012 (UTC)
 * Shouldn't that last term be t=0? Also, you need to mention that when x=0, y=-1, and not 0 like the x(T-1) formula would suggest :P. Opaquer 23:29, 18 November 2012 (UTC)
 * Repair cost starts with the base cost anyway, so if we add the base cost again, it's yet another special case to mention. In fact, t is worse than I remembered:  If n-P==0, that term is just a multiplier to the increment (per-level cost), producing a level-independent fee of once or twice the increment.  If n > P, t becomes 0 (as you note), and we pay per level gained.  But if n < P, that whole term becomes void, because we don't get a discount for a negative n-P.  As for y, that's why I distributed its conditional -- rather than a discontinuous y=-1, we skip the +1 along with the new-enchants cost.  --Mental Mouse 23:43, 18 November 2012 (UTC)


 * Ah, I see. There's no +1. You'll be one level off then if you just use y=x(T-1), unless you add no new enchantments (x=0). Otherwise, you need that +1 there too :(. I haven't seen any way to get rid of it yet, or any way to make y a continuous function regardless of x :(. As for t - the k subscripts only apply to enchantments you're adding (or that are getting wiped out like smite over sharpness): If you've got a sharpness 5 sword, and you want to add a sharpness 1 to it, it's not going to work, so we can say that for n<P, ignore that term completely? Opaquer 23:49, 18 November 2012 (UTC)
 * (1) Which is why I moved the +1 into y. (2)  right, but that doesn't work so well in a formula, while my algorithmic version lets us explicitly skip the term up front.  Again, any particular sections or entries of the Big Table that you'd like to see tested first?  What I'd like to do is put in some predictions based on the formula, then go to the game and test those.  So far, I'm thinking that the remaining "plain target" cases are juicy, as are the ones that add BlastR to a pure-Resp item. --Mental Mouse 23:58, 18 November 2012 (UTC)
 * (1) Sorry, that was completely my bad. I was so used to using y=x(T-1), I didn't see the +1 term in it! And (2): Give me another edit. I'll test out some predictions and see what we get. Maybe for the second term, we should have another fudge factor out the front, so that if P>n, that term=0, otherwise it equals 1? Just to cover every single case? Opaquer 00:00, 19 November 2012 (UTC)
 * But why add more fudge, when approaching it algorithmically (which is surely how the game does it) lets you skip all the fudge factors, in favor of up-front decisions? Especially since conflicting enchants toss in yet another option, where not only t, but the increment itself, is unused? --Mental Mouse 00:41, 19 November 2012 (UTC)
 * Because as far as I can tell, there's no continuous function for y, or the n-P+t term that will make it work. I think one way the game does it is by checking the enchantments, and based on each enchantment, adds something else, like what we've got. Still as far as I can see though, it doesn't look like there's any continuous function at all that will be 0 when x=0 regardless of T, and otherwise it will equal x(T-1)+1. Also for the other terms too, like the n-P+t term. If n=P and they're not at max level, we've seen that the increment cost is added, yet if n=P and they're at max level, only half the increment cost is added. In some cases, we might actually need those fudge factors. Sometimes we just can't avoid them. Opaquer 00:46, 19 November 2012 (UTC)

A BIG Table
Question marks or italic entries indicate predictions. Exclamation marks indicate verified predictions. On a row, indicates that row has been verified.

All predictions have been verified (in some cases after correcting mistakes in computation).

Comments on Big Table

 * OK, since I am absolutely terrible at using wiki tables, I'll explain my predictions :P.


 * NOTE*: Dummy variables like n, m, k, j (etc) are various levels of each enchantment. When I say Bn, I mean for all values of blast protection that are allowed, with n being the level (so, B1, B2, B3 and B4). Also, if I have Xn+Ym (where X and Y are enchantments), the X enchantment is the target item and the Y is the sacrifice. Also, I just realised that we haven't quite figured out what happens when the base cost of the first item is less than the base cost of the second item, so some stuff I've got here might be wrong :(. If it is, make sure that it's because the second item has a higher base value. Who knows, if we know how much it *should* cost, we can compare it with how much it does cost and maybe figure out this section of the mechanics :D:

Rm+BkRj=BkRx+8k+2+(R cost) [-MM] -
 * PnRm+Bk=PnRm+k


 * Pn+BkRj=PnRj+8j+2+k [edited-MM] (Opaquer here: I'm quite tired and getting up in 4 hours, so probably going to sleep soon, but for the level cost, shouldn't it just be Pn (base cost of first item)+rest of it, instead of PnRj (which would be the base cost for a protection n, resp j helmet?)

-


 * PnRm+Rk=PnRm+8(k-m) (IF k>m)
 * PnRm+Rk=PnRm+8 (IF k=m)
 * PnRm+Rk=PnRm+4 (IF k=m=max R level)
 * PnRm+Rk=PnRm (IF km)
 * PnRm+BkRj=PnRm+k+8 (IF j=m)
 * PnRm+BkRj=PnRm+k+4 (IF j=m=max R level)
 * (Not too sure about if k<m to be honest. Didn't actually test it... If I had to guess, I'd say it would be PnRm+BkRj=PnRm+k and that it WOULD work as an enchantment, but it won't give you anything new. That's a complete guess though...)

Anyway, I think that's about everything except the plain swords. I need more data for it though, since the second item has a higher base value and we haven't quite figured that out yet... Opaquer 00:26, 19 November 2012 (UTC)


 * I assume that if all sacrifice are less than the target's, it won't work, but if the sacrifice has two enchantments of which only one is less than the target, it will work, even if the other enchantment isn't added because it conflicts. So far, it looks like the lesser enchantment doesn't cost anything, but that's one of the things we're verifying for the complex cases.


 * For the "higher base value" issue, I think "the secret is that there is no secret". The prior experiments and tables make me think that those "oddly" high values will naturally come out of the same pattern.


 * Also, in some of those formulas you've missed subtracting target from sacrifice values, or boosting the level for an equal combine. I'm inclined to go back to the algorithm to figure those, but there's still the issue of which ones to prioritize.  So far, the most interesting cases look like:
 * Adding BlastR (conflicting) when Resp is lower than target,
 * Adding BlastR when both Resp are maxed.
 * Adding two enchantments to a plain helmet.

--Mental Mouse 01:03, 19 November 2012 (UTC)


 * Ah, but the pattern is the same! With the plain swords, it's adding the whole n-P+t term, and then an extra 1 level. I suspect that the formula still works, but x=T=1 for the cases we've tested. Helmets with 2 enchants is a definite must! Also, very good point about the subtracting target from sacrifice values. I'll edit it now. I was too hungry to think about it properly, but lunch has fixed that for me :P. Opaquer 01:15, 19 November 2012 (UTC)


 * For adding BbRr to a plain sword, I get (b+r)&times;8+3. For adding BlastR with low Resp, I get just b.  For adding BlastR with maxed Resp, I get b+4.  All on top of base value, of course.  I'm going to start editing in the predictions.  --Mental Mouse 01:50, 19 November 2012 (UTC)
 * And, it's looking good! All predictions so far are verified.  I'm about to wrap for the night, but over time I'll fill in predictions for the rest of the table, and test.
 * And that's the pattern I was looking for. My formula will still hold, just use the base cost as 0, so you get:

L=0+(2*b[level of B]-0[Previous level of B]+0[t])*4[per level cost]+(2*r[level of R]-0+0)*4+2[2 new enchantments, so x=2]*(2[there's now 2 enchantments on the sword)-1)+1+0[anvil repair stuff]+0[Q value]


 * This gives

L=2b*4+2r*4+2(2-1)+1=(b+r)*8+3


 * Good to know my formula holds at least :D! In theory, this formula should work for any values we have, regardless of which item is in the first or second slot, right? Just for higher level stuff (like sharpness 4 looting 3 on a knockback 1 sword), the reason why it's so much more expensive than having the S4L3 sword first is because you have to add (2*4[sharpness level]*1[sharpness per level cost])+(2*3[looting level]*4[looting per level cost]) instead of just adding (2*1[knockback level]*2[knockback per level cost]). At least that bit makes sense now :D! So, the way I see it, we've got the mechanics of it sorted, don't we? As I see it, we've done combining, repairing, combining with no common links, with some common links, with all common links, stuff being wiped out, adding it at max level, adding higher level stuff adding lower level stuff. Anything else we're missing? Also, I don't know if I've mentioned it, but I'll actually be going away tomorrow to a couple of camps for a couple of weeks, and while I'll have internet access some of the time, not always all the time like now. Another thing: I made a program (not complete yet - right now it's only for swords, but once we know the formula, I can fix it up for armour, tools, bows etc). Basically, you put the enchantments you want onto the swords, along with the durability, and it will calculate the level cost and resulting item. I think it works now. Spent most of yesterday fixing small bugs and whatnot in it, but should be good now. If you want it, I'll upload it somewhere and you can download it and have a play around with it. I just found it easier to do that rather than to plug it into the formula each time :P. Opaquer 05:47, 19 November 2012 (UTC)


 * Right, the slots themselves are asymmetrical, but otherwise there's no explicit check for "is this one more powerful". I'll want to test values from all those empty sectors up there, but it'll likely be easier just to go through the table a sector at a time, which I can do over the next few days.  (Yes, I do think we've got it, but we still need to test.)  Your program sounds interesting, but if it's in Visual Basic, I can't use it, as I'm on Linux.  I've been thinking about dusting off my rusty Tcl/Tk, but at this point, I barely need it anymore for this project.  BTW, I also edited the formula above (and copied it to the rewrite page) to abstract out an Ek to enclose all the possibilities for enchantment costs.

(A thought: In retrospect, this page really should have been "Talk:Mental Mouse/Anvil mechanics", that is the discussion page for the rewrite, but I'm wary of changing it now.) --Mental Mouse 12:15, 19 November 2012 (UTC)


 * Looks good! We'll need to show a few examples for everyone else I'm thinking, since while we understand what we mean, we've been looking at this for weeks! And yes, my program appears to work for swords! But it is in visual basic :(. Is there any way you can run it on your machine, or anything I can do so you can run it? Source code, .exe file, anything? Opaquer 12:24, 19 November 2012 (UTC)
 * Sorry, I don't even have a toolchain to do that right now! I can work with Tcl/Tk etc, I can compile and run Java (and might even venture to edit it), I've got perl, python, and ruby all easily available. --Mental Mouse 13:47, 19 November 2012 (UTC)
 * Aww. Ah well. Maybe someone can figure out how to make it into a webpage or something. All I really know is visual basic unfortunately :(. Though, if you want the link for the exe (if you or anyone else can do anything with it), it's here: rapidshare link with /3674535277/Anvil%20Mechanics.zip at the end. Opaquer 14:10, 19 November 2012 (UTC)
 * Anyway, I'm heading off. I've got a few camps coming up, so won't be on as much, but I'll try get on when I can :). Talk soon hopefully :). Opaquer 14:34, 19 November 2012 (UTC)
 * I've finished verification, and our system as it stands handles the whole table! Yay!  When you get a chance, can you sign off on Talk:Anvil mechanics for the rewrite? --Mental Mouse 21:29, 19 November 2012 (UTC)

On the Naming of Cats Swords
I set out with a Bane 1 sword (BV 3), and drew up a decision tree. "Repairs" are from minimal damage, applied as needed. I haven't even finished the tree, because the pattern is so obvious: --Mental Mouse 00:45, 24 November 2012 (UTC)
 * The initial sword had repair cost 5, renaming cost 10, and the cost for both was 12.
 * For each successive repair, all three costs rise by 2 -- I tested up to 13,18,20.
 * As soon as the item is renamed, those costs change to 7, 15, 17, and stay there regardless of renaming or repairs. Renaming the sword back to "Iron Sword" does not change this.  (The way I accidentally wiped the name on a prior test sword doesn't seem to work anymore.)

And with a plain sword, similar pattern, but the initial costs are 1, 7, 8, and renaming changes the costs to 3, 12, 13.

So far it looks like:
 * Repairing without renaming costs 2 per time.
 * Rename+repair is the sum of the costs, but you only pay BV and penalty once.
 * A renamed object gets a constant 2 for repair penalty -- that is, penalties stop accumulating.
 * First rename of an object with durability costs BV+7+Penalty, after that it's BV+10+Penalty.
 * (Re-confirmed) Repeatedly renaming a random object (no durability) costs 5 the first time, then stays 9 for all later renames.

This doesn't really square with my prior attempt under "More Questions" above, so there may be issues with whether a renamed object is intact (but I don't think so). Or I might have muffed something when I did the previous try, which is entirely possible. --Mental Mouse 02:05, 24 November 2012 (UTC)

OK, I redid the second experiment from "More Questions". Looks like I had a mystery extra point in step 5 and maybe 8. What I'm getting now is:
 * 1) Durability 101, costs 3, 7, 10.  Repaired.
 * 2) Durability 491, costs 5, 9, 12.  Repaired
 * 3) Durability 881, costs 7, 11,14.  Repaired.
 * 4) Durability 1271, costs 8, 13, 14.  Renamed.
 * 5) Durability 1271, costs 4, 12, 14.  Renamed.
 * 6) Durability 1271, costs 4, 12, 14.  Repaired.
 * 7) Max durability.  After slight damage, costs 3, 12, 13.  (I checked, and damaging it didn't change the renaming costs.)

I couldn't test wiping the name, but otherwise, now it matches my theory above. I'm putting that in the rewrite for now, we can change it if we find out it's incomplete. --Mental Mouse 02:42, 24 November 2012 (UTC)
 * Hello from not my home! Looks good though! One thing: I've heard sword repairs are different to other items/armour etc. Also, just to be sure: what are the three different costs? Are they the material stuff? And is there anything else I need to do, related to the rewrite or anything? Opaquer 12:24, 24 November 2012 (UTC)
 * The three costs are repair (1 unit), rename, both. Do you mean that sword renames are different?  I can check that, though not right now.  (Niece's birthday party RSN).  For the rewrite, just leave a note at Talk:Anvil mechanics saying yeah, we should replace the page with our new one.  I asked for a consensus, but haven't gotten any replies.... :-(  I figure if there's no feedback in another week or so (give them time to recover from Thanksgiving), we should just figure "no opposition" and go ahead. --Mental Mouse 15:15, 24 November 2012 (UTC)