Friday, May 18, 2012

Magic Words Room Edits

Alright, apologize for the rushed and sub-par quality of the video, but it should show you the basics of how to use this thing:

Commands are as follows:

DMap - Toggles the debug map on and off, allowing you to see room boundaries and know exactly what you're doing.

RType - Toggles the bit of text next to the hand that tells you the type of the room you're touching.

DoorR [boundary] - Sets the boundary of the room "door" to the right of the hand, between 0 (nothing passes through) and 100 (Everything passes through)

DoorD [boundary] - Sets the boundary of the room "door" underneath the hand, between 0 (nothing passes through) and 100 (Everything passes through)

Room Type [type] - Changes the type of the room the hand is in. You can either type the Room Type number from 0 to 10, or the name of the room type itself. Entering "Room Type Help" will bring up a list of room type numbers and names.

Find CA Links - Creates symbolic colored dots in rooms that have a CA link in them. These dots can be clicked to move to the room they are linked with. Creatures cannot see or use these dots-- they are purely for user information. Note that this command can take several seconds to several minutes to finish, depending on the size of the world.

Hide CA Links
- Hides the CA Link dots (does not affect the links themselves)

Make CA Link -  Use this command twice-- once in the first room you wish to CA link, and again in the second room to complete the link. If you start a link but do not complete it, the linking process will be canceled after several seconds. All links are created with a strength of 1 (max)

Break CA Link -  Use while the hand is hovering over a CA link dot. Destroys the CA link between the rooms corresponding to the dot. It is important to use this command to break links as other methods such as kill hots will remove the dot, but not actually break the link.

After my huge writeup on the importance of CAs, I couldn't not come up with a tool to make that whole process easier, and it follows in the spirit of the Garden Box and other such efforts I've been making to make the world as customizable as possible

Download the Magic Words: Room Edits. As always, requires the Magic Words Core to work. This hasn't had more than a few hours of bugtesting, so please let me know if you run into any problems. 

Thursday, May 17, 2012

CAs and You!

So what is CA?

CA stands for Cellular Automata. More often, they are called “smells”, although this is somewhat of a misnomer, since light, nutrients, and water are not exactly smells, but since the majority of CAs are smells, the name sticks anyway.

CAs, sadly, are not easily perceived by the player, and as a result, we often forget completely about them while developing or even just setting up a creature habitat. I’m writing this stuff up to help bring awareness to how CAs are used in the game, how creatures perceive them, and how important it is that we design our agents and metarooms with the proper flow of CAs in mind.

CAs are Room Values!

Look at the map of the room below:


Each of those little sections, those little boxes, is called a room. The lines that divide them are known as doors. Even though they don’t really look like rooms or doors as we know them, that is how they are referred to, so just keep that in mind as you read the rest of this article.

CAs are not little invisible agents that waft around the ship like bacteria. They are actually numerical values calculated and stored in each room. One room might have a CA 8 (fat) smell value of 0.65, and the room next to it might have a CA 8 value of 0.55. CA values range from 0 to 1.

If you want to know the value of a certain CA in a certain room, first make sure you can see you room map by entering “dmap 1” in the caos command line. Center the hand in the room you want to check and enter the following: “outv prop grap mopx mopy #” replacing the “#” with a number from 0 to 19, depending on the CA you are testing for. Hitting enter should return a decimal value for the CA.

In the screens below, I’ve created labels to monitor the CA value of protein in each room. I’ve removed all other sources of protein smell in the world, so the only agent producing the smell are the lemons in the top left. As you can see, the CA concentration is the strongest where the lemons are sitting, and gets to be less and less as the rooms get further away. Even down at the bottom of the workshop, the CA exists, meaning a creature can sense it and follow it.


CAOS Note: Lemons don’t smell like lemons just because they’re classified as fruit! To make an agent “smelly” you have to use the EMIT command in the creation script-- the same place in the script you set your ATTR, BHVR, and other agent settings. The EMIT command is structured as such: emit [CA number] [amount]. The amount ranges from 0 to 1, so you might use 0.05 to give your agent a mild scent, or 0.9 for a very strong smell. You can actually set EMIT to a number even higher than 1, but the increase is very minimal.

How Creatures Use CAs

The classic Creatures IQ Test is the most common example of how exactly creatures use CAs to find their way around.

Creature brains already know from the start that protein smell is linked to fruit-- this is defined when the world is created using the CACL command, it’s not something they need to learn. And most creatures are born with an instinct to find fruit when they are hungry for protein. Once a creature decides to go looking for fruit, a combination of brain and action scripts take over.

The brain starts by checking the room the creature is in, and the rooms around it. It then decides which room has the highest CA value. If that room is to the left or right, a creature will simply walk that direction, but if that direction is up or down, the creature will start to feel very “low down” or “high up”, which will trigger its instincts to push or pull lifts to get moving in the direction with the higher CA. Similarly, if the CA is higher in a room that the creature can’t access by walking, it will start feeling “trapped” and feel inclined to push doors.



So in short, for a creature to pass a classic IQ test, it needs to:

- Be hungry.
- Understand that food (or fruit or seeds) will satisfy its hunger.
- Decide that finding food is more important than pushing the training dummy, taking a nap, smashing the lift button repeatedly, running into walls, etc.
- Be able to detect smells
- Understand that pushing lifts will satisfy its “need to go up” drive
- Understand that pushing doors will satisfy its “need to exit/trapped” drive.
- Not have any pose or gait mutations that might prevent it from traveling properly.

Primarily, creatures use CAs to find food. Creatures will also follow them to find their way home. This is most commonly seen in pregnant norns, who will often feel homesick and try to make their way back to the heating pan or incubator, where the hidden “norn home” (CA 15) emitter is located. Ettins will also make use of this, following the CA to “ettin home” (CA 17) when they are carrying a gadget (which they might have sought out by following the CA for “gadget” (18). CAs play a few other roles here and there, for example “norn” (12) CA generally makes grendels angry.

How other agents use CAs

While creatures use CAs for navigation, there are some plants and animals that rely on CAs as well. CA 3 (moisture) and CA 4 (nutrients) are sometimes required for certain plants to grow. The seed might check the room that it lands in, and if the CA levels aren’t high enough, it will just rot away instead of sprouting. Moisture might be added by little raindrops that, upon hitting the ground, add a little CA 3 into the room they land in. CA 4 might be added by decaying food; essentially compost. Similarly, some critters might require certain light or heat levels to reproduce or for eggs to hatch.

But this is all very agent-specific-- many third-party plants and critters especially don’t rely on CAs in part because many third-party metarooms don’t use emitters. These days, having an agent that requires certain CAs to function tends to really cripple where it can be used.

Overall, CA requirements for agents can potentially add a lot of complexity and interest to the game, but it requires a lot of knowledge about exactly what the agents require. In a room of CA-requiring agents, you might want to be careful about planting too many flowers that require lots of nutrients, lest they deplete the soil and your fruit-bearing plants are unable to grow. You might have to worry about watering the soil regularly, or throwing apple cores over it. The more CA requirements an agent has, the more restrictions there are on where it can thrive.

Often, when it comes to customizing, it’s easier to just ignore CA requirements and script in a form of population control, limiting where your plants sprout by room-type instead of CAs, so your species will thrive whether or not a room has proper emitters. But if you want to include this sort of interesting complexity into your agents, it’s important to specify to players what CAs they need, so the player knows to provide them in one way or another, whether by placing them in a room with emitters, creating their own emitters, or using other CA-altering agents.

CAOS Notes: Creating emitters is very easy. The code goes something like this:

new: simp 1 1 [species] "blank" 0 0 0
emit [CA number] [amount]
mvto [x] [y]


That’s it. Let’s say I want to be really mean and make a protein smell emitter to confuse my creatures. I might enter “new: simp 1 1 12345 "blank" 0 0 0 emit 6 0.5 mvto mopx mopy”.

This would create an invisible agent where the hand was that constantly emitted protein/fruit smell. Creatures would come from all over looking for fruit, and find nothing, and get very confused. So I wouldn’t recommend using it for fruit smell, but you might use it to emit light or heat, whatever the agents in the room might require.

But let’s say you don’t want to create an agent that emits a CA forever-- let’s say you just want to give the room a one-time boost of a certain CA, like how fruit might give the soil a little bit of nutrients as it decays. For this, you would use the ALTR command:

ALTR [Room ID] [CA number] [amount]

The room ID will probably be the room that the agent is sitting, in which case you can use “room targ” or “room ownr” in place of the room ID. If you’re running this from the CAOS command line, you can just use “room pntr” to use the room the hand is hovering over.

Amount in this case goes from -1 to 1, depending on if you want to subtract or add some amount of CA from the room.

Now, one thing to note is that ALTR doesn’t work on “smell” CAs that creatures use for navigation; it only works on CAs 0-5. If you need to alter the other CA of a room, you can use PROP, a command with the same function of ALTR, but instead of adding or subtracting the number specified, it sets that CA level in that room to exactly the number specified.

How CAs Travel

Now, we know what causes a CA value to exist at all, but what affects how CAs travel from one room to another?

Just a moment ago, we mentioned that ALTR works on some CAs, but not others. It works on heat, water, light, and other CAs that do not represent smells. Actual smell-based CAs are called “navigable” CAs by the game, presumably meaning that they are CAs creatures can follow to find their way to food sources or other objects of desire.

The interesting thing is that while non-navigable CAs can travel freely in all directions, navigable CAs only travel to the left and right.

For the purposes of demonstration, I have removed CA links from this room. Note how the grendel smell will only travel from left to right, and ignore rooms above and below:


Why do navigable CAs work like this? Doesn't it make more sense that smells would travel through all rooms?  Well, to us, yes, but you have to remember that we're dealing with not-so-bright creatures.
Again, for purposes of demonstration, I have set the pink and white grazer to emit a non-navigable CA that can travel anywhere. But let's say that was a protein smell, and poor Disastrous Plantation wanted to get to it? She would feel a pretty painfully stabbing desire to go up once she reached the open air, and have no way to get there. Maybe she would travel a bit more to the left to take the lift there, but she would just walk off the edge of the cliff trying to get to the grazer, getting increasingly more confused.

So for the sake of the creatures, it is better that smells only naturally travel in the directions that creatures can walk, and the rest be controlled by CA links.

CA links are very critical part of navigation for creatures, but not all third party metarooms include them, meaning you need to set them up manually to ensure your creatures can thrive.

As an example, here we see that there is a bounty of food right above Herria. But since smell CAs do not pass vertically through rooms, without CA links, she'll never be able to smell the food right above her.

CAOS Notes: Setting up a CA link is actually very easy. The syntax is as follows:

LINK [room1] [room2] [perm]

Room1 and Room2  are the room numbers you want to link. Getting these numbers is easy-- using Shift+Ctrl+R will produce the number of the room the hand is currently in right next to the hand:
 As shown, the room numbers we want to link here are 839 and 855. The perm is easy-- for most CA links, it is set to 1, to let all CAs flow freely between the link. Setting it to 0.5 would only let about half the CA amounts through the link, and so on.

So once we enter our command, "LINK 839 855 1" ... Herria can suddenly smell something delicious above her, and does not hesitate even a second to take the lift up to where the fragrant food awaits! As you can see by the tags, the CA smell has spread out into the rooms below.

CA links are also used to connect different metarooms together by creating a link between the rooms that the doors are located in; this way the creatures can smell what's on the other side of the door.

CA links are not just useful for linking up metarooms though-- creating links between rooms where elevines reside will encourage creatures to use them as well. Just remember that you are creating a link between two rooms, not two agents, and if you move the elevine, you'll need to break the old link (by running the command again with the perm set to zero) and create a new one, if you want to avoid some very confused creatures wondering where that smell is coming from!

Room Types and CAs

There's one more important thing to know about CAs, and that's how room types affect them. Room types are not just to determine if plants should grow or if fish should swim-- each type of room treats each CA differently. Consider the chart below:


Gain determines how much of the CA is absorbed from emitters in the room, Loss is how much of the CA dissipates into nothingness, and Diffusion controls how much of the CA flows over into other rooms.

Here you can see that soil-type rooms are really the only ones that can hold onto nutrient CAs, and CA smells travel much more easily through hard surface areas than through soil.

The variations between room types are subtle, but one special type of room to note is "Ettin Home," which is very much like a standard walkway with one huge exception-- it doesn't carry absorb gadget smell from gadgets in the room. This strange mechanism basically ensures that once ettins bring gadgets home to add to their hoard, they don't smell them anymore, meaning they can still pick up the subtle smells of other gadgets further away on the ship and hunt them down.

These relationships between CAs and Room Types can be altered with the RATE command, but you want to be careful what you do, because changes in CA rates will affect your whole world. Perhaps the most common CA rate modification available is Moe's Heat in Water transfer, which changes the rates to allow...well, heat to travel through water.

Wow... well, that about wraps up what I've learned about CAs over the past several weeks! I hope this clears up a lot of questions and misunderstandings about CAs, and hopefully makes the world an easier place for norns to find their way around. If you have any questions or comments or corrections, feel free to leave them below! And stay tuned for the release of a few Magic Words commands that will make managing your world's CA links a lot easier, I hope!