; cellhack2 — NASM constants. GENERATED by engine/tools/gen_inc.py from ; engine/include/cellhack/view.h and rules.h. Do not edit by hand. ; ; The server prepends this file to your source automatically; you never need ; to %include it. It is published so you can read the names and values. ; ---- ABI ABI_VERSION equ 1 ; bumped when anything in this file changes incompatibly ; ---- Guest memory map (identical for every colony) CODE_BASE equ 0x00100000 ; your program, entry at offset 0, read+exec CODE_SIZE equ 0x00010000 ; 64 KB region; your blob may be at most CODE_MAX bytes CODE_MAX equ 0x00008000 ; 32 KB maximum program size STACK_BASE equ 0x00200000 ; read+write, zeroed before every call STACK_SIZE equ 0x00004000 ; 16 KB; guard pages on both sides are unmapped STACK_TOP equ 0x00204000 ; rsp starts at STACK_TOP-8 (return address pushed) VIEW_BASE equ 0x00300000 ; read-only view struct, also passed in rdi VIEW_SIZE equ 0x00001000 ; 4 KB mapped (struct is VIEW_STRUCT_SIZE bytes) CELLMEM_BASE equ 0x00310000 ; read+write scratch, also passed in rdx CELLMEM_SIZE equ 0x00001000 ; 4 KB; only the first MEM_SIZE bytes persist EXIT_ADDR equ 0x00400000 ; return address; `ret` lands here and ends the call ; ---- View struct, pointer in rdi VIEW_STRUCT_SIZE equ 128 ; total bytes; unused bytes are zero VIEW_TICK equ 0 ; u32 current tick (0-based) VIEW_ENERGY equ 4 ; u16 your energy (same value as rsi) VIEW_RAND equ 6 ; u8 a fresh random byte for this call VIEW_AGE equ 7 ; u8 ticks since you were born, saturates at 255 VIEW_X equ 8 ; u16 your x position (0 = left) VIEW_Y equ 10 ; u16 your y position (0 = top) VIEW_W equ 12 ; u16 arena width VIEW_H equ 14 ; u16 arena height VIEW_POP_SELF equ 16 ; u16 living cells in your colony VIEW_POP_ENEMY equ 18 ; u16 living cells in all other colonies VIEW_COLONY equ 20 ; u8 your colony slot (0..3) VIEW_CELLS equ 32 ; u8[25] 5x5 neighbourhood, row-major, see VIEW_IDX VIEW_ENERGIES equ 64 ; u8[25] energy of each neighbour (0 for empty/wall) VIEW_RADIUS equ 2 ; neighbourhood radius: cells within +-2 are visible VIEW_DIM equ 5 ; neighbourhood is VIEW_DIM x VIEW_DIM VIEW_CENTER equ 12 ; index of yourself: (2+2)*5 + (2+2) ... = 12 ; ---- Neighbour cell types in VIEW_CELLS CELL_EMPTY equ 0 ; nothing there CELL_FRIEND equ 1 ; a cell of your colony CELL_ENEMY equ 2 ; a cell of another colony CELL_WALL equ 3 ; outside the arena ; ---- Directions DIR_UP equ 0 ; y - 1 DIR_RIGHT equ 1 ; x + 1 DIR_DOWN equ 2 ; y + 1 DIR_LEFT equ 3 ; x - 1 ; ---- Actions, returned in al ACT_NOP equ 0x00 ; do nothing (still pays upkeep) ACT_REST equ 0x01 ; gain REST_GAIN energy ACT_MOVE equ 0x10 ; ACT_MOVE + direction ACT_SPLIT equ 0x20 ; ACT_SPLIT + direction: spawn a child there ACT_ATTACK equ 0x30 ; ACT_ATTACK + direction: steal energy from that cell ACT_DIR_MASK equ 0x03 ; low two bits of a MOVE/SPLIT/ATTACK are the direction ; ---- Persistent cell memory, pointer in rdx MEM_SIZE equ 64 ; bytes that survive between calls and are copied to children ; ---- Limits INSN_BUDGET equ 5000 ; instructions per call; exceeding it is a fault (no action) ; ---- Ruleset v1 RULESET_VERSION equ 1 ; rules version these constants belong to ENERGY_MAX equ 255 ; energy is clamped to this ENERGY_START equ 100 ; starting energy of each colony's first cell UPKEEP equ 1 ; energy every living cell pays every tick, whatever it does REST_GAIN equ 4 ; energy gained by ACT_REST (before upkeep) MOVE_COST equ 2 ; paid when you attempt a move, even if you lose the square SPLIT_MIN equ 40 ; you need at least this much energy to split SPLIT_COST equ 4 ; paid on a split attempt; the rest is halved with the child ATTACK_COST equ 2 ; paid on every attack attempt ATTACK_TAKE equ 20 ; at most this much energy is taken from the target MAX_COLONIES equ 4 ; one per corner