與程式有關的遊戲三選 (2)

Written byKalanKalan
💡

If you have any questions or feedback, pleasefill out this form

This post is translated by ChatGPT and originally written in Mandarin, so there may be some inaccuracies or mistakes.

Today, we continue to introduce a few games related to programming. The focus is on TIS-100 and Turing Complete.

TIS-100

image10

This game shares a similar essence with the previously introduced game, A=B.

The gameplay revolves around a TIS-100 computer, which features a syntax resembling assembly language and consists of 12 nodes. Each node has a register, and some nodes can act as inputs and outputs, akin to the concept of GPIO. The assembly language provided in the game is a simplified version, without complex addressing modes or interrupts.

In this game, you will also solve various puzzles, but since it uses assembly language, the difficulty level varies:

  • For those with a basic understanding of assembly language: It is easier than A=B, as A=B requires solving problems within a broken syntax, while assembly language does not have that complication.
  • For those unfamiliar with assembly language: This game could be as challenging as A=B. Grasping the concepts of assembly language will take some time.

image20

All syntax-related information is covered in a PDF within the game.

The game tracks various statistics about your code, including how many times it ran, the length of the code, the number of nodes used, and more. For players who enjoy challenging themselves to find the optimal solution, this should be a delightful pastime.

There is no tutorial in this game! This presents a high barrier for players with no programming background. However, the game mechanics are quite simplified, and the number of commands and specifications you need to memorize is much less than that of actual assembly language.

The problems are not particularly difficult; for example, "Add input A and input B, then send the result to output A" or "Multiply input A and input B, then output the result." Of course, assembly language isn't insurmountable, and if you manage to learn it and successfully complete the game, you might be more skilled than half of the software engineers out there. After all, not all software engineers encounter assembly language in their work.

Turing Complete

This is a game where you build a CPU from scratch.

Your objective is to start with the most basic logic gates and progressively create a CPU using fundamental components like adders, multiplexers, and registers. After constructing the CPU, your work isn't done; you can write an instruction set for your CPU, which will ultimately turn into assembly language, allowing you to solve puzzles using the assembly language you've created.

There's a quote in the Steam trailer that I particularly like:

If you try to make such projects, unseen by others, as perfect as any human could, you'll develop skills that other professionals don't have.

Of course, the CPU depicted in the game is a vastly simplified version, both in terms of semiconductor processes and circuit design. For example, basic features like branch prediction are not implemented in the game. However, this does not hinder our understanding of how CPUs operate.

Many software engineers may not fully grasp how CPUs function unless they work in the relevant industry. If they take the time to complete all the levels in this game, they will certainly learn many things that most software engineers might not know.

The game's UI primarily utilizes a dragging method. Once you complete a logic gate component, it becomes a reusable component for later levels.

As the game progresses, the number of components increases. The circuits in later levels become more complex, requiring even more components and connections.

Turing Completeness

An important milestone in the game is achieving Turing Completeness. After completing WORKING COMPUTER, you will realize that all the circuits you painstakingly put together were aimed at this moment. This level will require you to meet several conditions:

  • Determine which operation to execute based on the bits of byte code: ADD, XOR, OR, etc.
  • Program Counter: Keep track of where the program is executing.
  • Decide whether to execute a jump (to a specific address) based on a bit: Implement six scenarios (greater than, less than, equal to, always, never).
  • Five registers.

At this point, you have essentially completed a rudimentary CPU. Although it runs entirely in software, achieving this is still quite rewarding.

Puzzle Solving

Next, the game will prompt you to write assembly language, which you can define yourself, and it will ultimately map to machine code. Subsequent levels will require you to solve puzzles using assembly language, such as calculating moduli and navigating mazes.

Final Thoughts

The essence of programming is never just the syntax itself, but the underlying logical thinking.

Many might ask, "If this is so similar to programming, why not just write code directly?" My perspective is that games can facilitate learning new concepts while maintaining a visually engaging design and a simplified environment. There's no need for extra configuration adjustments, dealing with an IDE, or learning how to use a debugger. Reducing the feedback cycle's cost is incredibly beneficial for learning.

If you found this article helpful, please consider buying me a coffee ☕ It'll make my ordinary day shine ✨

Buy me a coffee