Re:Notch's next game is an MMO
by someone13 on Tuesday April 03, 2012 @06:59PM
(#3795235)
It's not quite as bad as it would be in a program other than an emulator, granted, but I can't imagine that it's easy to notice a bug in a 200-character line of:
And so on. It just seems like some sort of code generation would be much easier.
[ Parent
| on HN ]
That kind of code generation is unlikely to exist. Each line of that code has its own specific purpose, it's not some copy pasta. And surprisingly, it should be trivial to test it! there are no conditions of edge cases apart from the conditional instructions. As long as you test for ranges and off by ones, there's no space for mistakes really. I'd take that kind of code over usual "business logic" any time :-)
Nonsense! Look at the code again. There are a lot of repeated motifs, like the things that fetch from memory and increment the program counter. It cries out to be partially automated. If nothing else, there has got to be a more human-readable equivalent to all that bit-masking and offset-adding.
Code generation doesn't need to be heavyweight.
Even some one-line functions or macros would make that code much more compact and readable.
Off by one errors, maybe we'll even bring back the golden age of buffer overflow exploits, emergent realistic hacking gameplay mechanics, Notch you're a genius...
Re:Notch's next game is an MMO
by kingatomic on Wednesday April 04, 2012 @10:16AM
(#3797660)
Part of the battle system could be causing segfaults in rival ship computers.
You cannot really do code-generation when all the lines have meaningful differences. What you saw was very likely the most compact representation of the VM -- any other form would likely be just as bad.
This is true, but it should be easy enough to make a script that can pack/unpack the code as needed.
Most likely when you have a bug in something like this it will be isolated to one specific instruction. So you can just zoom in on the bit you need.
If you followed the standard Java practice for this you would probably have an Instruction class that inherited from several base classes and that would make your project very large and difficult to navigate indeed.