Englisch
Avatar

Solra Bizna
@SolraBizna

Making a drop-in simulated computer system for games and education

SolraBizna hat 0 Fördernde.

Beschreibung

I am a big believer in the education and entertainment value of simulation. Kerbal Space Program is a high-profile example of a simplified space simulation that launched tens of thousands of real aerospace careers. Oxygen Not Included and Stationeers contain partial thermodynamic models that are great sandboxes for learning principles of industrial control. Cities: Skylines' sanded-down model of traffic flow is certainly still complex enough to model many real-world problems and solutions in traffic engineering. One of my favorite games of all time is SCRAM, an Atari 8-bit "game" that is nothing more than a simplified simulation of a nuclear reactor. Yet there isn't really a game where one can practice programming "to the metal".

Instead, we have a lot of near misses, including but not limited to:

  • OpenComputers, a mod that adds Lua-based computers to Minecraft. The utility offered by even simple scripts lit the fire in the hearts of several students I know, but the fact that it's "Lua all the way down" limits what they can learn.
  • Stationeers provides a simple microcontroller it calls IC10, programmed in something it calls MIPS. However, it's not really MIPS. Stationeers' "MIPS" is a BASIC-like operating environment with sharp limitations and whose syntax is "inspired by MIPS". It doesn't have interrupts, integers, strings, or even main memory, and no program can be longer than 128 instructions.
  • SHENZHEN I/O is themed around small-scale electronics design, built around tiny microcontrollers. No program can be more than a dozen or so instructions long, boards are impossibly cramped, and IO is extraordinarily limited. Wonderful puzzle game, as long as you're not expecting to learn much about programming a real microcontroller.
  • Kerbal Operating System, a mod for Kerbal Space Program that adds programmable computers to the game. You can automate launches, rendezvous, landing, and more. However, it can only be programmed in a language called kerboscript, which has unusual syntax and a very high-level architecture.
  • Mindustry has a (clunky, but powerful) visual scripting language you can use to control things in the game. It's suitable for simple automation tasks, but as is too often the case, program length is sharply limited and there is no main memory. You do, at least, get random-access "memory cells", which can be awkwardly loaded/stored—except that since you can't preload them, you can't use them to store complex input or a larger program.

Every game I know of that has a built-in programmable computer either drops in (and optionally sandboxes) an existing scripting language, or makes its own slightly wacky environment. I don't know of a single one that "looks like a real computer". Putting such an architecture into a game would require a lot of up-front design and implementation—work that could have gone into making the non-computer parts of the game better.

Enter Tatsui.

Tatsui is a computer system architecture. It contains a 32-bit RISC-V CPU, and is built around a bus system dubbed LoBus that would not have been out of place in the 1980's. It has all the features of a "real computer": a mainstream ISA, virtual memory, firmware, mass storage, scaffolding for an operating system. Most importantly, it's designed as a library that is easy to incorporate into a game.

Imagine an inexperienced person sitting down in front of a computer in Minecraft or Stationeers and being presented with a command line prompt much like the one in OpenComputers. They make a few toy Lua programs, maybe achieve some basic useful purpose in the game. They find that they have a taste for programming, and start seeking more interesting problems to solve, and more efficient/elegant means of solving them. They start to experiment in other languages, even compiled ones like C or Rust, in an environment where nothing can go terribly wrong. Soon they learn that even the OS is replaceable—that they can make an OS kernel of their own, or at least use an alternative made by someone else. If the game/mod author permits it, they will even find that they can replace the BIOS.

The confidence and fundamental skills they gain at every point on this path will be directly applicable to real programming on real computers—because, architecturally, Tatsui is a real computer. Wherever they go with those skills, they will carry with them the positive associations and memories from experimenting with the mechanics of programming in a fun, simulated environment.

Headline features:

  • Single RV32GC CPU (compatible with mainstream compilers, including for C/C++/Rust)
  • Up to 2GiB of system memory (but typically just a few megabytes)
  • Separate Supervisor and User modes
  • Virtual memory (Sv32 flavor)
  • LoBus expansion system, allowing custom or standard expansion cards
  • Serial I/O, if you want terminals
  • Framebuffer 2D graphics, if you want GUIs
  • SCSI-like storage and expansion device system, supporting every mass storage system imaginable (and you can boot them all)
  • Ethernet-compatible networking
  • Over- and underclocking, with power consumption and execution time tradeoffs
  • Interfaces for battery, fan, system temperature, "blinkenlights"
  • Simple but powerful serial or framebuffer console management, provided by BIOS
  • Cheap to save or clone state
  • Low effort required to incorporate into a game
  • Deterministic (same input, same output, every time—great for replays and networked games)
  • Standard (an OS kernel written for Tatsui can also work on real RISC-V computers, and vice versa)
  • Role-agnostic (one mainframe with dozens of seats, a minicomputer with several seats, a personal microcomputer, a dedicated server, a tiny embedded microcontroller; Tatsui can fit any of these roles)
  • Scale-agnostic (kilobytes? megabytes? gigabytes? kHz? MHz? GHz?)
  • Simple enough for a single person to understand the whole architecture
  • Open source (emulator, BIOS, OS)

Will not ever include:

  • CPU caches (too expensive to emulate)
  • DRAM refresh cycles (boils down to "an annoying reason your code is randomly a few cycles slower")
  • JIT (very likely to cause a game loop to hitch, also causes problems for determinism)

Me

I am a polymath who specializes in computers. I write software, much of which is Free. I maintain a few services, all of which are free. I tutor programming, frequently to people who lack the means to pay. Unfortunately, my hobbies also include having a roof over my head and food in my belly, and neither of those things are gratis.

The more that is donated to me, the more time I can spend working on Tatsui and other Free and Open Source software. I am currently stuck in a welfare trap. I recently stretched myself to the breaking point for a short-term, part-time job—and I ended up losing more money to paperwork mixups, and transportation costs to fix those mixups, than I ended up earning from the job. Even leaving that aside, I am not allowed to save money for an emergency, nor can I make investments. If I reach my income target, I will no longer need welfare.

I have PTSD as a result of abuse and neglect during my childhood. It is severe enough that the US Social Security Administration considers me unemployable. The road to recovery is long and painful, and no matter how much I improve, I will never be entirely free. In the past, I have only rarely brought up these issues in public. As I get older, I feel more and more compelled to stand up and be counted. I do so not only for my own benefit, but to encourage the millions of others who suffer invisibly to seek help.

In addition to my "flagship project", you may find the ARS interesting. It's a fictional 8-bit video game system that could have existed in the late 1980's. Its backstory is that it was created by dying electronics/miltech giant Eiling Technologies as a last-ditch attempt to remain relevant, but instead formed the nucleus of its downfall. The system was overpriced, overengineered, and undersupported. The emulator runs on Windows, Linux, macOS, and the web, and the hardware is extensively documented in a keyfabe way that may be entertaining in its own right. Unfortunately, I haven't released much software to run on it. If you want to write your own software, ars-init provides a rather nostalgic boot-up screen and very basic services.

Verknüpfte Konten

SolraBizna besitzt die folgenden Zugänge auf anderen Plattformen:

Verlauf

SolraBizna ist vor 6 Jahren beigetreten.

Einnahmen pro Woche (in US-Dollar)

Anzahl Unterstützer pro Woche