1;redcode 2;assert CORESIZE==8000 3;name Tangle Trap 3 4;author David Moore 5;strategy .4c pit trapper with error-checking. 6;strategy If damaged, then deploy "airbag" 7;------------------------------------------------------------------- 8; Here's the main code after boot: 9; 10; A add B, check 11; B sub #-step, 2 12; C mov <check, @D 13; D mov <check, @C - step * time 14; E jmz A, check 15; jmp clear, 0 ; go to core clear 16; 17; ... 18; 19; jmp skip + step, skip 20; check jmp trap, 0 21; 22; There are 7 processes in the loop. They execute in this order: 23; 24; CADBECA DBECADB ECADBEC ADBECAD BECADBE ... 25; 26; Look at that again: 27; 28; CADBE CADBE CADBE CADBE CADBE CADBE CADBE ... 29; 30; Note that there are constant additions (+2) and subtractions (-1) 31; to "check". The sum of these changes is zero as long as 32; things work properly. When the loop is damaged, the count 33; is thrown off, causing line E to read a non-zero value. 34; This allows the warrior to leave the crippled code and go 35; quickly to the second phase: a core clear. 36;------------------------------------------------------------------- 37; The pit trap after boot: 38; 39; X spl 0, <2 ; <-- JMP bombs are aimed here 40; Y spl -1, 0 41; Z jmn -1, #MAXPROCESSES 42; dat 0, 0 43; 44; Every new process in the pit lands on X once and only once. 45; Line Z is a counter for how many processes remain outside 46; of the pit. As soon as the count reaches 0, you can be sure 47; that all processes are at Y and Z. Next, they will all go 48; to Z and the DAT, with no chance to return to the pit. Checkmate! 49;------------------------------------------------------------------- 50; vamp numbers 51; boot distances 52 ORG START 53 MOV.I $ 23, @ 21 54 MOV.I $ 24, @ 4 55 MOV.I $ 22, < 3 56 MOV.I $ 19, $ -2957 57 SPL.B $ 5, $ -2673 58 SPL.B $ -2892, $ -2849 59 SPL.B @ 0, $ -2889 60 MOV.I < -1, $ -2 61 DAT.F < -4, < -5 62 SPL.B $ -2895, $ -2936 63 SPL.B @ 0, $ -2898 64 MOV.I < -1, $ -2 65 DAT.F < -2, < 957 66START SPL.B $ -13, < 564 67 SPL.B $ 2, < -1348 68 SPL.B $ 1, < -614 69 MOV.I < 11, < -10 70 MOV.I < 10, < -11 71 MOV.I < 9, < -9 72 MOV.I < 8, < -15 73 DJN.B @ -10, # 3 74 DJN.B @ -15, # -2955 75 JMP.B $ 0, < 0 76 DAT.F < -8, # -10 77 JMP.B $ -67, $ -18 78 JMP.B $ 458, $ 2 79 SPL.B $ 0, < 2 80 SPL.B $ -1, $ 11 81 JMN.B $ -1, # 0 82 SPL.B $ 0, < -7 83 MOV.I $ -5, < -5 84 DJN.B $ -1, < 3984 85 ADD.F $ 1, $ 45 86 SUB.AB # 49, $ 2 87 MOV.I < 43, @ 1 88 MOV.I < 42, @ -177 89 JMZ.B $ -4, $ 41 90 JMP.B $ -46, $ 0 91 92