Skip to content
0:00 / 0:00

#opusmagnum#brainfuck#turingcompleteness

Opus Magnum Computer (bf interpreter)

Haiaiai

190 subscribers • 2 videos on Hallway

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • May be out of date. Uploaded 8 years ago, in an area where tools change fast.

Advanced. Deep dive for people who know the field.

52K views8 years ago1 recommendation

Computer scienceGame developmentComputation and complexityGame programming

A detailed walkthrough of a fully functioning Brainfuck interpreter built using the mechanics of the puzzle game Opus Magnum.

Embrace computation! Demo program: + + [ . - > [ [ ] ] < ] . Zoomed out demo: youtu.be/ShpMkV21uyc Inc/Dec operation in detail: youtu.be/gA3IZy_Yc0s So I build a computing thingy, takes Brainfuck commands (except input as explained) and does them to poor little molecules. Took around 60h, half of that shifting things around to finally avoid all those arms and atoms colliding. (Sorry for signal noise when talking, not really a casting setup here. Also I'm astounded how bored I sound, but that's just the way I talk) Parts: Inputs and Outputs Overview over machine Internal setup Demo program Program end and final words Regarding execution speed time: Cycles per command: 109 Skip time: 2 instructions skipped per full command cycle, beginning on same cycle as loop command was decoded; leaving loop skipping uses up one more turn, as only after trying to enter code to the skip system the fully skipped code is grabbed for transport back. So skipping over [ - ] takes 2 turns. If you're willing to make cycles-per-turn longer you might make 3 skips per turn; but you need cycles where the skipping is inactive for the code feeding and returning. Further comments about building this: - I started with the memory operations. I would now build them further out, because they are really fast, but everything else now has to grab the current cell sideways, pushing the data to the output was really harder than it should have been. - Went well: Inc & Dec, 6 cycles per bit, I think that's good. Both are basically the same, carry bit just handled the other way - Went well: Output core op, 4 cycles per bit. Although it took me longer than inc/dec to get right - Really nice: having both forward and backward skipping work on the same action token, which then handles the counting... just nice - Bad, related to last point: that made the inner area under the action token really crowded, took a while and introduced some wait times - Command token: stayed with that layout from the start, changed encoding once - General: Stacks worked really well, in SpaceChem I had to do some tricks for that - Useful to keep some areas clear of stuff to be able to move the long code chains by rotation

Why it's here

1 person recommends this

What people say. Recommended as a creative implementation of a computer and interpreter inside Opus Magnum.

u/leo3065in r/programming • Recommends

On “Game in which you develop your own CPU”

Because of pipelines? Gonna make those parallel processing working. But yeah many games by Zach is like processors with strange architecture and some gimmick thrown in. Like, TIS-100, Shenzhen I/O and Exapunks are straight up programming, and someone made a 4-bit version of brainfuck interpreter in SpaceChem (link to this video), who also made similar thing in Opus Magnum (link to this video). Hell, someone even built TIS-100 in Infinifactory, which are both games by Zachtronics.