The Tao of Corewar - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

The Tao of Corewar

Description:

... location if b field is zero, but first PRE-DECREMENT b-field. ... A fast scan routine used as the start point of a warrior. Aims to get lucky and hit enemy code. ... – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 31
Provided by: dc29
Category:
Tags: corewar | scan | tao

less

Transcript and Presenter's Notes

Title: The Tao of Corewar


1
The Tao of Corewar
  • by datagram
  • (omghai2u)

2
Core-what?
3
History
  • Created and extended by A. K. Dewdney in
    Scientific Americans 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

4
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.

5
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.

6
Anatomy of an Instruction
  • OpCode A-field, B-Field
  • Examples
  • mov 0, 1
  • spl _at_10, 0 (more on _at_, , etc. later)
  • jmp 10

7
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.

8
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

9
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, 0

10
Imp
  • Our first warrior!
  • What does Imp do?
  • (shout it out, I dont give a shit)
  • Note relative addressing.
  • Lets look at Imp in the core (go go demo)
  • redcode-94
  • name Imp
  • author datagram
  • mov 0, 1
  • end

11
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, _at_2
  • jmp -2
  • dat 0, 0
  • end

12
Dwarf, Step by Step 1
  • Notes _at_ b-field indirect a literal
    number.
  • Red Currently executing Bold Last
    instructions changes.
  • --------------------------------------------------
    ------
  • 0 add 4, 3 execution begins here
  • 1 mov 2, _at_2 Add 4 to instruction 3s b-field
  • 2 jmp -2
  • 3 dat 0, 0
  • --------------------------------------------------
    ------
  • -1 add 4, 3
  • 0 mov 2, _at_2 next instruction
  • 1 jmp -2 Move the instruction at 2 to the
  • 2 dat 0, 4 location pointed to be the 2s
    b-field
  • --------------------------------------------------
    ------

13
Dwarf, Step by Step 2
  • Notes _at_ b-field indirect a literal
    number.
  • Red Currently executing Bold Last
    instructions changes.
  • --------------------------------------------------
    ------
  • -2 add 4, 3 Jump back 2 instructions.
  • -1 mov 2, _at_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.

14
More complex, you say?
  • Addressing Methods
  • In Dwarf, you saw _at_, , 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?

15
Addressing Methods
  • - Direct. (The is optional.)
  • - Immediate.
  • - A-field indirect.
  • - A-field indirect with pre-decrement.
  • - A-field indirect with post-increment.
  • _at_ - B-field indirect.
  • lt - B-field indirect with pre-decrement.
  • gt - B-field indirect with post-increment.

16
Addressing Methods, Examples
  • 0 nop 0, gt1
  • 1 nop 0, _at_5
  • 2 nop 1, lt0
  • 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.
  • Easyright?

17
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.

18
Instruction Modifiers, Examples
  • mov.ba 0, 1 Move b-field of 0 to a-field of
    1
  • nop 0, 0 lt- becomes nop 1, 0
  • add.x 5, 1 Add, in reverse order, a and b
    fields to 1
  • nop -1, -2 lt- 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 lt- becomes nop 1, 7
  • Note It did NOT change the instruction

19
Meet SPL
  • Multi-tasking!
  • SPL Create a new process executing at a-field
    location of SPL.
  • SPL destination
  • spl 1 spl 0 spl _at_0, 10 spl 1, lt1000
  • Like JMP, but SPL jumps AND continues execution
    at the next instruction.
  • Important
  • Each program has its own process queue.
  • Your program will split execution time between
    your processes.

20
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 1

21
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.

22
Rock, Paper, Scissors
  • Very basic look at strategy
  • Paper gt Rock gt Scissors gt 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?

23
Stones (Bombers)
  • org sGo
  • step EQU 551
  • bomb dat 2667, lt5334
  • sGo spl 0, step
  • mov bomb, gt-1
  • add.ab step, -2
  • djn -2, lt-3
  • How it works

24
Papers (Replicators)
  • pBoot spl 1, 1000
  • spl 1, 2000
  • spl 1, 3000
  • pls mov plb, gt8
  • plc mov pls, ltpln
  • pln spl _at_pln, gt-1356
  • mov plb, ltpln
  • mov plb, lt-1000
  • mov plb, gt200
  • jmn.f _at_0, gtpls
  • plb dat lt2667, lt5334
  • How it works

25
Scanners
  • I cant write any simple scanners (
  • Want to see my pimped out tournament submission?
  • Complex, but shouldnt be too hard for the
    troopers in
  • the audience whove 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?)

26
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.

27
Any questions?
28
The DC213 Tournament
  • Given enough interestIll 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.

29
More info
  • http//corewar.info
  • Christian Schmidts (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 Metcalfs Corewar page.

30
The End.
Write a Comment
User Comments (0)
About PowerShow.com