Live data from Hacker News

Two Programs Enter, One Program Leaves

codinghorror.com

11–20 of 38 posts

Re: Two Programs Enter, One Program Leaves

#11
post #2

What happens if the instruction pointer for, say, process A, steps into the code space for another process, B? Does the simulator treat it as an illegal instruction causing A to lose? Or does process A continue, but executing B's code?

The processes are all in the same code space; there's nothing distinguishing process A's instructions and process B's instructions, so process A would continue executing code created by process B. Some Corewar programs ("vampires") use this to hijack their opponents.

Re: Two Programs Enter, One Program Leaves

#12
post #9
post #8

Back in the day I tried applying genetic algorithms to corewars as a high school science fair project. I lost. They had no idea what was talking about. Early lesson in the importants of communicating technical ideas.

Oh, you lost the science fair . How did your code perform in battle?

The evolved warriors weren't all that impressive either.

Really required a large number of generations, which my poor turbo pascal skills or lack of hardware didn't really provide. I wonder if I can find that code on a floppy somewhere...

Re: Two Programs Enter, One Program Leaves

#15
post #2

What happens if the instruction pointer for, say, process A, steps into the code space for another process, B? Does the simulator treat it as an illegal instruction causing A to lose? Or does process A continue, but executing B's code?

I think it treats it as a legal instruction. What I don't get is the replicator strategy. How does replicating yourself help not die? Even if you replicate yourself to all the memory except one address -- but that one address is where your IP is you're screwed. It seems like repairing yourself and attacking the opponent are the only feasible strategies -- at least if I understand correctly.

Replicators split into multiple processes, each with its own IP. A program isn't considered dead until all its processes are killed. If one of its processes stumbles across a bad address, the others aren't affected.

Re: Two Programs Enter, One Program Leaves

#16
post #2

What happens if the instruction pointer for, say, process A, steps into the code space for another process, B? Does the simulator treat it as an illegal instruction causing A to lose? Or does process A continue, but executing B's code?

I think it treats it as a legal instruction. What I don't get is the replicator strategy. How does replicating yourself help not die? Even if you replicate yourself to all the memory except one address -- but that one address is where your IP is you're screwed. It seems like repairing yourself and attacking the opponent are the only feasible strategies -- at least if I understand correctly.

That is what the SPL instruction is for: the program copies its preferably short code to some random location and then splits its execution to continue with both. You are only dead once your last execution pointer hits an illegal instruction.

Re: Two Programs Enter, One Program Leaves

#17
post #15

Earlier quoted context omitted.

I think it treats it as a legal instruction. What I don't get is the replicator strategy. How does replicating yourself help not die? Even if you replicate yourself to all the memory except one address -- but that one address is where your IP is you're screwed. It seems like repairing yourself and attacking the opponent are the only feasible strategies -- at least if I understand correctly.

Replicators split into multiple processes, each with its own IP. A program isn't considered dead until all its processes are killed. If one of its processes stumbles across a bad address, the others aren't affected.

Ah OK, didn't read carefully enough. Thanks.
Post reply on HN