logging in or signing up 2005 11 18 Corewar Simeone Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINTLite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 54 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: February 12, 2008 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript The Tao of Corewar: The Tao of Corewar by datagram (omghai2u)Core-what?: Core-what?History: History Created and extended by A. K. Dewdney in Scientific American’s “Computer Recreations” articles from 1984-1987. Two coding standards: ‘88 and ‘94 rules Technically more exist, but these are the popular ones. Still popular; mostly European players Currently supported on all platforms The Core: The Core Continuous, looping array of instructions. Basic unit of memory: 1 instruction Execution is taken in turns between programs. (programs DO NOT compete for execution time) All instructions take 1 turn to execute. After executing, a process moves to the next instruction in the core, unless told to jump to another address or is killed.Relative Addressing: Relative Addressing All addressing is relative either to: The executing instruction itself An instruction that the executing instruction points to (not as complicated as it sounds…) In a core of 8000 instructions, -1 = 7999, 10 = 8010 More on addressing methods and modifiers later.Anatomy of an Instruction : Anatomy of an Instruction [OpCode] [A-field], [B-Field] Examples: mov 0, 1 spl @10, {0 (more on @, {, etc. later…) jmp 10The Instructions, Part 1: The Instructions, Part 1 MOV – Move a-field instruction to b-field location. ADD – Add a-field to b-field. SUB – Subtract a-field from b-field. MUL – Multiply a-field by b-field. DIV – Divide a-field by b-field. MOD – Modulus a-field by b-field. JMP – Jump to a-field location. JMZ – Jump to a-field location, if b-field is zero. JMN – Jump to a-field location if b-field is not zero. DJN – Jump to a-field location if b field is zero, but first PRE-DECREMENT b-field. (Complex!) SPL – Split a new process to a-field location.The Instructions, Part 2: The Instructions, Part 2 CMP – Same as SEQ but for ’88 (compatible with ’94) SEQ – Skip if a-field is equal to b-field SNE – Skip if a-field is not equal to b-field SLT – Skip if a-field is less than b-field Can be skip if greater than, too; reverse the values. NOP – No operation (do nothing) DAT – Data. Illegal instruction; kills the process. LDP – Load from P-Space STP – Store to P-Space More on P-Space in a while…Deadly Instructions: Deadly Instructions How do programs die? All processes in a program die. How do processes die? Executing illegal instructions. What are illegal instructions? Any DAT instruction: dat 0, 0 Modulus (MOD) by 0: mod #0, #1000 Division (DIV) by 0: div #-4569, #0Imp: Imp Our first warrior! What does Imp do? (shout it out, I don’t give a shit) Note relative addressing. Let’s look at Imp in the core… (go go demo) ;redcode-94 ;name Imp ;author datagram mov 0, 1 endDwarf: Dwarf Another warrior, except this time it has the potential for victory. Dwarf was the first bomber-type warrior. Note the use of advanced addressing methods. Dwarf in the core! Also, improved dwarf step sizes. ;redcode-94 ;name Dwarf ;author datagram add #4, 3 mov 2, @2 jmp -2 dat #0, #0 endDwarf, Step by Step 1: Dwarf, Step by Step 1 Notes: @ = b-field indirect; # = a literal number. Red = Currently executing; Bold = Last instruction’s changes. -------------------------------------------------------- 0 add #4, 3 ; execution begins here 1 mov 2, @2 ; Add #4 to instruction +3’s b-field 2 jmp -2 3 dat #0, #0 -------------------------------------------------------- -1 add #4, 3 0 mov 2, @2 ; next instruction 1 jmp -2 ; Move the instruction at +2 to the 2 dat #0, #4 ; location pointed to be the +2’s b-field --------------------------------------------------------Dwarf, Step by Step 2: Dwarf, Step by Step 2 Notes: @ = b-field indirect; # = a literal number. Red = Currently executing; Bold = Last instruction’s changes. -------------------------------------------------------- -2 add #4, 3 ; Jump back 2 instructions. -1 mov 2, @2 ; -, 0 jmp -2 ; | 1 dat #0, #4 ; ---, The B-field of MOV points here. 2 … | 3 … | +4 4 … | 5 dat #0, #4 ; ---’ The B-field of DAT points here.More complex, you say?: More complex, you say? Addressing Methods In Dwarf, you saw @, #, etc. What do they mean? Methods are used to: Modify code during and after execution Reference instructions indirectly Reference a/b fields of instruction indirectly Instruction Modifiers MOV moves one instruction to another location, right? Many instructions seem to have only one method of working, but can have appended modifiers. What if we want to move only a or b fields of instructions? What if we want to add or subtract something to an a-field of an instruction, not the default b-field?Addressing Methods: Addressing Methods $ - Direct. (The $ is optional.) # - Immediate. * - A-field indirect. { - A-field indirect with pre-decrement. } - A-field indirect with post-increment. @ - B-field indirect. < - B-field indirect with pre-decrement. > - B-field indirect with post-increment.Addressing Methods, Examples: Addressing Methods, Examples 0 nop 0, >1 1 nop 0, @5 2 nop {1, <0 3 nop 4, }3 4 nop *1, }0 5 nop #0, 5 6 nop 0, 0 end ; Line 0 ; B-field of +1 (1) increases AFTER execution! ; Line 2 ; A-field of +1 (3) decreases BEFORE execution! ; B-field of +0 (2) decreases BEFORE execution! ; Line 3 ; A-field of +3 (6) increases AFTER execution. ; Line 4 ; A-field of +0 (4) increases after execution. Easy…right? Instruction Modifiers: Instruction Modifiers .A A-field of source into A-field of destination. .B B-field of source into B-field of destination. .AB A-field of source into B-field of destination. .BA B-field of source into A-field of destination. .F Both fields of source into same fields of destination. .X Both fields of source into opposite fields of destination. .I Moves the whole source instruction to destination.Instruction Modifiers, Examples: Instruction Modifiers, Examples mov.ba 0, 1 ; Move b-field of 0 to a-field of +1 nop 0, 0 ; <- becomes: nop 1, 0 add.x #5, 1 ; Add, in reverse order, a and b fields to +1 nop #-1, #-2 ; <- becomes: nop #0, #3 ; Why does it add 5 and 1? Any #n, when ; referenced directly, acts as a 0 address. mov.f 1, 2 ; Move both a and b fields of +1 to the dat #1, 7 ; same fields in line +2 nop #3, #4 ; <- becomes: nop #1, 7 ; Note: It did NOT change the instruction Meet SPL: Meet SPL Multi-tasking! SPL: Create a new process executing at a-field location of SPL. SPL [destination] spl 1 … spl #0 … spl @0, 10 … spl 1, <1000 Like JMP, but SPL jumps AND continues execution at the next instruction. Important: Each program has it’s own process queue. Your program will split execution time between your processes. Process Queuing: Process Queuing Program A 3 processes Program B 1 process. Program A, process 1, Program B, process 1, Program A, process 2, Program B, process 1, Program A, process 3, Program B, process 1, Program A, process 1, Program B, process 1, SPL in core example: SPL 0 ; Process 1 MOV 0, 1 ------------------------------------ SPL 0 ; Process 2 MOV 0, 1 ; Process 1 ------------------------------------ SPL 0 ; Process 3 MOV 0, 1 ; Process 2 MOV 0, 1 ; Process 1P-Space: P-Space A personal storage space that persists between rounds. Only numbers can be stored in p-space! STP – Store a number in p-space. LDP – Load a number from p-space. PIN – Programs with the same PIN share p-space. P-warriors! Using p-space to store strategy information and switch strategies if they are losing repeatedly. Brainwashing! Getting enemies to execute STP instructions and trash their p-space with junk data. Can crash some p-warriors! Can be done by you if PIN numbers are identical.Rock, Paper, Scissors: Rock, Paper, Scissors Very basic look at strategy: Paper > Rock > Scissors > Paper Paper = Replicator (aka Silk) Rock = Bomber (aka Stone) Scissors = Scanners, Vampire Why does paper beat stone? Why does stone beat scanner? Why does scanner beat paper?Stones (Bombers): Stones (Bombers) org sGo step EQU 551 bomb dat {2667, <5334 sGo spl #0, #step mov bomb, >-1 add.ab #step, -2 djn -2, <-3 How it works:Papers (Replicators): Papers (Replicators) pBoot spl 1, {1000 spl 1, {2000 spl 1, {3000 pls mov plb, >8 plc mov pls, <pln pln spl @pln, >-1356 mov plb, <pln mov plb, <-1000 mov plb, >200 jmn.f @0, >pls plb dat <2667, <5334 How it works:Scanners: Scanners I can’t write any simple scanners : ( Want to see my pimped out tournament submission? Complex, but shouldn’t be too hard for the troopers in the audience who’ve followed the presentation so far. The basic idea goes: + compare two locations + are these two locations different? + if so, it is very likely that you found enemy code + figure out which of the two you want to bomb + bomb that bitch like Baghdad. (too racy?)Guerrilla Tactics: Guerrilla Tactics Bootstrapping Copying away a piece of program code from your original code. Used to leave a large decoy for scanners to find, as well as create a smaller block of executing code to make it harder for scanners to find you. Core coloring Making bombs visible to scanners, so that scanners bomb useless locations. Dodging A program that looks for bombed locations and copies itself there. The idea is that bombers do not bomb the same location repeatedly in a short period of time, so this is a safe location. Q-Scanning A fast scan routine used as the start point of a warrior. Aims to get lucky and hit enemy code. Optimized q-scans can get 8-9% wins on their own.Any questions?: Any questions?The DC213 Tournament: The DC213 Tournament Given enough interest…I’ll run a tournament. Make a warrior, standard settings: Rounds: 250 Core size: 8000 Cycles: 80000 Processes: 8000 Code Length: 100 Min. Distance: 100 P-space: Disabled All entries in by January 5th, 2006.More info…: More info… http://corewar.info Christian Schmidt’s (Fizmo) Corewar page. Many great beginner links and guides. Information on evolving warriors. rec.games.corewar Google group with plenty of information. http://koth.org King of the Hill homepage. http://corewar.co.uk John Metcalf’s Corewar page.The End.: The End. You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
2005 11 18 Corewar Simeone Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINTLite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 54 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: February 12, 2008 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript The Tao of Corewar: The Tao of Corewar by datagram (omghai2u)Core-what?: Core-what?History: History Created and extended by A. K. Dewdney in Scientific American’s “Computer Recreations” articles from 1984-1987. Two coding standards: ‘88 and ‘94 rules Technically more exist, but these are the popular ones. Still popular; mostly European players Currently supported on all platforms The Core: The Core Continuous, looping array of instructions. Basic unit of memory: 1 instruction Execution is taken in turns between programs. (programs DO NOT compete for execution time) All instructions take 1 turn to execute. After executing, a process moves to the next instruction in the core, unless told to jump to another address or is killed.Relative Addressing: Relative Addressing All addressing is relative either to: The executing instruction itself An instruction that the executing instruction points to (not as complicated as it sounds…) In a core of 8000 instructions, -1 = 7999, 10 = 8010 More on addressing methods and modifiers later.Anatomy of an Instruction : Anatomy of an Instruction [OpCode] [A-field], [B-Field] Examples: mov 0, 1 spl @10, {0 (more on @, {, etc. later…) jmp 10The Instructions, Part 1: The Instructions, Part 1 MOV – Move a-field instruction to b-field location. ADD – Add a-field to b-field. SUB – Subtract a-field from b-field. MUL – Multiply a-field by b-field. DIV – Divide a-field by b-field. MOD – Modulus a-field by b-field. JMP – Jump to a-field location. JMZ – Jump to a-field location, if b-field is zero. JMN – Jump to a-field location if b-field is not zero. DJN – Jump to a-field location if b field is zero, but first PRE-DECREMENT b-field. (Complex!) SPL – Split a new process to a-field location.The Instructions, Part 2: The Instructions, Part 2 CMP – Same as SEQ but for ’88 (compatible with ’94) SEQ – Skip if a-field is equal to b-field SNE – Skip if a-field is not equal to b-field SLT – Skip if a-field is less than b-field Can be skip if greater than, too; reverse the values. NOP – No operation (do nothing) DAT – Data. Illegal instruction; kills the process. LDP – Load from P-Space STP – Store to P-Space More on P-Space in a while…Deadly Instructions: Deadly Instructions How do programs die? All processes in a program die. How do processes die? Executing illegal instructions. What are illegal instructions? Any DAT instruction: dat 0, 0 Modulus (MOD) by 0: mod #0, #1000 Division (DIV) by 0: div #-4569, #0Imp: Imp Our first warrior! What does Imp do? (shout it out, I don’t give a shit) Note relative addressing. Let’s look at Imp in the core… (go go demo) ;redcode-94 ;name Imp ;author datagram mov 0, 1 endDwarf: Dwarf Another warrior, except this time it has the potential for victory. Dwarf was the first bomber-type warrior. Note the use of advanced addressing methods. Dwarf in the core! Also, improved dwarf step sizes. ;redcode-94 ;name Dwarf ;author datagram add #4, 3 mov 2, @2 jmp -2 dat #0, #0 endDwarf, Step by Step 1: Dwarf, Step by Step 1 Notes: @ = b-field indirect; # = a literal number. Red = Currently executing; Bold = Last instruction’s changes. -------------------------------------------------------- 0 add #4, 3 ; execution begins here 1 mov 2, @2 ; Add #4 to instruction +3’s b-field 2 jmp -2 3 dat #0, #0 -------------------------------------------------------- -1 add #4, 3 0 mov 2, @2 ; next instruction 1 jmp -2 ; Move the instruction at +2 to the 2 dat #0, #4 ; location pointed to be the +2’s b-field --------------------------------------------------------Dwarf, Step by Step 2: Dwarf, Step by Step 2 Notes: @ = b-field indirect; # = a literal number. Red = Currently executing; Bold = Last instruction’s changes. -------------------------------------------------------- -2 add #4, 3 ; Jump back 2 instructions. -1 mov 2, @2 ; -, 0 jmp -2 ; | 1 dat #0, #4 ; ---, The B-field of MOV points here. 2 … | 3 … | +4 4 … | 5 dat #0, #4 ; ---’ The B-field of DAT points here.More complex, you say?: More complex, you say? Addressing Methods In Dwarf, you saw @, #, etc. What do they mean? Methods are used to: Modify code during and after execution Reference instructions indirectly Reference a/b fields of instruction indirectly Instruction Modifiers MOV moves one instruction to another location, right? Many instructions seem to have only one method of working, but can have appended modifiers. What if we want to move only a or b fields of instructions? What if we want to add or subtract something to an a-field of an instruction, not the default b-field?Addressing Methods: Addressing Methods $ - Direct. (The $ is optional.) # - Immediate. * - A-field indirect. { - A-field indirect with pre-decrement. } - A-field indirect with post-increment. @ - B-field indirect. < - B-field indirect with pre-decrement. > - B-field indirect with post-increment.Addressing Methods, Examples: Addressing Methods, Examples 0 nop 0, >1 1 nop 0, @5 2 nop {1, <0 3 nop 4, }3 4 nop *1, }0 5 nop #0, 5 6 nop 0, 0 end ; Line 0 ; B-field of +1 (1) increases AFTER execution! ; Line 2 ; A-field of +1 (3) decreases BEFORE execution! ; B-field of +0 (2) decreases BEFORE execution! ; Line 3 ; A-field of +3 (6) increases AFTER execution. ; Line 4 ; A-field of +0 (4) increases after execution. Easy…right? Instruction Modifiers: Instruction Modifiers .A A-field of source into A-field of destination. .B B-field of source into B-field of destination. .AB A-field of source into B-field of destination. .BA B-field of source into A-field of destination. .F Both fields of source into same fields of destination. .X Both fields of source into opposite fields of destination. .I Moves the whole source instruction to destination.Instruction Modifiers, Examples: Instruction Modifiers, Examples mov.ba 0, 1 ; Move b-field of 0 to a-field of +1 nop 0, 0 ; <- becomes: nop 1, 0 add.x #5, 1 ; Add, in reverse order, a and b fields to +1 nop #-1, #-2 ; <- becomes: nop #0, #3 ; Why does it add 5 and 1? Any #n, when ; referenced directly, acts as a 0 address. mov.f 1, 2 ; Move both a and b fields of +1 to the dat #1, 7 ; same fields in line +2 nop #3, #4 ; <- becomes: nop #1, 7 ; Note: It did NOT change the instruction Meet SPL: Meet SPL Multi-tasking! SPL: Create a new process executing at a-field location of SPL. SPL [destination] spl 1 … spl #0 … spl @0, 10 … spl 1, <1000 Like JMP, but SPL jumps AND continues execution at the next instruction. Important: Each program has it’s own process queue. Your program will split execution time between your processes. Process Queuing: Process Queuing Program A 3 processes Program B 1 process. Program A, process 1, Program B, process 1, Program A, process 2, Program B, process 1, Program A, process 3, Program B, process 1, Program A, process 1, Program B, process 1, SPL in core example: SPL 0 ; Process 1 MOV 0, 1 ------------------------------------ SPL 0 ; Process 2 MOV 0, 1 ; Process 1 ------------------------------------ SPL 0 ; Process 3 MOV 0, 1 ; Process 2 MOV 0, 1 ; Process 1P-Space: P-Space A personal storage space that persists between rounds. Only numbers can be stored in p-space! STP – Store a number in p-space. LDP – Load a number from p-space. PIN – Programs with the same PIN share p-space. P-warriors! Using p-space to store strategy information and switch strategies if they are losing repeatedly. Brainwashing! Getting enemies to execute STP instructions and trash their p-space with junk data. Can crash some p-warriors! Can be done by you if PIN numbers are identical.Rock, Paper, Scissors: Rock, Paper, Scissors Very basic look at strategy: Paper > Rock > Scissors > Paper Paper = Replicator (aka Silk) Rock = Bomber (aka Stone) Scissors = Scanners, Vampire Why does paper beat stone? Why does stone beat scanner? Why does scanner beat paper?Stones (Bombers): Stones (Bombers) org sGo step EQU 551 bomb dat {2667, <5334 sGo spl #0, #step mov bomb, >-1 add.ab #step, -2 djn -2, <-3 How it works:Papers (Replicators): Papers (Replicators) pBoot spl 1, {1000 spl 1, {2000 spl 1, {3000 pls mov plb, >8 plc mov pls, <pln pln spl @pln, >-1356 mov plb, <pln mov plb, <-1000 mov plb, >200 jmn.f @0, >pls plb dat <2667, <5334 How it works:Scanners: Scanners I can’t write any simple scanners : ( Want to see my pimped out tournament submission? Complex, but shouldn’t be too hard for the troopers in the audience who’ve followed the presentation so far. The basic idea goes: + compare two locations + are these two locations different? + if so, it is very likely that you found enemy code + figure out which of the two you want to bomb + bomb that bitch like Baghdad. (too racy?)Guerrilla Tactics: Guerrilla Tactics Bootstrapping Copying away a piece of program code from your original code. Used to leave a large decoy for scanners to find, as well as create a smaller block of executing code to make it harder for scanners to find you. Core coloring Making bombs visible to scanners, so that scanners bomb useless locations. Dodging A program that looks for bombed locations and copies itself there. The idea is that bombers do not bomb the same location repeatedly in a short period of time, so this is a safe location. Q-Scanning A fast scan routine used as the start point of a warrior. Aims to get lucky and hit enemy code. Optimized q-scans can get 8-9% wins on their own.Any questions?: Any questions?The DC213 Tournament: The DC213 Tournament Given enough interest…I’ll run a tournament. Make a warrior, standard settings: Rounds: 250 Core size: 8000 Cycles: 80000 Processes: 8000 Code Length: 100 Min. Distance: 100 P-space: Disabled All entries in by January 5th, 2006.More info…: More info… http://corewar.info Christian Schmidt’s (Fizmo) Corewar page. Many great beginner links and guides. Information on evolving warriors. rec.games.corewar Google group with plenty of information. http://koth.org King of the Hill homepage. http://corewar.co.uk John Metcalf’s Corewar page.The End.: The End.