Showcase [Showcase] Prototype Artificial Intelligence inside Terraria (pre-1.3.1)

DicemanX

Brain of Cthulhu
So I created an Artificial Intelligence Machine in Terraria. This AI is capable of learning from both negative and positive feedback; the feedback is either manual or automated. The entire machine consists of an input interface, a distributor (which directs the signaling agent to a particular neural subnet based on the input), and a neural net composed of individual neural subnets.

Each neural subnet is comprised of a randomizer that connects to neural paths which generate various outputs. Initially, the AI fires a signal randomly along one of the neural paths. However, if the AI receives negative feedback, it will shut down that neural path, so that it will be excluded in the next round of decision-making for the same input. Additionally, if the AI receives positive feedback, and it is instructed that the chosen neural path is always the best path to take, then the AI will shut down all other neural paths in that subnet.

The potential for this is pretty staggering, but rather limited pre-1.3.1. In my preliminary build that features a simple addition learning game, I have 6 subnets with 6 neural paths apiece, and it already takes up quite a bit of space. If I adapted this to a game of tic-tac-toe, then the number of neural paths would increase to over 10,000, which wouldn't even fit in a large world. However, with the tools coming in 1.3.1, it will be possible to compress the mechanism greatly, and speed it up considerably.

Note also that neural subnets can be in turn linked to further subnets to create a large array of branching pathways stemming from a single input. Alternately, the subnets can be linked based on further player inputs, such as what would happen in an interactive game in which the player and the AI alternate making moves.


Video showcasing the AI:



The Interface:

OBSCycU.png



Explanation of the Learning Game:

The player inputs two digits (1,2, or 3) to be added, and then pulls the AI lever to allow the AI to perform the addition. Initially, the AI will randomly select one of six answers (1-6). The player will then offer positive or negative feedback by pulling on the RIGHT or WRONG levers. Then the player pulls the clear lever and inputs another pair of digits. This continues until the AI learns the correct answer for each pair of digits to be added.

The machine learns by shutting down neural paths that lead to the incorrect answers, eventually producing only the correct answer. Alternately, when "hyper learning" is enabled, the AI will immediately shut down all other neural paths after it gets the correct answer and the player pulls the RIGHT lever. It is possible to give the AI incorrect feedback, and teach it to consistently generate an incorrect answer. This shows that the machine learns strictly through the feedback, and not because the correct answer is hard-coded into the machine.

The player can reset the AI at any time by pulling the RESET lever. This will wipe the AI's memory and the AI can be retrained.


Schematics of one of the Neural Subnets:

zzChEDn.png


vKYQtRS.png



Explanation:

Skip ahead to the tutorial part of the video for a fuller explanation of what is going on in each subnet. Briefly, when the player pulls the AI lever, it sends a dummy ghost into the starting randomizer module. Each module branches into two paths, and the ghost has a 50% chance of proceeding down one of those paths. There are six modules in total, and there are six possible paths from the entire randomizer leading to one of six neural paths (hoik tracks in the subnet).

The ghost stops in the chosen track, awaiting feedback. If the WRONG lever is pulled, it causes a deactuation of a hoik tooth earlier in the track, activating a teleporter there that loops back to the start of the randomizer. This way if a ghost tries to proceed down the same track again it will be sent to the randomizer again and again until it finally selects an open track.

If the RIGHT lever is pulled with HYPER LEARNING enabled (H lever in the schematic) then the ghost is hoiked to a different teleporter, whose pressure plate also deactuates the hoik teeth at the start of every track, shutting down all the tracks. The pressure plate also connects to the hoik tooth in that track alone, reopening the track. This way, all other tracks are shut down except the track the ghost traveled through.


Full Schematics:

d7gCNTF.jpg


BzHBI5n.jpg


World Download:

https://drive.google.com/file/d/0B4b_4cIU1vVBcnBTYVZjcVNwdGM/view


Acknowledgements:

My thanks to the creators of Mechmod, the T-MEC community mod. I use the mod for free-cam mode to showcase the builds in the videos. Here's a link:
http://forums.terraria.org/index.php?threads/mechmod-a-t-mec-community-mod.38088/page-10#post-923417
 
Last edited:
Wow. Just... Wow.
Seeing what can be done already with the wiring system currently, makes me wonder just how far things will go in 1.3.1...
I'm honestly expecting the ability to program enemies, with something like lizahrd traps and wooden spikes
 
Wow! It's amazing to see the small mod I started turn into something so huge (I don't even code anymore lol!)

This is amazing, and hope with 1.3.1 we can create a wiki-- all in game (That would be so freaking hard but awesome!)
 
Oh God, Artificial Intelligence in Terraria?! You never cease to amaze me Diceman!
I can't even, this is so cool!!!
 
Okay, really? This is AMAZING! I downloaded it and it's pretty neat! You really outdid yourself!

I did find that if you put in things with a different order, it won't remember it from the other order.
Ex: 2+1=3 (and I entered right)
But then I did 1+2 and it came out as 4, even though it had already seen a correct answer.
 
I did find that if you put in things with a different order, it won't remember it from the other order.
Ex: 2+1=3 (and I entered right)
But then I did 1+2 and it came out as 4, even though it had already seen a correct answer.

The order doesn't matter. What does matter is whether you have hyperlearning enabled. If it is off, then telling the AI that it is correct in generating an output of 3 when 1+2 (or 2+1) is input will not prevent it from trying other options. The AI doesn't "know" that there's only one correct answer, so you need to instruct it by turning hyperlearning on :).
 
Back
Top Bottom