Write Only Log for 2026 - osric.uk

Core wars

Introduction

Thinking about core wars. No idea if this is anything like the original game, but the game I want goes something like:

Take a chunk of linear memory, an instruction set, and a number of active read heads. Every tick each read head atomicly reads and executes the induction at its current location. Instructions can have one of a number of effects: Change the value of the current location, change the current location, store a value in a register, create a new read head, delete the current read head.

Players write instruction sequences that are written into memory. The object of the game is to have your read head as last one standing.

Details

  • Memory is the surface of a torus (that is, a square joined top to bottom and side to side)
  • Read heads are tagged as owned by a player. The read head from a "create a read head" instruction is owned by the owner of the read head that executes the instruction. (Instructions in memory aren't owned)
  • All values are 8 bit unsigned integers. All maths is mod 256.
  • Still thinking about registers for read heads. Something about being able to "build" or "earn" more (or taking "damage" and losing one?)

So. I've typed in (most of) another copy of clox from Crafting Interpreters (just need to do the optimisations). What's next?

  • Arrays/Lists (dynamic, numeric indexed). Can mostly fake it with objects, but language support would be nice.

  • Try/catch/throw, or some kind of runtime error handling.

  • Standard library. At least string functions (length, split, char at) and IO (both files and network). Exposing basic maths maybe. Graphics?

  • Language server, for format and syntax errors as mvp. Eventually self hosting, but vibe coding something that works in c# to start with.

  • Compiler, either a lox compiler or a C compiler. C compiler is bigger, but lox compiler needs a runtime (which I really don't want to write in assembler).

I think language server is fairly high priority, so I can start writing in Lox without going crazy. Which leads to the last point:

  • A project. The headline here is "browser", but that breaks down into a bunch of sub projects - fetch, html parse, css parse, JavaScript engine, DOM, document render, UI, text mode or gui.

Anyway.

Time for actual design!

I want calls like string.length and string.split(",") to work. This means handling the dot operator, or maybe updating OP_INVOKE.

Code like var x = string.split; x(","); should work, even if its a bit silly. That means updating OP_GET_PROPERTY.

Is length a field or a method? If it's a method, it will need brackets when called.

To remember your current position in the blog, this page must store some data in this browser.

Are you OK with that?