Building an Artificial Intelligence Machine inside Terraria

DicemanX

Brain of Cthulhu
We're still waiting for better toolsets in 1.3.1 on PC, but nevertheless I managed to build a preliminary Artificial Intelligence Machine within the game with a more limited toolset. Here's a video showcasing the machine. The video also explains the mechanisms involved:


The learning game featured in the video is very basic, but it does showcase how the AI can be trained to generate certain outputs. Here's what the game interface looks like:

OBSCycU.png


We're still very far away from being able to make complex games within Terraria, but this is a start to the whole process. Once the mechanisms are worked out, it will be possible to scale up the machines considerably, and create some really interesting games to play against the AI!

The general idea behind the AI machine is as follows:

An input interface sends signals to a distributor, which it turns carries a signal to one of the subnets within the neural network. Each subnet is dedicated to generating an output for a specific input. The subnets consist of a randomizer which initially randomly selects one of many neural paths to fire a signal down. The AI then waits for feedback. If negative feedback is given (either manually or in automated fashion) then the AI shuts down that neural path. If positive feedback is given, then either the neural paths remain untouched, or the AI will shut down every other neural path within that subnet. It will only do the latter if instructed that there is only one correct output.

Neural subnets can be connected to other neural subnets to handle chains of inputs - for instance, the player might play a game against the AI that involves taking turns. However, pre-1.3.1 such neural nets would take up too much space and wouldn't even fit in large worlds. For instance, a game of tic-tac-toe would require over 10 thousand neural paths! The coming update will actually make this feasible.

If you're interested in learning more about the specific mechanisms, look here:
http://forums.terraria.org/index.ph...intelligence-inside-terraria-pre-1-3-1.41434/

The mechanisms are centered around hoiks, once again demonstrating what sorts of things they enable!
 
INSANE!!!! how long did this take to figure out?

I built the randomizers and track system a while ago (I made a BlackJack machine that used the same approach) so for the AI I only needed to figure out how to incorporate negative and positive feedback to control the neural paths. I figured it out when driving back from work yesterday - driving long routes gives me plenty of time to think :).
 
Im curious how you wired the logic and memory?

I've done similar things in Minecraft before but i cant figure it out in Terraria since the wiring is pulse based not state based...
 
Im curious how you wired the logic and memory?

I've done similar things in Minecraft before but i cant figure it out in Terraria since the wiring is pulse based not state based...

T-MEC is the right place to learn all about it! :) You should check out the various threads in the T-MEC forums (linked in my sig) concerning hoiks and hoiktronics. Try to replicate some of the builds to see how they operate first-hand, and download any worlds that are provided to check out some of the larger builds.

Pulse-based systems aren't really all that different. For instance, when it comes to logic gates you still have inputs and an output but neither consists of sustained signals. Therefore, to ensure that you keep generating the same output for a set of given inputs, you need to incorporate local or global resets to the output. So long as you keep resetting the output to default before each logic gate operation, if will function as a gate instead of a simple toggle.

Here's a thread that gives examples of logic gating. I use giant logic gates instead of combining together the various traditional gates - Terraria allows us to create gates with N inputs and up to 2^N outputs by using a simple branching process. You can read about it here and try out some of the builds by downloading the worlds linked in that thread:

http://forums.terraria.org/index.ph...ic-gates-example-applications-included.29987/

You can also watch the accompanying tutorial video:


Here's another detailed video guide to building ALUs. It's a little dated, but it still gives the viewer a good idea of how hoiktronics works in Terraria:


Additionally, until 1.3.1 is released it is impossible to have pure wire-based logic in Terraria, so we have to resort to hoiks and use NPCs or dummies as signaling agents. You'll probably find things much easier in 1.3.1.

So, basically... You made a computer that can be taught how to do simple addition? That's awesome!

The addition learning game is pretty trivial, and was only used for demonstration purposes. It will be more interesting when the AI is expanded so that it can play more challenging games against the player. Also, given the initial random AI responses, I plan on adding a betting system so that you can do some gambling as the AI learns how to better play the games. Should be fun.
 
... what. You just blew my mind. Looks like Wiring is FAR more complex than I ever thought.
 
Back
Top Bottom