COREWAR

/
Step 21: First Combat: Tune Your Bomb Interval to Destroy the Target
🎯Hit the enemy at Cell 0400 with a DAT bomb and win(0/1)

MISSIONS (30 STEPS)

CH.1: UI & MEMORY BASICS (1-6)
BASIC★☆☆
Step 1: The "STEP" Button That Advances Time
🔒
BASIC★☆☆
Step 2: Process Termination and Restoring with "RESET"
🔒
BASIC★☆☆
Step 3: "Edit Mode" vs. "Running Mode"EDIT
🔒
BASIC★☆☆
Step 4: The Three Rooms of a Memory Box (Changing B)EDIT
🔒
BASIC★☆☆
Step 5: Modifying Both the Left Room (A) and Right Room (B)EDIT
🔒
BASIC★☆☆
Step 6: Literal Numbers (#) vs. Relative Addresses ($)EDIT
CH.2: CORE INSTRUCTIONS (7-13)
🔒
ARITHMETIC★☆☆
Step 7: Observing the "ADD" Instruction
🔒
ARITHMETIC★☆☆
Step 8: Changing the Number to Add (A-Field)EDIT
🔒
ARITHMETIC★☆☆
Step 9: Changing the Target Address (B-Field)EDIT
🔒
ARITHMETIC★☆☆
Step 10: Using the Subtraction Instruction "SUB"EDIT
🔒
BASIC★☆☆
Step 11: Copying an Entire Box with "MOV"EDIT
🔒
CONTROL★☆☆
Step 12: Looping Back in Time with "JMP"EDIT
🔒
CONTROL★☆☆
Step 13: Build Your First Program (Automatic Counter)EDIT
CH.3: VON NEUMANN & DIGITAL LIFE (14-18)
🔒
BASIC★☆☆
Step 14: Why Does "DAT" Become a Bomb?EDIT
🔒
BASIC★☆☆
Step 15: Copying Your Own Instruction (Code = Data)EDIT
🔒
BASIC★☆☆
Step 16: Observation: Stepping Through "Imp", the Oldest Digital Organism
🔒
BASIC★☆☆
Step 17: Modifying the Imp (Copy Destination Experiment)EDIT
🔒
ARITHMETIC★★☆
Step 18: Understanding Indirect Addressing (@ Pointers)EDIT
CH.4: CLASSIC ARCHETYPES (19-24)
🔒
STRATEGY★★☆
Step 19: Observation: Dissecting the "Dwarf" Bomber Step-by-Step
🔒
STRATEGY★★☆
Step 20: Modifying Dwarf (Changing the Bombing Interval)EDIT
🔒
STRATEGY★★☆
Step 21: First Combat: Tune Your Bomb Interval to Destroy the TargetEDIT
🔒
CONTROL★★☆
Step 22: Observation: The "SPL" Split Instruction and Mitosis
🔒
CONTROL★★☆
Step 23: Finding Enemies with Conditional Skip "SEQ / CMP"EDIT
🔒
STRATEGY★★☆
Step 24: Stopping an Imp with a Pre-Decrement "Imp-Gate"EDIT
CH.5: BATTLE EVOLUTION (25-30)
🔒
STRATEGY★★☆
Step 25: [Stone] High-Speed Bomber and Step Size TuningEDIT
🔒
STRATEGY★★☆
Step 26: [Paper] Observing the Self-Replicating Swarm "Mice"
🔒
STRATEGY★★★
Step 27: [Modifying Paper] Tune Clone Dispersal Distance to Overwhelm StoneEDIT
🔒
STRATEGY★★☆
Step 28: [Scissors] Tuning Scanner Stride to Shred PaperEDIT
🔒
STRATEGY★★★
Step 29: [Trap] Abducting Enemy Processes with "Vampire"EDIT
🔒
STRATEGY★★★
Step 30: Graduation Exam: Tune Your Warrior and Win the Final BattleEDIT
🟢 EDIT MODE (Click cells to modify)
[Addr][Opcode][A (Left)][B (Right)]
📦 DATA / BOMB (DAT)
0000
▼MOV
#
$
👈 EDIT
0001
▼MOV
<
<
0002
↺JMN
$
$
0003
❖SPL
@
#
0004
+ADD
#
$
0005
↺JMP
$
$
0006
■DAT
$0
$0
++ ADD ROW
0007
■DAT
$0
$0
0008
■DAT
$0
$0
0009
■DAT
$0
$0
0010
■DAT
$0
$0
0011
■DAT
$0
$0
0012
■DAT
$0
$0
0013
■DAT
$0
$0
0014
■DAT
$0
$0
0015
■DAT
$0
$0
0016
■DAT
$0
$0
0017
■DAT
$0
$0
0018
■DAT
$0
$0
0019
■DAT
$0
$0
0020
■DAT
$0
$0
0021
■DAT
$0
$0
0022
■DAT
$0
$0
0023
■DAT
$0
$0
0024
■DAT
$0
$0
0025
■DAT
$0
$0
0026
■DAT
$0
$0
0027
■DAT
$0
$0
🏟️ARENA (20 ROWS)SCOPE: 0000 - 0019
[CORE MEMORY 800 CELLS (20 ROWS × 40 COLS)]1:1 Row Synced with Editor
P1: 0
P2: 0
CYC: 0
📖 LECTURE NOTE // STEP 21 OF 30Chapter 4: Warrior Dissection, Multitasking & Sensors⏱ 5 min read
📖 Lecture Note: Computer Science & Artificial Life Principles Behind This Experiment

Combat Address Arithmetic and Initial Pointer Calibration

How base address, initial pointer offset, and step stride combine to calculate the exact landing coordinate of your first shot

#Address Arithmetic#Pointer Calibration#Base + Offset + Stride#First-Strike Precision#Multi-Warrior Arena
🔬Step 21: First Combat: Tune Your Bomb Interval to Destroy the Target

Your first enemy (Red Warrior 2) has appeared in the Arena at Address 0400! The enemy is idling at 0400 with JMP $0.

Your Dwarf's pointer at 0003 starts at #392 (0003 + 392 = 0395). With ADD.AB #4, $3, the first bomb lands at 395 + 4 = 0399 and the second at 0403, jumping right over the enemy at 0400!

🎯 Your Task Change the highlighted A (Left Value) on row 0000 from #4 to #5 and press [PLAY] to score a direct hit on 0400 (395 + 5 = 400) and win your first battle!

1. Entering Combat: How MARS Alternates Turns Between Warriors

In Step 21, you graduated from solo target practice into real multi-warrior combat! For the first time, a red enemy program (Warrior 2) appeared halfway across the 800-cell Arena at Address 0400.

When two or more Warriors inhabit the same memory core, how does the MARS processor schedule their execution? MARS enforces strict, deterministic fairness through interleaved turn-taking: - On Cycle 1, Blue (Warrior 1—your program) executes one single instruction. - On Cycle 2, Red (Warrior 2—the opponent) executes one single instruction. - On Cycle 3, Blue executes its next instruction, and so on.

Neither warrior has "private" memory; both live inside the exact same 800 boxes. The battle continues until all execution pointers belonging to one side execute a DAT cell and perish, leaving the surviving warrior victorious. In operating systems history, this shared-memory environment resembles early cooperative multitasking systems (like early Mac OS or Windows 3.1) and embedded real-time kernels without an MMU (Memory Management Unit), where all tasks share a single flat physical address space and any pointer write can directly alter another task's code.

Target Formula: Landing Address = (Pointer Row) + (Initial B-Value) + (1st ADD Stride)
  ├─ Original (#4): 0003 + 392 + 4 = 0399 (Misses Enemy at 0400! Next shot is 0403)
  └─ Tuned    (#5): 0003 + 392 + 5 = 0400 (🎯 Direct Hit on Enemy at 0400 on Shot #1!)

2. The Ballistic Equation: Base Row + Initial Offset + Stride

In this mission, your enemy was a tiny 1-line program ("JMP.A $0, #0") sitting at Address 0400. To destroy it, you tuned row 0000's step size from "#4" to "#5". Let's break down the exact ballistic math—known in systems programming as Address Arithmetic—that made your first shot a bullseye.

Where does Dwarf's very first bomb land? The landing coordinate is the sum of THREE numbers: 1. THE POINTER'S BASE ADDRESS: The pointer box ("DAT.F #0, #392") sits on the 4th line, which is Address 0003. Remember that in indirect addressing ("@2"), the second-stage offset is always measured relative to the pointer cell itself (0003). 2. THE INITIAL POINTER VALUE: At Cycle 0, the B-field of Cell 0003 starts at #392. Before the loop even begins, the pointer aims at 0003 + 392 = Address 0395. 3. THE FIRST "ADD" STRIDE: On Cycle 1, Line 1 ("ADD.AB #Stride, $3") executes BEFORE Line 2 ("MOV") launches the bomb!

Therefore, the exact landing address of Shot #1 is: Shot #1 Address = 0003 (Base) + 392 (Initial B) + Stride - With the original Stride of #4: Shot #1 lands at 0003 + 392 + 4 = Address 0399, and Shot #2 lands at 0399 + 4 = Address 0403—leaping right over the 1-cell enemy at 0400! - By tuning the Stride to #5: Shot #1 lands at 0003 + 392 + 5 = Address 0400—obliterating the enemy's JMP instruction on the very first volley!

3. Preventing Off-By-One Errors in Low-Level Programming

Missing a target address by a single cell—hitting 0399 instead of 0400—is a classic example of what software engineers call an Off-By-One Error.

When working with pointers in assembly or C, off-by-one bugs almost always happen for one of two reasons: forgetting which address serves as the zero base (here, the pointer cell stands at 0003, not 0000!), or forgetting whether the pointer is incremented before or after it is dereferenced (in Dwarf, ADD runs on line 1 before MOV dereferences the pointer on line 2). Mastering the equation "0003 + 392 + 5 = 0400" gives you the exact spatial precision required to engineer surgical strikes. In real-world systems programming—whether calculating memory buffer boundaries, indexing into hardware page tables, or aligning network packet headers—this exact discipline of verifying "Base + Initial Offset + Pre-Increment" saves engineers from catastrophic memory corruption bugs.

🔒

🔒 MISSION CLEAR Unlocks the Full Lecture Note

Complete the experiment in the simulator above to automatically unlock the full deep-dive article—or click below to read the full text immediately.