Multi-Maniacs

In preparation for my evolving challange at latest and very exciting round of the corewars tournament, I have been gathering some stuff together.

How many combinations of warrior can you have in just eight instructions? Well, lets work out how many combinations of opcodes, modifiers and addressing modes there are in a single instruction first:

  1. Multi maniac has some unique conditions. There is no SPL instruction.
  2. Therefore, there are 18 instructions, 7 modifiers, 8 addressing modes for the a operand and 8 addressing modes for the b operand.
  3. So there are 18*7*8*8 combinations of opcode, modifier and addressing modes; that is 8064 combinations.
  4. However, not all combinations of opcode and modifier make sense. Some combinations of opcode/modifier don't affect one or more operands (but if the operand is a pre-decrement or post-increment, it still has to be evaluated). Trust me, the real number is approximately 6000 odd. I have a lookup table that gets this number exact. Thing is, I guessed that only 4000 would make sense, and I used the approximation in my maths below; the idea that there is actually more obscure combinations possible would make the results below even more staggering
  5. Ok, so there is approximately 4000 codes possible in an instruction. There is also the value of the operands to consider. In the Multi-maniac tournament, the core-size is 8000. With both operands, there are therefore 4000*8000*8000 combinations per instruction. That is 256000000000.
  6. Now it is worth stressing at this point that my 4000 approximation is convienient yet shoddy. There are approximately a little over 4000 executable combinations in corewars, without SPL nor pspace. Other combinations are aliased to one of these instructions: for example, SPL.AB is treated as SPL.F by the MARS. However, to the SEQ.I and SNE.I instructions, SPL.AB and SPL.F are still quite different! So, maybe, I ought to be counting the full 8064 combinations after all.. aghhh, my head is hurting!
Ok, now to work out how many combinations of warrior there are in just eight lines. It took Joonas a long time to convince me that with eight instructions, there were ^8 combinations instead of just *8. Furthermore, the warrior can start on any line, so there are a further *8 combinations. That is ((4000*8000*8000)^8)*8 combinations. (When I was working on the premise of ((4000*8000*8000)*8)*8 combinations, I was all hopeful I could 'brute force' this game with a few boxes; after all, the result was only 44 bits.. ;-))
And the answer is:

147573952589676412928000000000000000000000000000000000000000000000000000000000000000000000000

Just for fun I recalculated with the full 8064 combinations: 40265577447197132975488474761776769470130290688000000000000000000000000000000000000000000000000

If you spot any major flaws, or just want to chat about corewars and MARs, you can contact me! "varfar at yahoo dot co (and dot the country code for Britain)".