-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameOfLife.ps
598 lines (392 loc) · 16.1 KB
/
GameOfLife.ps
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
/arg{exch def} def
/board {
[
[0 0 0 0 1 0 0 0 0 0 1 0]
[0 0 0 1 1 1 0 0 0 0 0 1]
[0 0 0 0 1 0 0 0 0 1 0 0]
[0 0 0 0 1 0 0 0 1 0 1 0]
[0 0 0 0 1 0 0 0 0 1 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 1 0 0 0 0 1 1 0]
[0 0 0 0 1 0 0 0 1 1 1 0]
[0 0 0 0 1 0 0 0 0 1 0 0]
[0 0 0 0 1 0 0 0 0 0 0 0]
] } def
/deleteboard {
[
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
]
} def
/funboard {
[
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 1 0 0 0 0 0 0 0]
[0 0 0 1 0 1 1 0 0 0 0 0]
[0 0 0 0 1 0 0 1 0 0 0 0]
[0 0 0 0 0 1 1 0 1 0 0 0]
[0 0 0 0 0 0 0 1 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0]
]
} def
/returnrand {
rand 2 mod
} def
/a1 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a2 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a3 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a4 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a5 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a6 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a7 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a8 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a9 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a10 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a11 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a12 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a13 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a14 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a15 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a16 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a17 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a18 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a19 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a20 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a21 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a22 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a23 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a24 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a25 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a26 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a27 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a28 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a29 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a30 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a31 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a32 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a33 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a34 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a35 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a36 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a37 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a38 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a39 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a40 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a41 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a42 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a43 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a44 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a45 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a46 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a47 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a48 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a49 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a50 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a51 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a52 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a53 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a54 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a55 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a56 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a57 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a58 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a59 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a60 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a61 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a62 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a63 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a64 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a65 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a66 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a67 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a68 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a69 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a70 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a71 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a72 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a73 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a74 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a75 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a76 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a77 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a78 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a79 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a80 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a81 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a82 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a83 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a84 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a85 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a86 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a87 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a88 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a89 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a90 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a91 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a92 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a93 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a94 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a95 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a96 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a97 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a98 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a99 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a100 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a101 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a102 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a103 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a104 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a105 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a106 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a107 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a108 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a109 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a110 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a111 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a112 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a113 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a114 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a115 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a116 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a117 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a118 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a119 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a120 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a121 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a122 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a123 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a124 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a125 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a126 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a127 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a128 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a129 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a130 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a131 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a132 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a133 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a134 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a135 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a136 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a137 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a138 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a139 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a140 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a141 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a142 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a143 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/a144 {rand 16#7fffffff div 100 mul cvi 5 mod 1 eq {1} {0} ifelse} def
/randboard {
[
[ a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12]
[ a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24]
[ a25 a26 a27 a28 a29 a30 a31 a32 a33 a34 a35 a36]
[ a37 a38 a39 a40 a41 a42 a43 a44 a45 a46 a47 a48]
[ a49 a50 a51 a52 a53 a54 a55 a56 a57 a58 a59 a60]
[ a61 a62 a63 a64 a65 a66 a67 a68 a69 a70 a71 a72]
[ a73 a74 a75 a76 a77 a78 a79 a80 a81 a82 a83 a84]
[ a85 a86 a87 a88 a89 a90 a91 a92 a93 a94 a95 a96]
[ a97 a98 a99 a100 a101 a102 a103 a104 a105 a106 a107 a108 ]
[ a109 a110 a111 a112 a113 a114 a115 a116 a117 a118 a119 a120 ]
[ a121 a122 a123 a124 a125 a126 a127 a128 a129 a130 a131 a132 ]
[ a133 a134 a135 a136 a137 a138 a139 a140 a141 a142 a143 a144]
]
} def
% size x y drawsquare
/drawsquare { 1 dict begin
/size arg
newpath
moveto
0 size rlineto
size 0 rlineto
0 size neg rlineto
size 0 rlineto
fill
} def
/drawboard { 1 dict begin
/board arg
/xoff arg
/yoff arg
/x 0 def
/y 0 def
board length {
board 0 get length {
1 board x get y get eq {
/xpos x xoff add def
/ypos y yoff add def
ypos 10 mul
board length xpos 1 add sub 10 mul
10 drawsquare
} if
/y y 1 add def
} repeat
/y 0 def
/x x 1 add def
} repeat
end
} def
/assert-are-equal {
0 dict begin
/observed arg
/expected arg
observed type expected type eq not
observed expected eq not or {
(bad. expected something else) print stop} if
end
} def
/assert-are-equal-array {
0 dict begin
/observed arg
/expected arg
observed length expected length ne {(not the same length) print stop} if
0 1 observed length 1 sub
{/i arg
observed i get expected i get ne {(not the same array) print stop} if
} for
end
} def
%Takes in (x y board) returns the number of alive neighbors
/isalive {
/board arg
/y arg
/x arg
/i -1 def
/j -1 def
/alivecells 0 def
3 {
3 {
i x add board length lt
{
i x add -1 gt
{
j y add -1 gt
{
j y add board length lt
{
i x add x eq
j y add y eq
and
{}
{
/alivecells
board i x add get
j y add get
alivecells add def
}
ifelse
}
{}
ifelse
}
{}
ifelse
}
{}
ifelse
}
{}
ifelse
/i i 1 add def
} repeat
/i -1 def
/j j 1 add def
} repeat
alivecells
} def
%Takes in a board and returns a board of the next living generation
/nextgeneration {
/board arg
/x 0 def
/y 0 def
/newboard board length array def
/j 0 def
newboard length {
newboard j newboard length array put
/j j 1 add def
} repeat
board length {
board length {
/alivecells x y board isalive def
alivecells 4 lt
{
alivecells 2 lt
{ newboard x get y 0 put }
{
alivecells 2 eq
{
board x get y get 1 eq
{ newboard x get y 1 put }
{ newboard x get y 0 put }
ifelse
}
{ newboard x get y 1 put }
ifelse
}
ifelse
}
{ newboard x get y 0 put }
ifelse
/x x 1 add def
} repeat
/x 0 def
/y y 1 add def
} repeat
newboard
} def
/twelveboards{
1 1 0 setrgbcolor
0 -64 randboard drawboard
1 0 1 setrgbcolor
/newboard board nextgeneration def
14 -64 newboard drawboard
1 0 0 setrgbcolor
/newboard board nextgeneration def
28 -64 newboard drawboard
1 1 0 setrgbcolor
/newboard board nextgeneration def
42 -64 newboard drawboard
0 1 1 setrgbcolor
/newboard board nextgeneration def
0 -50 newboard drawboard
0 1 0 setrgbcolor
/newboard board nextgeneration def
14 -50 newboard drawboard
0 .5 1 setrgbcolor
/newboard board nextgeneration def
28 -50 newboard drawboard
1 0 .5 setrgbcolor
/newboard board nextgeneration def
42 -50 newboard drawboard
1 .5 .5 setrgbcolor
/newboard board nextgeneration def
0 -36 newboard drawboard
.5 .5 1 setrgbcolor
/newboard board nextgeneration def
14 -36 newboard drawboard
0 0 .5 setrgbcolor
/newboard board nextgeneration def
28 -36 newboard drawboard
.3 .7 0 setrgbcolor
/newboard board nextgeneration def
42 -36 newboard drawboard
} def
twelveboards
%srand
showpage