I Made a 32-bit Computer Inside Terraria

From Scratch
24 Jun 202315:25
EducationalLearning
32 Likes 10 Comments

TLDRIn an innovative journey, a person dedicates 600 hours over five months to create a fully functional computer inside the sandbox adventure game Terraria. Using the game's wiring system, they simulate the inner workings of a computer, overcoming challenges with logic gates and circuitry to build a prototype and eventually a complete computer capable of running programs like Pong, Conway's Game of Life, and even rendering a 3D world. To tackle performance issues, a custom mod called WireHead is developed, drastically improving execution speed. The project, compared to monumental achievements like Gutenberg's press or the Eiffel Tower, showcases a blend of creativity, technical skill, and perseverance, pushing the boundaries of what can be achieved within a video game environment.

Takeaways
  • πŸš€ The creator views the project as their greatest achievement, comparable to historical feats like Gutenberg's press or the Eiffel Tower.
  • πŸ”¬ Using Terraria's wiring system, the creator simulated the inner workings of a computer within the game, transcending its intended sandbox adventure gameplay.
  • βš™οΈ The project utilized a unique type of logic gate within Terraria, sidestepping traditional gates due to their complexity and timing issues.
  • πŸ’» The in-game computer operates on simple logic gates arranged in complex configurations, emulating the basic building blocks of real-world computers.
  • πŸ”§ Prototyping revealed limitations and learning opportunities, particularly around the custom and limited instruction set used.
  • ⚑ The full-scale computer required extensive work and innovation, including overcoming significant performance limitations.
  • πŸ‘¨β€πŸ’» By re-implementing Terraria's wiring system with a custom mod, the creator drastically improved performance, achieving 5000 instructions per second.
  • πŸ“± The project expanded to include an over-engineered software toolchain, supporting development in "Computerraria" with programmatic control over Terraria.
  • ➑️ Demonstrations of Pong, Conway's Game of Life, and 3D rendering showcase the computer's capabilities and the potential for complex program execution within Terraria.
  • πŸ” The project is open source, inviting further exploration and development from the community, with future aspirations like running a simplified version of Terraria within itself.
Q & A
  • What is the main achievement described in the video?

    -The main achievement described is creating a fully functional computer inside the video game Terraria, capable of running programs like Pong, Conway's Game of Life, and even simple 3D rendering.

  • How long did it take to build the computer inside Terraria?

    -According to the script, building the full computer took around three months of active development.

  • What is the purpose of the 'WireHead' mod created by the developer?

    -The 'WireHead' mod overrides and replaces the entire wiring system in Terraria with a custom version, significantly improving performance and enabling the computer to run at around 5000 instructions per second.

  • What is the significance of the logic gates used in building the computer?

    -The logic gates, which take in inputs and emit outputs based on simple logic, are the basic building blocks used to create the computer's various components, such as the arithmetic logic unit (ALU) and control unit.

  • What real-world instruction set was implemented in the computer?

    -The developer implemented the official RISC-V instruction set in the computer, enabling more advanced functionality compared to the custom, limited instruction set used in the initial prototype.

  • What challenges were faced during the development process?

    -Some challenges mentioned include debugging complex wiring issues, overcoming performance limitations due to lag caused by the game engine's inefficient handling of large wiring projects, and optimizing programs like Conway's Game of Life to run reasonably fast.

  • What additional tools and infrastructure were developed to support the computer?

    -The developer created an extensive software toolchain, including programmatic control of the Terraria world, a high-level Rust application driver, support for running official RISC-V instruction set compliance tests in-game, and continuous integration with automated regression testing.

  • What programs or applications were successfully run on the computer?

    -The script mentions running Pong with real-time user input, Conway's Game of Life (although at a slow speed), and a simple 3D rendering program capable of displaying a 3D world from a specific coordinate.

  • What are the developer's future plans for the project?

    -The developer mentions wanting to create a simple version of Terraria running inside the game Terraria as the next milestone for the project.

  • How can others get involved or learn more about the project?

    -The script states that everything done so far is open-source and available on public GitHub repositories linked in the description. Interested individuals with software experience can check out the repositories and potentially contribute programs using the provided Rust interface.

Outlines
00:00
πŸ–₯️ Introducing the Extraordinary Terraria Computer

The author details their remarkable achievement of creating a fully functional computer within the sandbox game Terraria. They provide background on Terraria and its wiring system, which they used to simulate the inner workings of a real computer using logic gates. The author describes the initial prototype they built, demonstrating basic operations like calculating Fibonacci numbers, and explains the fundamental components of a computer, such as the CPU, memory, and instruction set. The prototype, while limited, served as a proof of concept for the larger project.

05:03
βš™οΈ Building the Full-Scale Terraria Computer

This paragraph delves into the process of constructing the full-scale computer within Terraria. The author discusses the challenges faced, including extensive manual work due to limited copy-paste functionality, as well as the need to adhere to a real-world instruction set. After three months of active development and learning about digital logic and CPU design, the author successfully built a complete computer from scratch within the game. The sheer scale of the final computer is highlighted, and the author shares the debugging struggles, emphasizing the complexity of the project.

10:04
πŸš€ Optimizing and Running Programs on the Terraria Computer

The author addresses the issue of lag caused by Terraria's game engine not being optimized for massive wiring projects. To overcome this, they developed a mod called WireHead, which overrides and accelerates the game's wiring system, enabling the computer to run at much faster speeds. The author showcases various programs running on the computer, including Pong with real-time user input, Conway's Game of Life, and even a 3D rendering program. Future goals, such as running a simple version of Terraria within the game itself, are discussed. The author encourages others to explore the open-source project and contribute programs using the provided Rust interface.

15:07
🎡 Closing Remarks

The final paragraph serves as a closing remark, with the author thanking the viewers for watching and encouraging them to like, subscribe, comment, and explore the project's GitHub repositories. The author expresses willingness to create a detailed technical video if there is audience interest.

Mindmap
Keywords
πŸ’‘Terraria
Terraria is presented as a sandbox adventure game, offering players a 2D environment to explore, build, and engage in combat. Within this video's context, Terraria's significance extends beyond its gameplay to serve as a platform for intricate engineering feats. The creator utilized Terraria's in-game mechanics, specifically the wiring system, to simulate a fully functional computer, illustrating the game's versatility and the creative potential it harbors for players.
πŸ’‘Wiring System
The wiring system in Terraria, as explained in the video, is a game mechanic that enables players to connect devices and trigger actions, such as opening doors or activating traps. The creator's project hinges on this system, as it is ingeniously employed to create logic gates and ultimately, a complete computer within the game. This demonstrates the wiring system's complexity and flexibility, transforming a seemingly simple mechanic into the backbone of an elaborate computational simulation.
πŸ’‘Logic Gates
Logic gates are fundamental components in digital circuits, performing basic logical functions based on input signals. In the video, these gates are replicated within Terraria using the game's wiring system to simulate the binary operations of a computer. The creator's adaptation of these gates, despite Terraria's limitations, underscores the intricate relationship between basic computing principles and their creative application in unconventional environments.
πŸ’‘CPU (Central Processing Unit)
The CPU, or Central Processing Unit, is described in the video as the core of the computer simulation within Terraria. The CPU's implementation showcases the culmination of various logic gates and circuits to perform calculations and execute commands. This in-game CPU not only highlights the creator's technical prowess but also serves as a bridge connecting the abstract concepts of computer engineering with the tangible, interactive world of Terraria.
πŸ’‘ALU (Arithmetic Logic Unit)
The ALU, or Arithmetic Logic Unit, is a critical component of the CPU responsible for executing arithmetic and logical operations. In the context of the video, the ALU is a part of the Terraria-based computer, processing operations like addition as part of the broader computational tasks. The inclusion and functionality of the ALU in the game-based computer exemplify the detailed simulation of real-world computing architecture within a virtual environment.
πŸ’‘Registers
Registers in computing are small, fast storage locations within the CPU, used to hold temporary data needed during execution processes. The video illustrates how these registers are simulated within the Terraria computer to store and manipulate data, mirroring their real-world counterparts. This adaptation underscores the depth of the simulation, achieving a complex representation of computer operations within the constraints of a game.
πŸ’‘Pong Clone
The Pong clone mentioned in the video represents a simplified version of the classic video game Pong, running on the Terraria-based computer. This project serves as a tangible demonstration of the computer's capabilities, translating the abstract concept of in-game computing into a relatable and interactive experience. The Pong clone is a testament to the creator's ingenuity, bridging the gap between the rudimentary operations of the in-game computer and the execution of a fully playable game.
πŸ’‘Instruction Set
An instruction set refers to the basic commands a CPU can execute, essentially the 'vocabulary' the computer understands. In the video, the creator discusses the challenge of implementing a real-world instruction set within the Terraria computer, emphasizing the complexity of ensuring the computer's operations adhere to a standardized set of commands. This aspect of the project highlights the meticulous attention to detail and deep understanding of computer architecture required to translate real-world computing principles into the game's environment.
πŸ’‘WireHead Mod
The WireHead mod, introduced in the video, is a custom modification created by the video's author to enhance Terraria's wiring system for the purpose of the computer simulation. By optimizing the game's processing of wiring actions, this mod significantly increases the efficiency and speed of the in-game computer. The development of WireHead underscores the project's technical demands, showcasing the creator's ability to extend the game's capabilities beyond its intended boundaries to accommodate complex computational tasks.
πŸ’‘Optimization
Optimization, in the context of this video, refers to the process of refining the computer's design and the WireHead mod to improve performance and efficiency. The creator's efforts in optimization are pivotal in overcoming the inherent limitations of Terraria's engine, ensuring that the in-game computer can operate at a practical speed. This focus on optimization reflects the iterative nature of engineering projects, where continuous improvements are essential for achieving functional and effective solutions.
Highlights

As Gutenberg with his press or Eiffel with his Tower, the author has brought forth their genius upon the world by creating a Pong clone running inside the game Terraria.

Terraria is a sandbox adventure game where you explore the world and fight bosses to progress, often compared to a 2D Minecraft clone.

The author simulated the inner workings of a regular computer inside Terraria using the game's wiring system, which allows triggering tiles like doors or traps.

The basic building block of computers, logic gates, take inputs and emit outputs based on simple logic, enabling complex computations through combinations.

The author exclusively used a specific type of logic gate in Terraria, where the output emits a signal if the input triggers and the state is on.

The entirety of the in-game CPU uses only these logic gates in various convoluted configurations.

After tinkering with the logic gates, the author spent two weeks building a functional but simple prototype computer in Terraria.

The prototype demonstrated the high-level functionality of computers, executing instructions from memory, performing arithmetic, and using registers.

Building the full-scale computer took around three months of active development, during which the author learned a lot about digital logic and CPU design.

The final computer has 100 kilobytes of memory and runs much faster than the prototype, thanks to the author's custom WireHead mod that overrides and accelerates Terraria's wiring system.

The computer runs programs like Pong, Conway's Game of Life, and even a 3D rendering engine, albeit slowly due to computational limitations.

The author plans to run a simple version of Terraria inside the in-game computer as the next milestone.

The project, including the WireHead mod, Rust interface, and continuous integration setup, is open-source and available on public GitHub repositories.

The author invites others to check out the project and contribute programs using the Rust interface.

The author expresses gratitude for watching and requests likes, subscriptions, comments, and GitHub stars for support.

Transcripts
Rate This

5.0 / 5 (0 votes)

Thanks for rating: