Talk:Biome spread

Walls and Biome spread
[Former title: "Walls do not spread biomes" --MentalMouse42 (talk) 11:38, 21 August 2019 (UTC)]

Walls do not spread biomes – confirmed here on forums. --MentalMouse42 (talk) 04:54, 17 August 2019 (UTC)
 * According to the 1.3.5.3 source code, that is not entirely true. Walls do spread, but they only affect natural purity walls. Here is what I found:
 * Natural Corrupt Grass Walls, natural Ebonstone Walls (both regardless of foreground block type – can be none at all), and Corrupt grass can all convert any Grass Wall, Jungle Wall, or Flower Wall (all three natural or manually placed, does not matter) within a radius of 2 tiles to a natural Corrupt Grass Wall, but only if there is at least one Corruption-related block (Demonite Ore, Corrupt grass, Corruption plants/flowers, Vile Mushroom, Ebonstone Block, Corruption Thorny Bush, Ebonsand Block, or Purple Ice Block) within a radius of 20 tiles. Crimson and Hallow seem to be quite similar to that (although Hallow cannot convert Jungle Walls, as it cannot convert any Jungle tiles).
 * There is some... unexpected behavior, though: Above the surface, the Crimson does not have this Crimson-related-block-within-20-tiles restriction, but instead the restriction that there does need to be a Crimson-related block in front of the Crimstone/Crimson Grass Wall. Below the surface, this seems to be true for all three biomes. I am highly skeptical about this, because it would be very arbitrary to let only surface Corruption and Hallow spread quite differently from the rest (or am I missing something here?). I assume an error occurred during decompiling which led to certain variable names being swapped (especially because there is unused, unnecessary code nearby, which would imply behavior like described above – if the variable names were correct).
 * The Underground Desert has a separate spreading mechanism: Natural Ebonsandstone Walls, natural Hardened Ebonsand Walls (both regardless of foreground block type – can be none at all), and Ebonsandstone Blocks can convert any Sandstone Wall, natural Crimsandstone Wall, or natural Pearlsandstone Wall to a natural Ebonsandstone Wall and can convert any natural Hardened Sand Wall, natural Hardened Crimsand Wall, or natural Hardened Pearlsand Wall to a natural Hardened Ebonsand Wall. Both conversions can only happen within a radius of 2 tiles and only if there is any Corruption-related block within a radius of 20 tiles.
 * I would like to get some input on this before adding it to the article, especially regarding what I called "unexpected behavior" above. After doing some more source-digging, I realized that Corruption and Crimson are not actually always as similar as I had thought, but this still seems odd to me. Has anybody experienced something in that regard?
 * --Rye Greenwood (talk) 04:09, 18 August 2019 (UTC)
 * Thank you for the source-dive! I wouldn't assume an error in decompiling -- unless you know your decompiler is unreliable, this sort of thing is exactly what a decompiler is expected to get right.  It's entirely plausible that some code got orphaned when a dev decided to make the Crimson behavior more distinct from Corruption.  In any case, you have brought out a core of useful information:  "Walls cannot infect blocks, but they can infect other walls within 2 tiles, if there are infected blocks nearby.  Unlike blocks, walls may also convert walls from other infectious biomes.  The exact restrictions on wall infection vary with both the infectious biome and the underlying biome."  That much can go right in the page, and I'll put it there, then come back to try and summarize the details here.  --MentalMouse42 (talk) 11:41, 18 August 2019 (UTC)
 * OK, I'm back. I'll try to summarize your findings so far, and you can tell me if I've got it right.
 * Natural infected grass, grass walls, or stone walls can convert natural or placed pure grass, jungle or flower walls into infected grass walls, except that Hallow can't convert jungle walls.
 * Corruption, Hallow, and underground Crimson need an biome block within 20 tiles. Surface Crimson instead requires an biome block in front of the source wall.
 * Natural infected sandstone or hardened-sand walls, or infected sandstone blocks, can infect natural sandstone or sand walls, including those of other biomes, again only if there's a biome block within 20 tiles.
 * Here you discuss Corruption but not Crimson. Given the preceding, I think it's worth checking if Crimson (and/or Hallow) have any differences.
 * In all cases, wall infection range is 2 tiles, rather than the 3 tile range for block infection.
 * Any wall which becomes infected thereafter counts as a natural wall. (What about placed walls which get infected or purified by powder/water/solution?)
 * Does that look right? --MentalMouse42 (talk) 13:32, 18 August 2019 (UTC)
 * Thank you for structuring that thing. I glanced through the code again to confirm everything and found another exception that I missed (I have to admit, I was rather tired yesterday): In regards to Hallowed wall spread, only natural Hallowed Grass Walls and Hallowed grass blocks can convert other walls – Pearlstone Walls cannot.
 * I realize I have not expressed myself unambiguously enough. Only Corrupted and Hallowed walls that are above the surface require a biome tile nearby (that 20-tile range) to spread. The rest instead requires the source tile to contain a biome block in the foreground.
 * Apart from that, it looks good. The term "underground Crimson" should probably be avoided, because that refers to the actual biome, which exists in the Cavern layer (whereas here, the mechanics already apply just below the surface, i.e. in the Underground layer).
 * In the Underground Desert, Crimson and Hallow behave exactly like the Corruption.
 * I'll list the biome tiles which are necessary for spread here (they are the same for both above- and below-surface wall spread), because there are certain inconsistencies (who would have thought):


 * Last point: Yes, all walls that get converted to biome variants, regardless of whether they were placed manually or naturally, are afterwards considered natural. I am not sure how much of a difference this makes (I do not think there are that many walls with both natural and manual forms), but well, that is how it is.
 * Thrown Powder can safely be ignored, since it only affects foreground blocks. Thrown Water and Clentaminator solutions behave similarly in that they always convert all pure and biome variants of Grass Walls (player-placed or not), Stone Walls, Sandstone Walls, and Hardened Sand Walls to the respective biome counterpart.
 * --Rye Greenwood (talk) 21:46, 18 August 2019 (UTC)
 * Addition: In-game testing revealed that the 20-tile range limit is not always adhered to in practice (https://imgur.com/a/AnRklmB), only sometimes. I guess it should be treated more as an estimate. --Rye Greenwood (talk) 22:05, 18 August 2019 (UTC)
 * Thanks again for your delving. Unfortunately, it's late here and I'm going to be out early tomorrow, so it may not be until tomorrow evening that I can edit the page.  (I'm fine if you decide to do it yourself.)  As far as "how much of a difference this makes": Consider that Underground Desert is defined by the presence of natural walls... and now we know a way to turn placed walls into natural walls!  Win!  --MentalMouse42 (talk) 02:00, 19 August 2019 (UTC)
 * Sneaking in here for a bit before I head out: Just to confirm a few points:
 * Demonite counts for a foreground block, but not Crimtane? Including in Underground desert?
 * Conversely, even above the surface, Crimson always requires a block at the source tile?
 * ETA: You say pearlstone walls can't spread, what about pearlsand and pearlsandstone walls? Come to think of it
 * Plant blocks do count underground, unless it's also desert?
 * ETA2: Does the desert have to register as a desert biome in normal fashion (sand blocks), or does this apply any time one of the desert walls is the source?
 * They do seem to have taken pains that each of the biomes has some unique variation, don't they....
 * --MentalMouse42 (talk) 10:58, 19 August 2019 (UTC)

I've merged the above info into the page, with the clarification that plants are not actual blocks. --MentalMouse42 (talk) 14:16, 19 August 2019 (UTC)
 * Looks pretty thorough & came up with unexpected side-discovery (how-to naturalize walls). Thanks for getting all that nailed down; it'll save a lot of work.  No more Meteor Hamaxing around the entire Corruption (and pickaxing out the purified stuff Just In Case).  208.89.33.43 18:41, 19 August 2019 (UTC)


 * MentalMouse, I hope you do not mind that I have turned your bulleted list into a numbered list; I can refer to the different points more easily that way:
 * Demonite Ore only counts as a biome tile for regular Corrupted wall spread (both above and below the surface), not in the Underground Desert. Crimtane Ore is never considered a biome tile.
 * Yes, surface Crimson always requires a biome tile at the spreading wall's tile. Only surface Corruption and Hallow do not. (I suspect I have misunderstood your question, because I actually thought this has been clear already... Did you mean something else?)
 * Natural Hardened Pearlsand Walls and natural Pearlsandstone Walls are the two wall types spreading Hallowed walls in the Underground Desert. Outside of the Underground Desert, only natural Hallowed Grass Walls and Hallowed grass blocks can spread Hallowed walls, as already discussed. (So a Pearlstone Wall could technically "spread" Hallowed walls in the Underground Desert if it was behind a Pearlsandstone Block, but that is because the wall behind a Pearlsandstone Block does not matter (see 5. below).)
 * Yes, plant tiles (including Vile/Vicious Mushrooms) always qualify as biome tiles outside of the Underground Desert. (By the way, I made a small mistake loosely related to this: Crimson/Hallow vines are always considered biome tiles as well, even in the Underground Desert – although a vine in the Underground Desert would surely be more than a strange sight. I edited the overview above accordingly.)
 * The decision of whether or not to apply Underground Desert behavior is entirely determined by the source (spreading) tile. For the Underground Desert mechanics to take action, the source tile has to contain any Sandstone Wall, any Hardened Sand Wall, or any Sandstone Block (in all three cases disregarding the other (wall/block) content of the tile for this step). Conversely, for the regular spread behavior to take effect, the source tile needs to contain any natural infected Grass Wall/Stone Wall/grass block, excluding Pearlstone Walls, again disregarding the rest of the tile's content.
 * There is no other requirement for the Underground Desert behavior. (So the Underground Desert spread may even happen on a Floating Island; well... if there somehow happened to be a natural Hardened Sand Wall/Sandstone Wall to spread to nearby... – yeah, generally, it will be limited to the actual Underground Desert by the restrictions.)
 * The biome to convert the target wall to is determined by the contents of the source tile, checking in the following order: Crimson wall → Crimson block → Hallowed wall → Hallowed block → Corruption wall → Corruption block. Qualifying walls are the respective natural Stone/Grass/Hardened Sand/Sandstone Walls and qualifying blocks are the biome tiles we already know (but only the ones which apply in the Underground Desert, of course, so e.g. no plants).
 * Examples:


 * {| class=terraria

! colspan=2 | Source tile !! rowspan=2 | Biome the target wall will be converted to ! Block !! Wall
 * || || Crimson
 * || || Crimson
 * || || Hallow
 * || || Corruption
 * }
 * All examples trigger Underground Desert spread behavior due to one of the source tile's contents pertaining to the group of Underground Desert tiles I mentioned above.
 * I guess it cannot hurt to outline the specifics of Underground Desert behavior again, now that I have talked so much about it; so just to be crystal clear: If Underground Desert behavior is "activated", due to the source tile being related to the Underground Desert as described above, any natural Sandstone Wall or any natural Hardened Sand Wall within 2 tiles around the source tile will be converted to the biome determined by the order above. At least one biome tile of the respective biome needs to be present within a 20×20 41×41-tile rectangle around the source tile for the conversion to succeed. Thus, the main difference here is that Sandstone Walls/Hardened Sand Walls of other biomes, not just the pure variants, can be converted. Another interesting difference is that the source wall is not always determining the biome to convert the target wall to (I mean, this is also partly true for regular, non-Underground-Desert spread, but there a Hallowed grass block in front of a Crimstone Wall can spread both biomes, whereas in the Underground Desert that would not be possible).
 * --Rye Greenwood (talk) 23:28, 19 August 2019 (UTC)
 * }
 * All examples trigger Underground Desert spread behavior due to one of the source tile's contents pertaining to the group of Underground Desert tiles I mentioned above.
 * I guess it cannot hurt to outline the specifics of Underground Desert behavior again, now that I have talked so much about it; so just to be crystal clear: If Underground Desert behavior is "activated", due to the source tile being related to the Underground Desert as described above, any natural Sandstone Wall or any natural Hardened Sand Wall within 2 tiles around the source tile will be converted to the biome determined by the order above. At least one biome tile of the respective biome needs to be present within a 20×20 41×41-tile rectangle around the source tile for the conversion to succeed. Thus, the main difference here is that Sandstone Walls/Hardened Sand Walls of other biomes, not just the pure variants, can be converted. Another interesting difference is that the source wall is not always determining the biome to convert the target wall to (I mean, this is also partly true for regular, non-Underground-Desert spread, but there a Hallowed grass block in front of a Crimstone Wall can spread both biomes, whereas in the Underground Desert that would not be possible).
 * --Rye Greenwood (talk) 23:28, 19 August 2019 (UTC)


 * No problem with the numberings. And you were pretty clear, I just felt the need to confirm particularly "surprising" findings.  Over the next day or two I'll see how much of these newest details I can work into the page, though again, you're welcome to join in.  One quibble:  Given you previously mentioned a 20-tile radius, I suspect that in this last note, you meant to say "a 41×41 rectangle around the source tile".
 * ETA: Also, we now know how to put a natural Desert wall in a sky island, and it's easy enough to put grass in the Underground desert, where I'd guess that it would grow vines.
 * --MentalMouse42 (talk) 01:40, 20 August 2019 (UTC)


 * Hmm... again, confirming a "surprising" point: If I understand you correctly, that corrupt grass wall with a sandstone block in front of it, would only corrupt sand or sandstone walls, but not other grassy walls?  While a crimson grass wall with a non-sandy pure block in front of it would only crimson grassy walls, not sandy walls? --MentalMouse42 (talk) 03:14, 20 August 2019 (UTC)


 * Also: If there is in infected grass wall with an infected sandstone block in front of it, I get the impression that the Underground Desert mechanics take precedence? --MentalMouse42 (talk) 11:43, 20 August 2019 (UTC)


 * Okay, I've taken a shot at working this information into the page. Where your comments seemed to contradict each other, I went with the latest statement.  Can you check the result for correctness?
 * One oddity I ran across elsewhere: This forum user seems to have encountered a situation where Crimson walls were spontaneously reverting to purity (pre-Hardmode).  I suspect Z-fighting, but otherwise don't know what to make of it, and the thread is from almost a year ago.  --MentalMouse42 (talk) 13:10, 20 August 2019 (UTC)


 * (First off: Natural conversion to purity walls is something that indeed sounds very odd. I have never experienced it and I do not see anything in the source code indicating such a behavior. I was going to say that perhaps the original poster is playing on console, where the whole thing might work differently, but then I saw the thread was posted in "PC In-Game Support", so... well, I have no idea at all. Also, you are correct, I did mean a rectangle of 41×41 tiles; I messed up there. I realize that the term "radius" I have been using might cause misconception, so just for clarity: All areas are rectangular. (This also applies to most other parts of the source code, because the rectangle is simply a very common tool in XNA.))
 * It seems like at this point I will need to describe the entire process of wall conversion, because I believe that will resolve any existing lack of clarity.

[Code accounting Moved to new section --MM]


 * This covers the entirety of the wall spread behavior, it is basically a translation of the code and is what I have been drawing my conclusions from. I hope this is not too technical, but it should provide you (and anybody else who is interested, of course) with the same information that I have.
 * As one can see, it is possible for a source tile to perform multiple conversions within one loop cycle, based on its wall/block content.
 * It should also answer your questions:
 * A Corrupt Grass Wall with a pure Sandstone Block in front of it can convert any nearby grass-type wall (but only if it is above the surface (!), since the Corrupt Grass Wall requires a biome tile in front if it is underground) into a natural Corrupt Grass Wall in the first steps of the loop cycle, and then convert any nearby Hardened Sand Wall/Sandstone Wall into its respective Corrupt version.
 * A Crimson Grass Wall with a non-sandy pure block in front if it would not convert anything, because non-Underground-Desert Crimson always requires a biome block on the source tile.
 * Any infected Grass Wall with an infected Sandstone Block/Hardened Sand Block of the same infection in front of it can both convert any nearby grass-type wall (regardless of elevation) into the Grass Wall type of its infection, and any nearby Hardened Sand Wall/Sandstone Wall into its respective infected version.
 * I can help working the details into the page, but will probably not do so before tomorrow (I think I need a break from this topic for now).
 * --Rye Greenwood (talk) 00:04, 21 August 2019 (UTC)


 * I'm fine with the technical aspect; in a prior lifetime I was actually a C programmer. So I do understand what you've written, even if it makes me want to spank the devs with a programming textbook. ;-)
 * Begging your pardon for the presumption, but I've split your code accounting out into a separate section for general reference. No need to dare burnout on account of this stuff; I will see what I can do about representing this on the topic page tonight and/or tomorrow, and when you have a round tuit to spare you can check my work.  Thanks again for all your effort on this!  I'm quite sure that future players will benefit greatly from the results.
 * --MentalMouse42 (talk)


 * (Edited) I believe I've captured the consequences of the above, while shedding some internal convolutions. I notice some interesting gaps:
 * Ice walls don't seem to have biome variants, but stone walls certainly do... Can those not pass or receive infections at all?
 * Once infected, a Grass wall apparently can't change biomes?
 * On consideration, I'd assume that when a block gets infected, its wall goes with it whenever possible. Cave walls and such are still unclear.
 * --MentalMouse42 (talk) 11:38, 21 August 2019 (UTC)

Believe me, I have had that feeling so many times while browsing the code... I have a morsel of hope that 1.4 will bring some code cleanup (although I guess it is more likely to make things even messier). Splitting the algorithm explanation is fine; that way I can link it from the article, hah. Thank you for putting all of this into understandable words, I appreciate that! One last thing I have noticed: How did you calculate the average number of seconds for a tile to be updated? I calculated an average of 167 / 777 seconds, respectively, when I tried to understand how you reached those values: $$\frac{1}{(6400\times1800\times3\cdot10^{-5}) \div (6400\times1800\times0.3) \times 60}\approx166.7$$ (and similarly for the underground) -- Rye Greenwood (talk) 00:44, 23 August 2019 (UTC)
 * Ice Walls do not have biome variants, presumably because they are rather rare – mostly, there are no background walls at all below the surface, only the background graphic. See this lovely screenshot for an underground Crimson ice cave with pure Ice Walls.
 * Yes, it does look like an infected grass wall will never be changed by natural means.
 * I do not think a wall gets infected together with its foreground block (if that block is converted by natural spread, that is). All suitable walls within the initial "V" after starting Hardmode get infected automatically and they will spread naturally "around" their blocks. For cave walls, the situation is similar to Ice Walls: There are no direct counterparts of the different cave walls because there rarely ever are background walls underground, at least so I assume. (I mean, there are biome-exclusive cave walls, but they can only exist in the "V" shape and do not spread whatsoever (unless I am missing some very big thing here, but I cannot remember seeing those walls e.g. in infected patches caused by destroying altars.)


 * I did not bother with the exact size of a world, since it varies; I noted that the number of blocks updated per tick was a fraction of the blocks per world, and that the "aboveground" area for each world size is approximately 1/4 of the whole (iirc, the large world is furthest from that, a few percent more). Then I rounded to 2 significant digits, because with that selection method, the "average time" is only barely meaningful anyhow.  I just did it in a calculator program and it's entirely possible I made a mistake, but given the low precision I'm happy enough that your more exact calculation is as close as it is.  (It means I didn't flip any fractions or misplace a decimal point).  Basically I've got enough scientific education to respect digits of precision, and enough engineer's temperament to "cut with an axe" in this sort of situation.  ;-) --MentalMouse42 (talk) 02:18, 23 August 2019 (UTC)


 * Sounds totally reasonable! I have no problem with leaving it like it is in that case; I was just wondering. --Rye Greenwood (talk) 02:26, 23 August 2019 (UTC)


 * Cool. I'm pretty sure an actual statistician would slap me, and then figure the chance for a tile to be updated in some given time.  But I've long since forgotten whatever I knew about Poisson distributions; that was 30 years ago, and I don't think I used them once in my working time.  Of course, now I'm looking at that page and wondering about the mechanics for block spread, but I bet the code for that is at least as bad. --MentalMouse42 (talk) 02:39, 23 August 2019 (UTC)


 * Then let us just hope we are flying under the radar of the statisticians here (the ones with a tendency to slapping, that is; if there is any peaceful one around willing to do some proper calculations – please go ahead!). Regarding block spread: I would not mind digging out that algorithm (as exhausting as it may be, it is always incredibly interesting to take a peek behind the scenes), but I am not sure if I will have enough time tomorrow or on the weekend. I should at least be able to have taken a look by Sunday, though. Of course, everybody else is invited to join in as well! --Rye Greenwood (talk) 03:01, 23 August 2019 (UTC)

And, an unhappy postscript. As a forum user pointed out to me, even pure Sandstone and Hardened Sand walls are unobtainable and uncraftable by the player, so no artificial Underground Deserts. --MentalMouse42 (talk) 14:10, 1 September 2019 (UTC)

While I am not a statistician, I can still provide a formula for the probability for a tile to be updated in a given time - hopefully it will be useful. :) P(N) = 1 - ( (1-1/(W*L)) ^ (T*N) ) ; where P(N) is the probability that a given tile will be updated at least once in N ticks; W is the width (in blocks) of the World; L=S for the above-surface-level loop and L=H-S for the below-surface-level loop; S is the height (in blocks) of the above-surface-level part of the World; H is the total height (in blocks) of the World; T is the number of tiles that are updated every tick (T=0,00003*W*H for the above-surface-level loop and T=0,000015*W*H for the below-surface-level loop; the result is obviously rounded - I assume to the closest integer, but it may instead be rounded up or down). Using this formula, it can be calculated that: In a Small World, assuming S=330: the probability for an above-surface-level tile to be updated at least once in 5 sec is ~ 3,2%, in 30 sec ~17,8%, in 1 min ~32,4%, in 2 min ~54,4%, in 3 min ~69,2%, in 4 min ~79,2%, in 5 min ~85,9%, in 6 min ~90,5%, in 8 min ~95,7%, in 10 min ~98,0%, in 12 min ~99,1%, in 18 min ~99,9%; for a below-surface-level tile - in 5 sec ~0,6%, in 30 sec ~3,7%, in 1 min ~7,2%, in 2 min ~13,9%, in 3 min ~20,1%, in 4 min ~25,9%, in 5 min ~31,2%, in 6 min ~36,2%, in 8 min ~45,1%, in 10 min ~52,7%, in 12 min ~59,3%, in 18 min ~74,0%, in 24 min ~83,4%, in 30 min ~89,4%, in 40 min ~95,0%, in 60 min ~98,9%, in 90 min ~99,9%. In a Medium World, assuming S=480: for an above-surface-level tile - all probabilities are very slightly higher than those in a Small World (with S=330), by up to 1,2% (~70,4% in 3 min); for a below-surface-level tile - all probabilities are very slightly lower than those in a Small World (with S=330), by up to 0,6% (~58,7% in 12 min). In a Large World, assuming S=720: for an above-surface-level tile - all probabilities are slightly lower than those in a Small World (with S=330), by up to 3,1% (~66,1% in 3 min); for a below-surface-level tile - all probabilities are very slightly higher than those in a Small World (with S=330), by up to 1,0% (~60,3% in 12 min). I believe adding this formula (and maybe a couple of those numbers to give an idea about the scale of the probability) to the page may be helpful for some people to better evaluate, for example, how fast a single infected block from breaking an Altar will be spreading. Unfortunately, adding a math formula in a readable way goes beyond my very basic wiki-editing skills, so I hope somebody will be willing and capable to add this. :) And a small note about what was mentioned above, that sometimes infection can be spread further than 20*20 tiles away - yes, it can - up to 22*22 - because if the source tile selects a target tile which is, for example 2 tiles up and 2 tiles to the left, and then finds a single biome tile in the 20*20 rectangle at the bottom right corner, it can still spread it, and the distance between the newly infected tile and the closest biome tile will be 22*22, which is exactly what can be seen on that screenshot posted above - the infected walls stop exactly 22*22 tiles away from the edge of the Hallow biome blocks, so everything works as expected! 213.87.160.169 16:06, 30 April 2020 (UTC)

Wall Conversion Algorithm in Detail
So, every single game tick, i.e. 60 times per second, the game will be updated, including the current world. This includes a plethora of other things we do not focus on at the moment, but it also includes wall spread. Now, the structure of this function of updating the world (which is called every tick) is as follows: Do some things we do not care about (like updating the Lunar Events status, town NPCs pending for moving in, among others) → cycle through world width × world height × 3E-5 (346 for a medium world) randomly chosen tiles (possibly choosing the same tile multiple times in one loop) that are above the surface ("surface loop") → cycle through world width × world height × 1.5E-5 (i.e. half of the first one; 173 for a medium world) randomly chosen tiles (possibly choosing the same tile multiple times in one loop) that are below the surface ("underground loop") → do some other irrelevant thing (spawning Falling Stars if it is nighttime). The "contents" of those two loops are mostly similar, with only minor differences here and there which I will mark below. Again, in each loop some stuff happens before and after the wall spread, like growing plants, calculating Corruption/Crimson/Hallow block spread – we do not care. Remember that the loop is cycling through a collection of random tiles, so in each cycle, it has a tile in memory that will serve as a base for the majority of actions taken in the loop – the "source tile". If the current loop cycle now reaches the wall spread part, it will execute the following procedures, in this very order:

This covers the entirety of the wall spread behavior, it is basically a translation of the code and is what I have been drawing my conclusions from. I hope this is not too technical, but it should provide you (and anybody else who is interested, of course) with the same information that I have. As one can see, it is possible for a source tile to perform multiple conversions within one loop cycle, based on its wall/block content. --Rye Greenwood (talk) 00:04, 21 August 2019 (UTC)
 * 1) [convert suitable wall in range to Crimson] Check whether the source tile contains a natural Crimson Grass Wall, a natural Crimstone Wall, or a Crimson grass block. If it does not, continue with 2. If it does, continue with 1.1.
 * 2) Pick a random tile ("target tile", as in "conversion target") within a 5×5-tile rectangle around the source tile. If the target tile contains a grass-type wall (natural pure Grass Wall, natural pure Flower Wall, natural pure Jungle Wall, or their respective player-placed versions; these are the only wall types which can be converted), continue with 1.1.1. If it does not, continue with 2.
 * 3) Check whether the source tile contains one of the following: Crimson grass block / Red Ice Block / Crimson plant / Vicious Mushroom / Crimstone Block / Crimson vine / Crimsand Block / Crimson thorny bush. If it does, convert the wall of the target tile to a natural Crimson Grass Wall. Continue with 2. (even if no conversion happened)
 * 4) [convert suitable wall in range to Corruption] Check whether the source tile contains a natural Corruption Grass Wall, a natural Ebonstone Wall, or a Corrupt grass block. If it does not, continue with 3. If it does, continue with 2.1.
 * 5) Pick the target tile like in 1.1. If the target tile contains a grass-type wall (see in 1.1), continue with 2.1.1. If it does not, continue with 3.
 * 6)  Cycle through all tiles in a 41×41-tile rectangle around the source tile from top-left to bottom-right. For each of these tiles, check whether it contains one of the following:  Check whether the source tile contains one of the following: Demonite Ore / Corrupt grass block / Corruption plant / Vile Mushroom / Ebonstone Block / Corruption thorny bush / Ebonsand Block / Purple Ice Block.  As soon as one of them does, quit the 41×41-cycling loop and  If it does, convert the wall of the target tile to a natural Corrupt Grass Wall. Regardless of whether something was converted or not, continue with 3.
 * 7) [convert suitable wall in range to Hallow] Check whether the source tile contains a natural Hallowed Grass Wall or a Hallowed grass block (this is where Pearlstone Walls are excluded from being spreading walls!). If it does not, continue with 4. If it does, continue with 3.1.
 * 8) Pick the target tile like in 1.1. If the target tile contains a natural pure Grass Wall, a natural pure Flower Wall, or their respective player-placed variants (this is where the Jungle Grass Wall is excluded from being susceptible to conversion), continue with 3.1.1. If it does not, continue with 4.
 * 9)  Cycle through all tiles in a 41×41-tile rectangle around the source tile from top-left to bottom-right. For each of these tiles, check whether it contains one of the following:  Check whether the source tile contains one of the following: Hallowed grass block / Hallowed plant / Hallowed vine / Pearlsand Block / Pearlstone Block / Pink Ice Block.  As soon as one of them does, quit the 41×41-cycling loop and  If it does, convert the wall of the target tile to a natural Hallowed Grass Wall. Regardless of whether something was converted or not, continue with 4.
 * 10) [Underground Desert spread] Check whether the source tile contains any Sandstone Wall (natural pure Sandstone Wall / natural Ebonsandstone Wall / natural Pearlsandstone Wall / natural Crimsandstone Wall), any Sandstone Block (pure Sandstone / Ebonsandstone / Pearlsandstone / Crimsandstone), or any Hardened Sand Wall (natural pure Hardened Sand Wall / natural Hardened Ebonsand Wall / natural Hardened Pearlsand Wall / natural Hardened Crimsand Wall). If it does not, continue with 5. If it does, continue with 4.1.
 * 11) [determine conversion target biome] Prepare the variable targetBiome. Continue with 4.1.1.
 * 12) Check whether the source tile contains a natural Corrupt Grass Wall, natural Hardened Ebonsand Wall, natural Ebonsandstone Wall, or natural Ebonstone Wall. If it does, continue with 4.1.1.2. If it does not, continue with 4.1.1.1.
 * 13) Check whether the source tile contains any of the following blocks: Corrupt grass block / Ebonstone Block / Ebonsand Block / Purple Ice Block / Hardened Ebonsand Block / Ebonsandstone Block. If it does, continue with 4.1.1.2. If it does not, continue with 4.1.2.
 * 14) The source tile contains a qualifying Corruption wall or block. Set targetBiome to corruption. Continue with 4.1.2.
 * 15) Check whether the source tile contains a natural Hallowed Grass Wall, natural Hardened Pearlsand Wall, natural Pearlsandstone Wall, or natural Pearlstone Wall. If it does, continue with 4.1.2.2. If it does not, continue with 4.1.2.1.
 * 16) Check whether the source tile contains any of the following blocks: Hallowed grass block / Pearlstone Block / Pearlsand Block / Pink Ice Block / Hardened Pearlsand Block / Pearlsandstone Block / Hallowed vine. If it does, continue with 4.1.2.2. If it does not, continue with 4.1.3.
 * 17) The source tile contains a qualifying Hallow wall or block. Set targetBiome to hallow. Continue with 4.1.3.
 * 18) Check whether the source tile contains a natural Crimson Grass Wall, natural Hardened Crimsand Wall, natural Crimsandstone Wall, or natural Crimstone Wall. If it does, continue with 4.1.3.2. If it does not, continue with 4.1.3.1.
 * 19) Check whether the source tile contains any of the following blocks: Crimson grass block / Crimstone Block / Crimsand Block / Red Ice Block / Hardened Crimsand Block / Crimsandstone Block / Crimson vine. If it does, continue with 4.1.3.2. If it does not, continue with 4.1.4.
 * 20) The source tile contains a qualifying Hallow wall or block. Set targetBiome to crimson. Continue with 4.1.4.
 * 21) If targetBiome was not set by now, continue with 5. If it was set, continue with 4.2. [the above might sound a little complicated; it is that thing I described here]
 * 22) Pick a target tile within a 5×5-tile rectangle around the source tile. If the target tile contains any Sandstone wall (natural pure Sandstone Wall / natural Ebonsandstone Wall / natural Pearlsandstone Wall / natural Crimsandstone Wall) or any Hardened Sand Wall (natural pure Hardened Sand Wall / natural Hardened Ebonsand Wall / natural Hardened Pearlsand Wall / natural Hardened Crimsand Wall), continue with 4.2.1 for, 4.2.2 for , or 4.2.3 for . If the target tile does not contain any of the qualifying walls, continue with 5.
 * 23) Cycle through all tiles in a 41×41-tile rectangle around the source tile from top-left to bottom-right. For each of these tiles, check whether it contains one of the following: Crimson grass block / Crimstone Block / Crimsand Block / Red Ice Block / Hardened Crimsand Block / Crimsandstone Block / Crimson vine. As soon as one of them does, quit the 41×41-cycling loop and continue with 4.3. If the loop is finished without hit, continue with 5.
 * 24) Cycle through all tiles in a 41×41-tile rectangle around the source tile from top-left to bottom-right. For each of these tiles, check whether it contains one of the following: Hallowed grass block / Pearlstone Block / Pearlsand Block / Pink Ice Block / Hardened Pearlsand Block / Pearlsandstone Block / Hallowed vine. As soon as one of them does, quit the 41×41-cycling loop and continue with 4.3. If the loop is finished without hit, continue with 5.
 * 25) Cycle through all tiles in a 41×41-tile rectangle around the source tile from top-left to bottom-right. For each of these tiles, check whether it contains one of the following: Corrupt grass block / Ebonstone Block / Ebonsand Block / Purple Ice Block / Hardened Ebonsand Block / Ebonsandstone Block. As soon as one of them does, quit the 41×41-cycling loop and continue with 4.3. If the loop is finished without hit, continue with 5.
 * 26) [convert suitable Sandstone Wall] Check whether the target tile contains any Sandstone Wall (natural pure Sandstone Wall / natural Ebonsandstone Wall / natural Pearlsandstone Wall / natural Crimsandstone Wall). If it does not, continue with 4.4. If it does, continue with 4.3.1 for, 4.3.2 for , or 4.3.3 for.
 * 27) Convert the wall of the target tile to a natural Crimsandstone Wall. Continue with 4.4.
 * 28) Convert the wall of the target tile to a natural Pearlsandstone Wall. Continue with 4.4.
 * 29) Convert the wall of the target tile to a natural Ebonsandstone Wall. Continue with 4.4.
 * 30) [convert suitable Hardened Sand Wall] Check whether the target tile contains any Hardened Sand Wall (natural pure Hardened Sand Wall / natural Hardened Ebonsand Wall / natural Hardened Pearlsand Wall / natural Hardened Crimsand Wall). If it does not, continue with 5. If it does, continue with 4.4.1 for, 4.4.2 for , or 4.4.3 for.
 * 31) Convert the wall of the target tile to a natural Hardened Crimsand Wall. Continue with 5.
 * 32) Convert the wall of the target tile to a natural Hardened Pearlsand Wall. Continue with 5.
 * 33) Convert the wall of the target tile to a natural Hardened Ebonsand Wall. Continue with 5.
 * 34) End loop cycle (well, actually, do that other unimportant stuff first, but end it then) and start the next cycle with the next source tile.

Misleading info?
Guys, I think there is misleading information in this article. Grass has same corruption range as stone or any other block. I tested this for many days and grass was still not corrupted. Can somebody confirm this and change article? Thanks.

ScienceDiscoverer (talk) 10:00, 7 September 2019 (UTC)


 * I suspect the table format is in confusing... try the other way around, with pure stone around corrupt grass. -MentalMouse42 (talk) 17:26, 7 September 2019 (UTC)


 * I tried that too. It's still not corrupting =\ Something is off here. Maybe in some latest update range of corruption got changed?
 * Capture 2019-09-12 12_29_28.png
 * ScienceDiscoverer (talk) 09:36, 12 September 2019 (UTC)


 * Indeed, something is off. I do not know which update changed it, but as of 1.3.5.3, the conversion range for all regular (non-grass) tiles in Hardmode is 3 tiles. Your Corrupt grass block would only be able to convert one of those Stone Blocks if they were within a 7×7-tile rectangle that is centered on the Corrupt grass block.
 * Thank you for pointing this out! I have updated the article with what I could take from the source code for now and clarified some things. Hopefully I can continue and investigate the conversion of grass tomorrow; things are getting a bit more convoluted there (too much for my tired brain right now). Of course, anybody else who is interested can join in shedding some light on this! --Rye Greenwood (talk) 02:03, 15 September 2019 (UTC)


 * I added everything that I found to the article; hopefully things are clear now. If not, please ask! --Rye Greenwood (talk) 19:39, 15 September 2019 (UTC)