|
IntroductionCorewars is a game about writing viruses (aka. warriors) in assembly (specifically Redcode). Redcode is a RISC assembly with niche features like multithreading and relative addressing. Your warrior is then loaded into the core (a VM, usually pMARS) together with another warrior. The warriors compete with each other to trick the other into terminating themselves. The most reliable way to accomplish this is to modify the opponents memory (i.e. instructions or jump addresses). Each warrior fights against multiple other warriors to eventually be rated and get a rank on the hill (or not). Get the first rank to become king of the hill! Getting StartedLearn Redcode, there’s the ’88 standard and the ’94 draft with some cool features. The ’94 draft has never been finalized, but it’s effectively standardised as a reference implementation in pMARS. The best place to start with Redcode is this Beginner’s guide for ’94. If you prefer cheat-sheet, you can use this redcode reference. You can read up on some basic strategies on the Corewars tips page. pMARSpMARS is the reference implementation of the ’94 draft. It’s open source and comes for all major operating systems, most have it in their package manager, or you can compile the source yourself. You can use it to have warriors fight each other (usually you do multiple battles with randomized starting positions in the core). If you call it with the -k option it compiles your warriors into KOTH format (which you need to send a warrior to a hill). It also features the cbd debugger, you can either enter it during a battle or by using the -e option. ![]() Use “help” to get a list of commands. “skip” executes a single command and outputs the next command. Add an integer to execute more than one command (e.g. “skip 3” does three steps). “list” allows you to look at core addresses, “list 5” looks at the 5th command. You can use ranges like “list 0,100” to list a range of addresses. It also supports relative addressing (remember, all addresses are relative). Say you want to check what’s at address two:
Now where does -102 point to? Check it like this:
We subtract 102 from 2 and end up in -100, since the core size is set to 8000, that’s 7900. Type “trace 5” to put a trace (breakpoint) on 5, then type “go” to have pMARS run until just before the next execution of the command at address 5. StrategiesThere’s many strategies for Corewars warriors. The most popular ones are called stone/paper/scissor as they tend to beat each other much like in the popular game. Check out the Corewar Strategy Guide for a deeper dive. Choosing a Hill to die onUsually you upload your warrior by sending an email to a hill. There’s several hills with various rule sets. ’88 hills are very limited, no multithreading and the lack of pspace mean your warriors are somewhat simple minded. Regular hills limit your warrior size to 100 instructions, which is a lot and easy to get lost into. For beginners I recommend to use a smaller hill like tiny or nano. Nano limits your warrior to 5 instructions, so you have a good chance of understanding what’s happening. Sadly, nano hills are usually dominated by evolved warriors, so warriors created by hand don’t stand much of a chance. Tiny limits you to 20 instructions, there’s still some evolved warriors around but they’re not as dominant as on the nano hills. Tiny hills also allow more elaborate warriors such as vampires. See this guide for info on the email format. Additional reading |