-
Notifications
You must be signed in to change notification settings - Fork 1
/
run
executable file
·194 lines (169 loc) · 3.99 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/ruby1.9.1
require './lib/dsl'
##### 30 turns
# build 2^8 = 8192
def build8192
slot(2) { num8192 }
end
##### 44 turns
# build 10k-1 == 9999
if false then
slot(2) { num9999 }
end
##### 602 turns total (including setup from above)
# heal from 10k to 20k
def heal
1.times do
lisp :inc, :zero
lisp :help,
:zero,
:zero,
[:get, [:succ, [:succ, :zero]]]
end
end
##### 214-23 total turns
# heals 48493 at once, calls help using value stored in slot 2 (setup above)
def setup_rec_heal
lisp :s,
[:s, [:k, :get], [:k, :zero] ],
[:s,
[:s,
[:k, [:help, :zero, :zero] ],
[:s,
[:k, :get],
:i] ],
[:k, :zero]
]
k!; s!; succ; k!; s!; succ;
end
# attack for 9k points, dealing 10k damage to own slot 0
def kick
lisp :attack,
:zero,
[:get, [:succ, :zero]],
[:succ, [:get, [:succ, [:succ, :zero]]]] # 1+9999
end
# attack for 2*8192 points, dealing similar damage to own slot 0
# this will kill the opponent in 1 turn, if they haven't healed
def setup_punch
slot 0 do
lisp :attack,
:zero,
[:get, [:succ, [:succ, [:succ, :zero]]]] # slot to attack
k!; s!; get; k!; s!; succ; k!; s!; succ
# [:dbl, [:get, [:succ, [:succ]]]] # 1+9999
end
end
def heal_once
setup_rec_heal
# copy into slot 1.. this is easier (and faster) than setting up a formula
slot(1) { get; zero; }
# heal once.. we are now at 48493
zero
end
def super_heal
lisp :get, [:succ, :zero]
zero
end
# heal again, which will max us out at 65535
#super_heal
#####
# slot 0: active slot.. current functions are run from there
# slot 1: stores copy of rec_heal
# slot 2: stores LARGE_NUM, used for attack/heal
# slot 3: stores slot to attack
# slot 4: stores copy of punch
def perform_attack
slot(3) { zero } # start with slot 0
slot(2) { dbl! }
# start attacking
0.upto(255) do |j|
if j > 0 and j % 2 == 1 then
super_heal
end
# copy punch into slot 0
setup_punch
# attack
slot(0) { zero }
# next slot
slot(3) { succ! }
end
end
def setup_heal10_rec
slot 8 do
lisp :s,
[:s,
[:help, :zero, :zero],
[:s,
[:help, :zero, :zero],
[:s,
[:help, :zero, :zero],
[:s,
[:help, :zero, :zero],
[:s,
[:help, :zero, :zero],
[:s,
[:help, :zero, :zero],
[:s,
[:help, :zero, :zero],
[:s,
[:help, :zero, :zero],
[:s,
[:help, :zero, :zero],
[:s,
[:help, :zero, :zero],
[:help, :zero, :zero]]]]]]]]]]],
[:s,
[:s,
[:k, :get],
[:k, :zero]],
[:k, :zero]]
end
end
def setup_rec_attack_heal
lisp :s, [:attack, :zero, :slot3], :slot8
k!; s!; get; k!; s!; succ; k!; s!; succ
end
def setup
build8192
heal_once
slot(3) { zero } # start with slot 0
setup_heal10_rec
end
def loop_attack
0.upto(255) do |i|
setup_rec_attack_heal
zero
" This isn't working yet.. we need to zombify slot3 with the code in slot8,
and bind it inside K()
"
"
zombie
slot3
k!; s!; s; k!; s!; k; slot8; k!; s!; k; zero
"
slot(3) { succ! }
end
end
def main
setup
while true do
loop_attack
# re-initialize state
slot(0) { put! }
slot(1) { put! }
slot(2) { put! }
slot(3) { put! }
slot(4) { put! }
slot(8) { put! }
setup
# revive all slots
slot(0) { put!; zero; revive!; super_heal }
slot(1) { put!; zero; revive!; super_heal }
slot(2) { put!; zero; revive!; super_heal }
slot(3) { put!; zero; revive!; super_heal }
slot(4) { put!; zero; revive!; super_heal }
slot(8) { put!; zero; revive!; super_heal }
end
end
main