Wyrm logic and advanced farming

Not to be confused with **Farming.** This section is going to talk about wyrms' AI more in detail, and can be used for things like making AFK wyrm traps/farms, where wyrms automatically go to a certain location as soon as they spawn, and then get trapped so you can then kill/capture them without having to search for them. **This section is for advanced players only.**

### **Wyrms' basics**

First of all with in this guide "wyrm" is defined as any creature with the wyrm AI. Not to be confused with golem type enemies. The big differences between enemies with the wyrm AI and the golem AI is that golems will generally stay still unless the player is in sight, and they cannot dig tiles while wyrms can, and wyrms move around following a semi-straight line without ever stopping.

Wyrms usually prioritize certain movements over others, changing movement only in case something like a fence, an ore or a tile is blocking the way.

When wyrms are moving vertically they will try to find the widest horizontal space

So in this order wyrms will prioritize:

1. Moving Forward (toward the direction they are facing)
2. Moving Vertically (toward the widest horizontal space/tunnel)
3. Turning Back

So if there are 2 possible paths the wyrm will choose the one where they will be able to go to the most prioritized direction.

**NOTE:** **this doesn't count if the wyrm is near a player.**

### **Wyrms' behaviour with the player.**

Wyrms will always change their direction so their y coordinates are the same as the player's and their x coordinates are either higher or lower than the player's (basically they will always try to go to the left or to the right of the player) as they aren't able to attack the player when they're under, on or above them. This means that the player cannot be hit by a wyrm inside a tunnel like this.

So wyrms will change their direction only when it's possible and they aren't either above or under the player. Making the direction priorities when the player is nearby:

1. Moving horizontally towards the player (only if the wyrm is facing the direction of the player, so if the player isn't behind the wyrm)
2. Moving vertically towards the player (only if the wyrm is facing the direction of the player, so if the player isn't behind the wyrm)
3. Moving Forward (towards the direction they are facing)
4. Moving Vertically (toward the widest horizontal space/tunnel)
5. Turning Back

### **Wyrm logic basics**

By using the basic AI of the wyrms there are a few things that can be made, but first, to clarify some things:

* With tunnels this guide generally refers to any series of mined/empty tiles in which wyrms can only go in 1/2 directions through.
* With holes this guide generally refers to anything made with multiple tunnels.

The most basic tunnels are:

* - tunnels
* I tunnels
* Z tunnels

And because of wyrm AI wyrms will prioritize

1. - tunnels
2. Z tunnels pointing towards their direction
3. I tunnels
4. Z tunnels pointing towards the opposite direction

#### **Holes:**

Using the 4 types of tunnels it's possible to create more complex ones, for example one of the most common and used, the T hole

The T-hole is made with an I tunnel in the middle and a - tunnel directly on top or under it. It lets wyrms go through the I tunnel and into the - tunnel but doesn't let them go back. Note that this doesn't work if the player is nearby or an obstacle/another wyrm is blocking the wyrm inside the - tunnel from passing while the wyrm is directly on top of the I tunnel. Also note that it can be upside down but cannot be rotated 90° otherwise its purpose changes entirely by making it a Ⱶ tunnel.

If you, instead, put the - tunnel on one of the sides of the I tunnel you will make a Ⱶ tunnel instead (also called half H)

The Ⱶ hole can be used for different thing depending on the situation.

The most simple use is bringing wyrms from 2 different directions into 1 single one. note that when one of one entrances is in an open area the I tunnels will make the wyrms go back and exit to that open area, so it's advised to use a Z shaped tunnel that ends with a T hole.

Another use is to turn around a wyrm, to do this the - shaped tunnel has to be as small as possible and the way from which you want to make the wyrms exit from has to have a - tunnel above/under that's bigger that the one inside the Ⱶ in which the wyrm is in. Note that you can make just one entrance and turn it into a ┏ hole where the wyrm will go inside, turn around and go back.

If you combine 2 T holes together you get a + hole

The + tunnel acts like T holes because it let's wyrms from up and from down into the - tunnel but it doesn't let them out.

#### **Zones:**

And now it starts to get slightly more complex, zones are basically a series of tunnels and holes, and differently from them both they start using actual words as their names instead of just letters and symbols.

One of the most simple type of zone is the loop.

The loop zone does what its name suggests: it makes wyrms constantly move inside it in a loop. It's made by 2 T holes opposite to each other.

### **Advanced wyrm logic**

Now everything starts to get more complicated and less explained because it would take too much, feel free to go back and re-read everything whenever you want if you're still confused. This guide will heavily mention things like x, y and tiles so make sure you know what these are.

Now, here are some other behaviours that haven't been mentioned as they were a little bit complicated or used for complex contraptions. Note that they are very close to each other as they are mutually exclusive and almost always present when dealing with tunnels.

* If a wyrm hits a tile while moving left/right and can keep going forward if he went down and if he went up then he will choose randomly whether to go up or down. Note that if the wyrm cannot go forward he will go into the direction with the longest - tunnel at the end.
* If a wyrm is inside an I tunnel he will go to the direction with the longest - tunnel at the end, if both - tunnels have the same length it will choose the closest tunnel and if they are both the same distance it will choose a random direction.

When wyrms hit:

#### **Holes:**

Random holes, useful for sorting wyrms automatically. Random holes can only sort in the same direction where the wyrm is going to, for example a wyrm coming from left and going right will keep going to the right, even after being sorted.

The random hole sorts wyrms in a random direction. This version works only sideways.

The random hole sorts wyrms in a random direction. This version works only up/down and that the exits have to be horizontally symmetrical, with the point the wyrms enter (the - tunnel in the middle) being the center.