Foreseen yet Unpredictable Invader: post-mortem #2

So, as promised, here is the second (and last) FyUI postmortem, dealing with the technical aspects of the game!

The whole game revolves around the boss's VM, which is specially studied to run a randomly-mutated code while making the game's difficulty come with the number of mutations.

Attack types

Boss and drones alike have a number of attack types/patterns:
  • A number of bullets launched straight at the player.
  • Bullets equally distributed in a circle, start angle rotating.
  • Bullets randomly distributed in a circle, with random speed. 
Boss have both "automatic"/"default" bullets, fired every 20 frames, and additional attacks launched by its code. Drones have only "default" bullets, fired every 22 frames. 

Basics about VM

Each instruction takes 4 bytes, one byte for the opcode, and the remaining for the operands.
Operands take each 1 byte, and may be unsigned integers or rationals. Their value is stored directly inside the instruction.
Many opcodes match the same instruction, some don't match anything, and the opcode 0 is a special instruction making the code's evaluation stop if all operands' value is 0. Let's call such instructions POST.
If there is no POST instruction, the boss can't regenerate (except in survival mode).

The boss' code is initially blank (only POST instructions), then mutated a bit, then a few POST instructions are added at the end of its code.
The instructions are executed sequentially, most of them after an extra delay precised as one of the instruction's operand. The script is repeated until the death (which can be temporary, since the alien can regenerate... wait... like a Timelord?)


A mutation is an inversion of one random bit of the boss' code.
The blank code is mutated a few times before the start of the game, and each time the player hits the boss.
Such mutations could have a huge effect on the game if one uses a traditional representation for numbers: swapping the most significant bit of an unsigned byte could mean a change of about half the maximum value. It would be even worse for floats. Hence the...

Alternate coding of values

The game's VM works only with one-byte values: unsigned integers and unsigned rationals.

Unsigned integers are coded in a way that the most significant part of it is not the usual most significant bit, but the number of bits set. This means 1-bit inverting mutations only have a small effect on the value, and make the mutations feel "progressive" and "coherent".

Rationals are in the [0, 1) range, and their value is merely that of a corresponding unsigned integer divided by 256.

The instruction set

In a smilar way, instructions are mostly ordered by number of bits set in the opcode.
The valid instructions are:
  • The POST instruction, matching only opcode 0, and validating/exiting the program.
  • An instruction to set the boss' life, matching opcode 1, and 2.
  • An instruction to change the boss' wings, matching opcode 4. It's purely aesthetical, and it was initially meant to change more than the wings.
  • An instruction to change the settings of the "default" bullets sent by the boss. This instruction is called with a delay.
  • An instruction to fire some bullets, without affecting the "default" bullets. This instruction is called with a delay.
  • An instruction to fire some bullets without delay.
  • An instruction to modify the speed of all upcoming bullets. No delay.
  • An instruction to change the acceleration and rotation speed of already sent bullets.
  • An instruction to change the "default" bullets sent by a specific drone (sends one if there is none). This is called with a delay. 

I hope this has been understandable and not too boring.
Anyway, you can get a super post-compo hopefully-fixed version of FyUI here!

(log in to comment)


Wow, I had no idea there was such depth to it! I wonder if it would be possible to expose more of this to the player. Maybe make the "DNA" visible. Perhaps put it at the top of the screen and allow the player to consciously shoot at specific parts of it to influence the boss's behavior.
Well, as it is now, the thing is completely deterministic (how/when you shoot at it won't change a thing to its code in the end) since I wanted to have a consistent scores.
I considered adding two weapons (SET and UNSET, which would set or unset a bit, instead of swapping it), but I don't know how it would have ended up, consistency-wise, and strategy-wise.
Sureley there are things to try out :)