-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtourist.mofu
More file actions
367 lines (319 loc) · 5.52 KB
/
Copy pathtourist.mofu
File metadata and controls
367 lines (319 loc) · 5.52 KB
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
;a
;b
;c
;d instant_iterator
;e iterator
;f iterator_for_ring_buffer_for_junction
;g iterator
;h iterator_for_ring_buffer_for_lambdaman_position
;direction_at_here_
;range[0]~[3]
;ring_buffer_for_prophet
;range [50]~[60]
.const lambda_begin 50
.const lambda_end 60
.const size 10
.const half 5
.const dt 5
.const div_dt 4
;.const count 220
;ring_buffer_for_junction
;range [100]~[130]
.const junction_array_begin 100
.const junction_array_end 130
.const length 30
;.const buffer_end 221
;visited_direction_list
;range [150]~[170]
.const list_begin 150
.const list_end 170
;,const list_count
;tmp variable
.const tmp 200
.const buf 201
.const local 202
;array_property
.const count 220
.const buffer_end 221
.const list_count 222
;vector
.const vx 230
.const vx_d 231
.const vy 232
.const vy_d 233
.const dxdt 234
.const dydt 235
;priority array
.const first 240
.const second 241
.const third 242
.const fourth 243
.const fifth 244
;state
.const visited 246
.const edges 247
.const prev_x 248
.const prev_y 249
.const px 250;lambda man's x
.const py 251;lambda man's y
.const v 252;vitality
.const w 253;way
.const x 254;current x position
.const y 255;current y position
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;direction
.const up 0
.const right 1
.const down 2
.const left 3
int 3;my id
int 5;get current position
mov [$x],a
mov [$y],b
int 3
int 1;get lambdaman's position
mov [$px],a
mov [$py],b
;reset_edge_count
mov [$edges], 0
;check_f_is_not_zero
;this is called once
jgt @junction_check,f,0
mov h, $lambda_begin
mov f, $junction_array_begin
mov [$buffer_end], $junction_array_begin
junction_check:
mov [$tmp], 0
junc_for:
;{
;copy x,y
mov a, [$x]
mov b, [$y]
;one move
jeq @junc_ue, [$tmp],0
jeq @junc_migi, [$tmp],1
jeq @junc_shita, [$tmp],2
;junc_hidari
dec a
jeq @junc_check, 1,1
junc_migi:
inc a
jeq @junc_check, 1,1
junc_ue:
dec b
jeq @junc_check, 1,1
junc_shita:
inc b
junc_check:
int 7
inc [$tmp]
jeq @wall, a, 0
inc [$edges]
wall:
;}
jlt @junc_for, [$tmp], 4
;this is called once
;start_fillin
jeq @filled, [$count],$lambda_end
mov h, $lambda_begin
;for{
fillin:
mov [h],[$x]
inc h
mov [h],[$y]
inc h
jlt @fillin, h, $lambda_end
;}
mov [$count], h
filled:
;get average position
mov [$prev_x], 0
mov [$prev_y], 0
mov g, 0
foraging:
mov [$tmp], [g]
div [$tmp], $half
add [$prev_x], [$tmp]
inc g
mov [$tmp], [g]
div [$tmp], $half
add [$prev_y], [$tmp]
inc g
jlt @foraging,g, $size
jeq @update_lambda, h, $lambda_end
mov h, $lambda_begin
update_lambda:
mov [$tmp] , h ;h is mod position
div [$tmp],$size
mul [$tmp], $size
sub h,[$tmp]
mov [h],[$x]
inc h
mov [h],[$y]
inc h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
jlt @j_loop_end, [$edges],3
mov [0],0
mov [1],0
mov [2],0
mov [3],0
mov e, $junction_array_begin
mov [$visited], 0
junction_array_check_loop:
jeq @j_loop_end, e, [$buffer_end]
mov [$tmp],[e]
inc e
mov [$buf],[e]
inc e
mov d,[e]
inc e
jlt @pass, [$tmp], [$x]
jgt @pass, [$tmp], [$x]
jlt @pass, [$buf], [$y]
jgt @pass, [$buf], [$y]
inc [$visited]
inc [d]
pass:
jeq @junction_array_check_loop, 1, 1
j_loop_end:
jlt @distance_update, [$visited], 3
mov e, 0
mov g, $first
direction_for:
;{
jeq @third_and_fourth, e, 4
mov [$tmp],[e]
mov [$buf], e
inc e
jgt @direction_for,[$tmp],0
mov [g], [$buf]
inc g
third_and_fourth:
mov [$third],[$first]
xor [$third], 2
mov [$fourth],[$second]
xor [$fourth],2
jeq @start_move,1,1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;ghost is not at junction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
distance_update:
jgt @prev_x_than,[$px],[$prev_x]
mov [$dxdt], [$prev_x]
sub [$dxdt], [$px]
mul [$dxdt], $dt
div [$dxdt], $div_dt
sub [$px], [$dxdt]
jeq @x_updated,1,1
prev_x_than:
mov [$dxdt], [$px]
sub [$dxdt], [$prev_x]
mul [$dxdt], $dt
div [$dxdt], $div_dt
add [$px], [$dxdt]
x_updated:
jgt @prev_y_than,[$py],[$prev_y]
mov [$dydt], [$prev_y]
sub [$dydt], [$py]
mul [$dydt], $dt
div [$dydt], $div_dt
sub [$py], [$dydt]
jeq @vy_determined,1,1
prev_y_than:
mov [$dydt], [$py]
sub [$dydt], [$prev_y]
mul [$dydt], $dt
div [$dydt], $div_dt
add [$py], [$dydt]
y_updated:
;vector check
jgt @vx_than,[$x],[$px]
mov [$vx], [$px]
sub [$vx], [$x]
mov [$vx_d], $right
jeq @vx_determined,1,1
vx_than:
mov [$vx], [$x]
sub [$vx], [$px]
mov [$vx_d], $left
vx_determined:
jgt @vy_than,[$y],[$py]
mov [$vy], [$py]
sub [$vy], [$y]
mov [$vy_d], $down
jeq @vy_determined,1,1
vy_than:
mov [$vy], [$y]
sub [$vy], [$py]
mov [$vy_d], $up
vy_determined:
;priority determine
jlt @p_vy_than, [$vx],[$vy]
jeq @p_v_eq, [$vx],[$vy]
p_vx_than:
mov [$first], [$vx_d]
mov [$second], [$vy_d]
mov [$third], [$vx_d]
mov [$fourth],[$vy_d]
jeq @xor,1,1
p_v_eq:
mov [$tmp], $w
and [$tmp], 1
jeq @p_vy_than,[$tmp],1
jeq @p_vx_than,1,1
p_vy_than:
mov [$first], [$vy_d]
mov [$second], [$vx_d]
mov [$third], [$vx_d]
mov [$fourth],[$vy_d]
xor:
xor [$third],2
xor [$fourth],2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
start_move:
mov g, $first
for:
;{
;copy x,y
mov a, [$x]
mov b, [$y]
;one move
jeq @ue, [g],0
jeq @migi, [g],1
jeq @shita, [g],2
;hidari
dec a
jeq @check, 1,1
migi:
inc a
jeq @check, 1,1
ue:
dec b
jeq @check, 1,1
shita:
inc b
check:
int 7
mov [$tmp], a
mov a, [g]
jgt @move, [$tmp], 0
inc g
;}
jlt @for, g, $fifth
move:
int 0
jlt @next_turn, [$edges], 3
;if_junction_then_update
jlt @junction_push, f,$junction_array_end
mov f, $junction_array_begin
junction_push:
mov [f],[$x]
inc f
mov [f],[$y]
inc f
mov [f], a
inc f
jeq @next_turn, [$buffer_end], $junction_array_end
add [$buffer_end], 3
next_turn:
hlt